From d6dc18d3bd0af73f03a5856c8f7472b6f8caab08 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Wed, 16 Dec 2020 19:19:59 +0000 Subject: [PATCH] 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 --- cl_input.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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) { -- 2.39.2