From: Mario Date: Wed, 28 Aug 2019 09:14:39 +0000 (+1000) Subject: Don't get xyspeed when not performing bobbing, reduces a sqrt call when not needed X-Git-Tag: xonotic-v0.8.5~1105^2~59^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c34acf27a4226b12d4576d9e1e05cc78e0a76975;p=xonotic%2Fxonotic-data.pk3dir.git Don't get xyspeed when not performing bobbing, reduces a sqrt call when not needed --- diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index b20a04cd4..d791c5b5b 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -280,7 +280,6 @@ vector CSQCPlayer_ApplyBobbing(entity this, vector v) return v; // bounded XY speed, used by several effects below - float xyspeed = bound(0, sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), autocvar_cl_bob_velocity_limit); float bob, cycle; // vertical view bobbing code @@ -314,6 +313,7 @@ vector CSQCPlayer_ApplyBobbing(entity this, vector v) cycle = sin(M_PI + M_PI * (cycle - autocvar_cl_bobup) / (1.0 - autocvar_cl_bobup)); // bob is proportional to velocity in the xy plane // (don't count Z, or jumping messes it up) + float xyspeed = bound(0, sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), autocvar_cl_bob_velocity_limit); bob = xyspeed * autocvar_cl_bob; bob = bound(0, bob, bob_limit); bob = bob * 0.3 + bob * 0.7 * cycle;