aboutsummaryrefslogtreecommitdiffstats
path: root/code/renderer/tr_surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/renderer/tr_surface.c')
-rw-r--r--code/renderer/tr_surface.c108
1 files changed, 103 insertions, 5 deletions
diff --git a/code/renderer/tr_surface.c b/code/renderer/tr_surface.c
index 66d5b93..b5cb0c0 100644
--- a/code/renderer/tr_surface.c
+++ b/code/renderer/tr_surface.c
@@ -610,7 +610,8 @@ static void VectorArrayNormalize(vec4_t *normals, unsigned int count)
/*
** LerpMeshVertexes
*/
-static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
+#if idppc_altivec
+static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp)
{
short *oldXyz, *newXyz, *oldNormals, *newNormals;
float *outXyz, *outNormal;
@@ -633,7 +634,6 @@ static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
numVerts = surf->numVerts;
if ( backlerp == 0 ) {
-#if idppc_altivec
vector signed short newNormalsVec0;
vector signed short newNormalsVec1;
vector signed int newNormalsIntVec;
@@ -687,8 +687,80 @@ static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
vec_ste(newNormalsFloatVec,4,outXyz);
vec_ste(newNormalsFloatVec,8,outXyz);
}
-
-#else
+ } else {
+ //
+ // interpolate and copy the vertex and normal
+ //
+ oldXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
+ + (backEnd.currentEntity->e.oldframe * surf->numVerts * 4);
+ oldNormals = oldXyz + 3;
+
+ oldXyzScale = MD3_XYZ_SCALE * backlerp;
+ oldNormalScale = backlerp;
+
+ for (vertNum=0 ; vertNum < numVerts ; vertNum++,
+ oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4,
+ outXyz += 4, outNormal += 4)
+ {
+ vec3_t uncompressedOldNormal, uncompressedNewNormal;
+
+ // interpolate the xyz
+ outXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale;
+ outXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale;
+ outXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale;
+
+ // FIXME: interpolate lat/long instead?
+ lat = ( newNormals[0] >> 8 ) & 0xff;
+ lng = ( newNormals[0] & 0xff );
+ lat *= 4;
+ lng *= 4;
+ uncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
+ uncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
+ uncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
+
+ lat = ( oldNormals[0] >> 8 ) & 0xff;
+ lng = ( oldNormals[0] & 0xff );
+ lat *= 4;
+ lng *= 4;
+
+ uncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
+ uncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
+ uncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
+
+ outNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale;
+ outNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale;
+ outNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale;
+
+// VectorNormalize (outNormal);
+ }
+ VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts);
+ }
+}
+#endif
+
+static void LerpMeshVertexes_scalar(md3Surface_t *surf, float backlerp)
+{
+ short *oldXyz, *newXyz, *oldNormals, *newNormals;
+ float *outXyz, *outNormal;
+ float oldXyzScale, newXyzScale;
+ float oldNormalScale, newNormalScale;
+ int vertNum;
+ unsigned lat, lng;
+ int numVerts;
+
+ outXyz = tess.xyz[tess.numVertexes];
+ outNormal = tess.normal[tess.numVertexes];
+
+ newXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
+ + (backEnd.currentEntity->e.frame * surf->numVerts * 4);
+ newNormals = newXyz + 3;
+
+ newXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp);
+ newNormalScale = 1.0 - backlerp;
+
+ numVerts = surf->numVerts;
+
+ if ( backlerp == 0 ) {
//
// just copy the vertexes
//
@@ -714,7 +786,6 @@ static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
}
-#endif
} else {
//
// interpolate and copy the vertex and normal
@@ -765,6 +836,33 @@ static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
}
}
+static void LerpMeshVertexes(md3Surface_t *surf, float backlerp)
+{
+ #if idppc_altivec
+
+ // !!! FIXME: figure out what's broken and remove this.
+ #ifndef NDEBUG
+ static int already_complained = 0;
+ if (!already_complained)
+ {
+ already_complained = 1;
+ Com_Printf("WARNING! FIXME! Altivec mesh lerping broken in debug builds!\n");
+ }
+ #else
+ extern cvar_t *com_altivec;
+ if (com_altivec->integer) {
+ // must be in a seperate function or G3 systems will crash.
+ LerpMeshVertexes_altivec( surf, backlerp );
+ return;
+ }
+ #endif
+
+ #endif // idppc_altivec
+
+ LerpMeshVertexes_scalar( surf, backlerp );
+}
+
+
/*
=============
RB_SurfaceMesh