From: divverent Date: Sat, 6 Mar 2010 15:37:45 +0000 (+0000) Subject: properly support huge sideways friction X-Git-Tag: xonotic-v0.1.0preview~230^2~432 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fb50a9a778603419fe35c6c6fbb018b3bcff7783;p=xonotic%2Fdarkplaces.git properly support huge sideways friction git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10037 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index 5c4d449d..6aaf8139 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1169,18 +1169,23 @@ void CL_ClientMovement_Physics_PM_Accelerate(cl_clientmovement_state_t *s, vec3_ // negative: only apply so much sideways friction to stay below the speed you could get by "braking" { vec_t f, fmin; - f = 1 - s->cmd.frametime * wishspeed * sidefric; + f = max(0, 1 + s->cmd.frametime * wishspeed * sidefric); fmin = (vel_xy_backward*vel_xy_backward - vel_straight*vel_straight) / VectorLength2(vel_perpend); + // assume: fmin > 1 + // vel_xy_backward*vel_xy_backward - vel_straight*vel_straight > vel_perpend*vel_perpend + // vel_xy_backward*vel_xy_backward > vel_straight*vel_straight + vel_perpend*vel_perpend + // vel_xy_backward*vel_xy_backward > vel_xy * vel_xy + // obviously, this cannot be if(fmin <= 0) VectorScale(vel_perpend, f, vel_perpend); else { fmin = sqrt(fmin); - VectorScale(vel_perpend, bound(fmin, f, 1.0f), vel_perpend); + VectorScale(vel_perpend, max(fmin, f), vel_perpend); } } else - VectorScale(vel_perpend, 1 - s->cmd.frametime * wishspeed * sidefric, vel_perpend); + VectorScale(vel_perpend, max(0, 1 - s->cmd.frametime * wishspeed * sidefric), vel_perpend); VectorMA(vel_perpend, vel_straight, wishdir, s->velocity);