From: Mario Date: Tue, 29 Dec 2015 01:31:32 +0000 (+1000) Subject: Optimize more maths X-Git-Tag: xonotic-v0.8.2~1368 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=80a353319ac67130b65e8cd6b1ea2420f31928e2;p=xonotic%2Fxonotic-data.pk3dir.git Optimize more maths --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 43b7f72f6..a05407e90 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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)); diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index 01296010b..0a8efb3b3 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -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; diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index e99730377..d51119775 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -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;