]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
hud_shownames: comparing distance squared is even faster 267/head
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 20 Dec 2015 01:31:41 +0000 (12:31 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 20 Dec 2015 01:31:41 +0000 (12:31 +1100)
qcsrc/client/shownames.qc

index dcb6a0692ca91624a5346e3c7175d4b05320579f..737535a08804cdd1c25179c14d27b0465891468d 100644 (file)
@@ -69,8 +69,10 @@ void Draw_ShowNames(entity this)
        bool onscreen = (o.z >= 0 && o.x >= 0 && o.y >= 0 && o.x <= vid_conwidth && o.y <= vid_conheight);
        if (autocvar_hud_shownames_crosshairdistance)
        {
-               float crosshairdistance = sqrt(pow(o.x - vid_conwidth / 2, 2) + pow(o.y - vid_conheight / 2, 2));
-               if (autocvar_hud_shownames_crosshairdistance > crosshairdistance) this.pointtime = time;
+               float d = autocvar_hud_shownames_crosshairdistance;
+               float w = o.x - vid_conwidth / 2;
+               float h = o.y - vid_conheight / 2;
+               if (d * d > w * w + h * h) this.pointtime = time;
                if (this.pointtime + autocvar_hud_shownames_crosshairdistance_time <= time) overlap = true;
                else overlap = (autocvar_hud_shownames_crosshairdistance_antioverlap ? overlap : false); // override what antioverlap says unless allowed by cvar.
        }