make CPMA air control code more logical
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Jan 2010 18:08:12 +0000 (18:08 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Jan 2010 18:08:12 +0000 (18:08 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9890 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c

index 51cdcc6..93e84c3 100644 (file)
@@ -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);