From: cloudwalk Date: Wed, 16 Dec 2020 19:19:59 +0000 (+0000) Subject: cl_input: Simplify wishspeed calculation to use VectorNormalizeLength instead of... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d6dc18d3bd0af73f03a5856c8f7472b6f8caab08;p=xonotic%2Fdarkplaces.git cl_input: Simplify wishspeed calculation to use VectorNormalizeLength instead of duplicating its functionality git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13067 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index 49fd61d0..a1e8cb85 100644 --- a/cl_input.c +++ b/cl_input.c @@ -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) {