]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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)
committerRudolf Polzer <divVerent@alientrap.org>
Mon, 1 Feb 2010 07:14:57 +0000 (08:14 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9890 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=d8ad148d989423fd3f2f0c76c5e93d31fd1804c4

cl_input.c

index 51cdcc6b05379e82877b4b96e6a63d48347da1f9..93e84c3eb1499f5c5b7268a1fb02ca05f8f6e5c5 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);