]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize more maths
authorMario <mario@smbclan.net>
Tue, 29 Dec 2015 01:31:32 +0000 (11:31 +1000)
committerMario <mario@smbclan.net>
Tue, 29 Dec 2015 01:31:53 +0000 (11:31 +1000)
qcsrc/client/view.qc
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/lib/csqcmodel/cl_player.qc

index 43b7f72f6c6767a7e0fd1c6850d9214c859802b7..a05407e9023d1b8df08e2d289aac957577f9dfe9 100644 (file)
@@ -1576,14 +1576,14 @@ void CSQC_UpdateView(float w, float h)
                float ov_furthest = 0;
                float dist = 0;
 
-               if((dist = vlen(vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmin.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
-               if((dist = vlen(vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmin.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmin.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmin.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
+               if((dist = vdist((vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org), >, ov_furthest))) { ov_furthest = dist; }
 
                if(!ov_enabled)
                {
@@ -2239,7 +2239,7 @@ void CSQC_Demo_Camera()
        else
        {
                tmp = getmousepos() * 0.1;
-               if(vlen(tmp)>autocvar_camera_mouse_threshold)
+               if(vdist(tmp, >, autocvar_camera_mouse_threshold))
                {
                        mouse_angles.x += tmp.y * cos(mouse_angles.z * DEG2RAD) + (tmp.x * sin(mouse_angles.z * DEG2RAD));
                        mouse_angles.y -= tmp.x * cos(mouse_angles.z * DEG2RAD) + (tmp.y * -sin(mouse_angles.z * DEG2RAD));
index 01296010b8ac7a05e319c370961134c35abc3049..0a8efb3b33fe3c8a6dc6e51be899a00e71b40439 100644 (file)
@@ -145,7 +145,7 @@ void DamageEffect(vector hitorg, float thedamage, int type, int specnum)
                        continue; // player model bone blacklist
 
                // now choose the bone closest to impact origin
-               if(nearestbone == 0 || vlen(hitorg - gettaginfo(self, tagnum)) <= vlen(hitorg - gettaginfo(self, nearestbone)))
+               if(nearestbone == 0 || vlen2(hitorg - gettaginfo(self, tagnum)) <= vlen2(hitorg - gettaginfo(self, nearestbone)))
                        nearestbone = tagnum;
        }
        gettaginfo(self, nearestbone); // set gettaginfo_name
@@ -253,7 +253,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
                }
                else
                {
-                       if(vlen(nearest - w_org) > bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS))
+                       if(vdist((nearest - w_org), >, bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS)))
                                continue;
 
                        thisdmg = thedamage;
index e9973037738df639e2d1f7723dd41214117bbcb2..d51119775c188be5551688c4c3838c36ed208514 100644 (file)
@@ -75,7 +75,7 @@ void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff)
                return;
        }
        */
-       if(vlen(o) > 32 || vlen(v) > 192)
+       if(vdist(o, >, 32) || vdist(v, >, 192))
        {
                //printf("TOO BIG: x=%v v=%v\n", o, v);
                return;