]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/csqcmodel/cl_player.qc
Don't get xyspeed when not performing bobbing, reduces a sqrt call when not needed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / csqcmodel / cl_player.qc
index b20a04cd4ed3bee048c23570fe7b2f5caed6159a..d791c5b5bfcbc2dcbe0ea6fda19b7d59d1a4d0b6 100644 (file)
@@ -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;