]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
change cl_lerping interpolation model from euler angles interpolation to forward...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 22 Oct 2009 07:19:57 +0000 (07:19 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 22 Oct 2009 07:19:57 +0000 (07:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9375 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c

index bf4d1d80ebf2ecdf94345141f39937b65468bb23..ef74fd14384a76ef2c834d7f9e0495e0b7acac30 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -864,7 +864,7 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat
        const matrix4x4_t *matrix;
        matrix4x4_t blendmatrix, tempmatrix, matrix2;
        int j, k, l, frame;
-       float origin[3], angles[3], delta[3], lerp, d;
+       float origin[3], angles[3], lerp, d;
        entity_t *t;
        dp_model_t *model;
        //entity_persistent_t *p = &e->persistent;
@@ -960,11 +960,23 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat
                // interpolate the origin and angles
                lerp = max(0, lerp);
                VectorLerp(e->persistent.oldorigin, lerp, e->persistent.neworigin, origin);
+#if 0
+               // this fails at the singularity of euler angles
                VectorSubtract(e->persistent.newangles, e->persistent.oldangles, delta);
                if (delta[0] < -180) delta[0] += 360;else if (delta[0] >= 180) delta[0] -= 360;
                if (delta[1] < -180) delta[1] += 360;else if (delta[1] >= 180) delta[1] -= 360;
                if (delta[2] < -180) delta[2] += 360;else if (delta[2] >= 180) delta[2] -= 360;
                VectorMA(e->persistent.oldangles, lerp, delta, angles);
+#else
+               {
+                       vec3_t f0, u0, f1, u1;
+                       AngleVectors(e->persistent.oldangles, f0, NULL, u0);
+                       AngleVectors(e->persistent.newangles, f1, NULL, u1);
+                       VectorMAM(1-lerp, f0, lerp, f1, f0);
+                       VectorMAM(1-lerp, u0, lerp, u1, u0);
+                       AnglesFromVectors(angles, f0, u0, false);
+               }
+#endif
        }
        else
        {