]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
physics: fix a subtle prediction regression
authorbones_was_here <bones_was_here@xonotic.au>
Wed, 31 Jul 2024 11:11:42 +0000 (21:11 +1000)
committerDes <xon@damianv.com.ar>
Mon, 5 Aug 2024 11:59:15 +0000 (08:59 -0300)
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 <bones_was_here@xonotic.au>
cl_input.c
mathlib.h
sv_user.c

index 21c2ad6435e7049b3795e87dbe8342001b6e7f6d..5468a4e2499d535d7b4abd0991a0b71d51ef9631 100644 (file)
@@ -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;
index 2fa93a1cb6626b7826922aeae0e0c314d82cdbc6..eee0373ad87b651cfed8cdb0bb4943010ed8d3d8 100644 (file)
--- 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)
index 58bef9bfb0a3f44a31ac9ec3270af7a91c19f75a..1192e58698f2500d64f305075471a0ff2d0b227e 100644 (file)
--- 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;