]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed viewmodel (it wasn't drawing because it's matrix was empty), fixed a bug with...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Aug 2002 14:14:34 +0000 (14:14 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Aug 2002 14:14:34 +0000 (14:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2310 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
matrixlib.c

index d0a46fa24af4c1ed6422a427904fdfcf8020b728..9c2cfdbb732b9e97f53dc8e98c885c5727e61690 100644 (file)
@@ -505,6 +505,9 @@ void R_DrawViewModel (void)
 
        R_LerpAnimation(ent);
 
+       Matrix4x4_CreateFromQuakeEntity(&ent->matrix, ent->origin[0], ent->origin[1], ent->origin[2], -ent->angles[0], ent->angles[1], ent->angles[2], ent->scale);
+       Matrix4x4_Invert_Simple(&ent->inversematrix, &ent->matrix);
+
        ent->model->Draw(ent);
 }
 
index ff447d7ab5f3a7a5dc17d81a5048c663b851391e..603b617c0129c124c184ed2f526974f07a3a3575 100644 (file)
@@ -135,7 +135,15 @@ void Matrix4x4_Invert_Simple (matrix4x4_t *out, const matrix4x4_t *in1)
        // (note the lack of sqrt here, because we're trying to undo the scaling,
        // this means multiplying by the inverse scale twice - squaring it, which
        // makes the sqrt a waste of time)
+#if 1
        double scale = 1.0 / (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2]);
+#else
+       double scale = 3.0 / sqrt
+                (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2]
+               + in1->m[1][0] * in1->m[1][0] + in1->m[1][1] * in1->m[1][1] + in1->m[1][2] * in1->m[1][2]
+               + in1->m[2][0] * in1->m[2][0] + in1->m[2][1] * in1->m[2][1] + in1->m[2][2] * in1->m[2][2]);
+#endif
+       scale *= scale;
 
        // invert the rotation by transposing and multiplying by the squared
        // recipricol of the input matrix scale as described above
@@ -287,17 +295,17 @@ void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, float x, float y, float z
        angle = roll * (M_PI*2 / 360);
        sr = sin(angle);
        cr = cos(angle);
-       out->m[0][0] = cp*cy * scale;
-       out->m[0][1] = sr*sp*cy+cr*-sy * scale;
-       out->m[0][2] = cr*sp*cy+-sr*-sy * scale;
+       out->m[0][0] = (cp*cy) * scale;
+       out->m[0][1] = (sr*sp*cy+cr*-sy) * scale;
+       out->m[0][2] = (cr*sp*cy+-sr*-sy) * scale;
        out->m[0][3] = x;
-       out->m[1][0] = cp*sy * scale;
-       out->m[1][1] = sr*sp*sy+cr*cy * scale;
-       out->m[1][2] = cr*sp*sy+-sr*cy * scale;
+       out->m[1][0] = (cp*sy) * scale;
+       out->m[1][1] = (sr*sp*sy+cr*cy) * scale;
+       out->m[1][2] = (cr*sp*sy+-sr*cy) * scale;
        out->m[1][3] = y;
-       out->m[2][0] = -sp * scale;
-       out->m[2][1] = sr*cp * scale;
-       out->m[2][2] = cr*cp * scale;
+       out->m[2][0] = (-sp) * scale;
+       out->m[2][1] = (sr*cp) * scale;
+       out->m[2][2] = (cr*cp) * scale;
        out->m[2][3] = z;
        out->m[3][0] = 0;
        out->m[3][1] = 0;
@@ -503,7 +511,14 @@ void Matrix3x4_Invert_Simple (matrix3x4_t *out, const matrix3x4_t *in1)
        // (note the lack of sqrt here, because we're trying to undo the scaling,
        // this means multiplying by the inverse scale twice - squaring it, which
        // makes the sqrt a waste of time)
+#if 1
        double scale = 1.0 / (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2]);
+#else
+       double scale = 3.0 / sqrt
+                (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2]
+               + in1->m[1][0] * in1->m[1][0] + in1->m[1][1] * in1->m[1][1] + in1->m[1][2] * in1->m[1][2]
+               + in1->m[2][0] * in1->m[2][0] + in1->m[2][1] * in1->m[2][1] + in1->m[2][2] * in1->m[2][2]);
+#endif
 
        // invert the rotation by transposing and multiplying by the squared
        // recipricol of the input matrix scale as described above
@@ -630,17 +645,17 @@ void Matrix3x4_CreateFromQuakeEntity(matrix3x4_t *out, float x, float y, float z
        angle = roll * (M_PI*2 / 360);
        sr = sin(angle);
        cr = cos(angle);
-       out->m[0][0] = cp*cy * scale;
-       out->m[0][1] = sr*sp*cy+cr*-sy * scale;
-       out->m[0][2] = cr*sp*cy+-sr*-sy * scale;
+       out->m[0][0] = (cp*cy) * scale;
+       out->m[0][1] = (sr*sp*cy+cr*-sy) * scale;
+       out->m[0][2] = (cr*sp*cy+-sr*-sy) * scale;
        out->m[0][3] = x;
-       out->m[1][0] = cp*sy * scale;
-       out->m[1][1] = sr*sp*sy+cr*cy * scale;
-       out->m[1][2] = cr*sp*sy+-sr*cy * scale;
+       out->m[1][0] = (cp*sy) * scale;
+       out->m[1][1] = (sr*sp*sy+cr*cy) * scale;
+       out->m[1][2] = (cr*sp*sy+-sr*cy) * scale;
        out->m[1][3] = y;
-       out->m[2][0] = -sp * scale;
-       out->m[2][1] = sr*cp * scale;
-       out->m[2][2] = cr*cp * scale;
+       out->m[2][0] = (-sp) * scale;
+       out->m[2][1] = (sr*cp) * scale;
+       out->m[2][2] = (cr*cp) * scale;
        out->m[2][3] = z;
 }