From d8ad148d989423fd3f2f0c76c5e93d31fd1804c4 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 30 Jan 2010 18:08:12 +0000 Subject: [PATCH] make CPMA air control code more logical git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9890 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_input.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cl_input.c b/cl_input.c index 51cdcc6b..93e84c3e 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1080,13 +1080,15 @@ void CL_ClientMovement_Physics_Swim(cl_clientmovement_state_t *s) static vec_t CL_IsMoveInDirection(vec_t forward, vec_t side, vec_t angle) { + if(forward == 0 && side == 0) + return 0; // avoid division by zero angle -= RAD2DEG(atan2(side, forward)); - angle = (ANGLEMOD(angle + 180) - 180) / 22.5; + angle = (ANGLEMOD(angle + 180) - 180) / 45; if(angle > 1) return 0; if(angle < -1) return 0; - return 1 - angle * angle; + return 1 - fabs(angle); } void CL_ClientMovement_Physics_CPM_PM_Aircontrol(cl_clientmovement_state_t *s, vec3_t wishdir, vec_t wishspeed) @@ -1099,11 +1101,13 @@ void CL_ClientMovement_Physics_CPM_PM_Aircontrol(cl_clientmovement_state_t *s, v return; k = 32; #else - k = 32 * CL_IsMoveInDirection(s->cmd.forwardmove, s->cmd.sidemove, 0); + k = 32 * (2 * CL_IsMoveInDirection(s->cmd.forwardmove, s->cmd.sidemove, 0) - 1); if(k <= 0) return; #endif + k *= bound(0, wishspeed / cl.movevars_maxairspeed, 1); + zspeed = s->velocity[2]; s->velocity[2] = 0; speed = VectorNormalizeLength(s->velocity); -- 2.39.2