From: bones_was_here Date: Wed, 31 Jul 2024 11:11:42 +0000 (+1000) Subject: physics: fix a subtle prediction regression X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=801605f9f6d61a742c4415c9abba69e411968398;p=xonotic%2Fdarkplaces.git physics: fix a subtle prediction regression In 3d8f1ca7b142c0a9fd8c3b4a494b62dcce39ab71 a horizontal player speed calculation was changed to include the vertical velocity and to no longer be the speed, by use of the wrong macro. This patch reverts those changes and adds a macro for this calculation. Signed-off-by: bones_was_here --- diff --git a/cl_input.c b/cl_input.c index 21c2ad64..5468a4e2 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1367,7 +1367,7 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) wishspeed *= 0.5; // apply edge friction - speed = VectorLength2(s->velocity); + speed = Vector2Length(s->velocity); if (speed > 0) { friction = cl.movevars_friction; diff --git a/mathlib.h b/mathlib.h index 2fa93a1c..eee0373a 100644 --- a/mathlib.h +++ b/mathlib.h @@ -76,6 +76,7 @@ unsigned int CeilPowerOf2(unsigned int value); #define Vector2Set(a,b,c) ((a)[0]=(b),(a)[1]=(c)) #define Vector2Scale(in, scale, out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale)) #define Vector2Normalize2(v,dest) {float ilength = (float)DotProduct2((v),(v));if (ilength) ilength = 1.0f / sqrt(ilength);dest[0] = (v)[0] * ilength;dest[1] = (v)[1] * ilength;} +#define Vector2Length(a) (sqrt(DotProduct2(a, a))) #define DotProduct4(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2]+(a)[3]*(b)[3]) #define Vector4Clear(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0) diff --git a/sv_user.c b/sv_user.c index 58bef9bf..1192e586 100644 --- a/sv_user.c +++ b/sv_user.c @@ -320,7 +320,7 @@ static void SV_UserFriction (void) vec3_t start, stop; trace_t trace; - speed = sqrt(PRVM_serveredictvector(host_client->edict, velocity)[0]*PRVM_serveredictvector(host_client->edict, velocity)[0]+PRVM_serveredictvector(host_client->edict, velocity)[1]*PRVM_serveredictvector(host_client->edict, velocity)[1]); + speed = Vector2Length(PRVM_serveredictvector(host_client->edict, velocity)); if (!speed) return;