From 1c8ef2661b58dbe3a3941fec0795ad1c01ca9bef Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 29 Jan 2010 16:52:27 +0000 Subject: [PATCH] cl_physics: an "alternate speed clamping" mode (iffed out until I added support for it to cl_movement) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8589 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_physics.qc | 34 ++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/data/qcsrc/server/cl_physics.qc b/data/qcsrc/server/cl_physics.qc index ad6ffa6e9..cb4f1d9dd 100644 --- a/data/qcsrc/server/cl_physics.qc +++ b/data/qcsrc/server/cl_physics.qc @@ -424,11 +424,35 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce vel_z = self.velocity_z; vel_perpend = self.velocity - vel_straight * wishdir - vel_z * '0 0 1'; - addspeed = wishspeed - vel_straight; - if(addspeed > 0) - vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed0) * accelqw; - if(wishspeed > 0) - vel_straight = vel_straight + min(wishspeed, accel * frametime * wishspeed0) * (1 - accelqw); +#if 0 + if(cvar("sv_gameplayfix_alternatespeedclamp")) + { + // 1. move as normal, but fake a forward move to get the maximum ALLOWED speed + float vel_xy; + vel_xy = sqrt(vel_straight * vel_straight + vel_perpend * vel_perpend); + addspeed = wishspeed - vel_xy; + if(addspeed > 0) + vel_xy = vel_xy + min(addspeed, accel * frametime * wishspeed0) * accelqw; + if(wishspeed > 0) + vel_xy = vel_xy + accel * frametime * wishspeed0 * (1 - accelqw); + // 2. accelerate actually, using our acceleration factor and the max allowed forward speed we derived + // we may add at most a vector length of min(wishspeed, accel * frametime * wishspeed0) + // however, the absolute value must not exceed vel_xy + addspeed = accel * frametime * wishspeed0; + addspeed = bound(0, sqrt(vel_xy * vel_xy - vel_perpend * vel_perpend) - vel_straight, addspeed); + // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // this is how much we can add without exceeding vel_xy + vel_straight += addspeed; + } + else +#endif + { + addspeed = wishspeed - vel_straight; + if(addspeed > 0) + vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed0) * accelqw; + if(wishspeed > 0) + vel_straight = vel_straight + accel * frametime * wishspeed0 * (1 - accelqw); + } if(sidefric < 0 && (vel_perpend*vel_perpend)) { -- 2.39.2