]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cl_input: Simplify wishspeed calculation to use VectorNormalizeLength instead of...
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 16 Dec 2020 19:19:59 +0000 (19:19 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 16 Dec 2020 19:19:59 +0000 (19:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13067 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c

index 49fd61d031416b57295220f9b60bf0e2f066ec1a..a1e8cb85b6fa3912a51c9f24888340a461281951 100644 (file)
@@ -1046,11 +1046,8 @@ static void CL_ClientMovement_Physics_Swim(cl_clientmovement_state_t *s)
        }
 
        // split wishvel into wishspeed and wishdir
-       wishspeed = VectorLength(wishvel);
-       if (wishspeed)
-               VectorScale(wishvel, 1 / wishspeed, wishdir);
-       else
-               VectorSet( wishdir, 0.0, 0.0, 0.0 );
+       VectorCopy(wishvel, wishdir);
+       wishspeed = VectorNormalizeLength(wishdir);
        wishspeed = min(wishspeed, cl.movevars_maxspeed) * 0.7;
 
        if (s->crouched)
@@ -1333,11 +1330,9 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
        VectorMAM(s->cmd.forwardmove, forward, s->cmd.sidemove, right, wishvel);
 
        // split wishvel into wishspeed and wishdir
-       wishspeed = VectorLength(wishvel);
-       if (wishspeed)
-               VectorScale(wishvel, 1 / wishspeed, wishdir);
-       else
-               VectorSet( wishdir, 0.0, 0.0, 0.0 );
+       VectorCopy(wishvel, wishdir);
+       wishspeed = VectorNormalizeLength(wishdir);
+
        // check if onground
        if (s->onground)
        {