[nexuiz-commits] r8589 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Jan 29 11:52:27 EST 2010
Author: div0
Date: 2010-01-29 11:52:27 -0500 (Fri, 29 Jan 2010)
New Revision: 8589
Modified:
trunk/data/qcsrc/server/cl_physics.qc
Log:
cl_physics: an "alternate speed clamping" mode (iffed out until I added support for it to cl_movement)
Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc 2010-01-29 11:37:51 UTC (rev 8588)
+++ trunk/data/qcsrc/server/cl_physics.qc 2010-01-29 16:52:27 UTC (rev 8589)
@@ -424,11 +424,35 @@
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))
{
More information about the nexuiz-commits
mailing list