@@ -1051,66 +1051,69 @@ static void Tess_SurfaceMD5( md5Surface_t *srf )
10511051 tessIndex[ 2 ] = tess.numVertexes + surfaceTriangle->indexes [ 2 ];
10521052 }
10531053
1054- shaderVertex_t *tessVertex = tess.verts + tess.numVertexes ;
1055- shaderVertex_t *lastVertex = tessVertex + srf->numVerts ;
1054+ shaderVertex_t *modelTessVertex = tess.verts + tess.numVertexes ;
10561055
10571056 // Deform the vertices by the lerped bones.
10581057 if ( tess.skipTangents )
10591058 {
1060- for ( ; tessVertex < lastVertex; tessVertex++,
1061- surfaceVertex++ )
1059+ for ( size_t i = 0 ; i < srf->numVerts ; i++ )
10621060 {
1063- vec3_t position = {};
1061+ shaderVertex_t *tessVertex = modelTessVertex + i;
1062+ md5Vertex_t *vertex = surfaceVertex + i;
10641063
1065- float *boneWeight = surfaceVertex->boneWeights ;
1066- float *lastWeight = boneWeight + surfaceVertex->numWeights ;
1067- uint32_t *boneIndex = surfaceVertex->boneIndexes ;
1068- vec4_t *surfacePosition = &surfaceVertex->position ;
1064+ vec4_t *vertexPosition = &vertex->position ;
1065+
1066+ float *boneWeight = vertex->boneWeights ;
1067+ float *lastWeight = boneWeight + vertex->numWeights ;
1068+ uint32_t *boneIndex = vertex->boneIndexes ;
1069+
1070+ vec3_t position = {};
10691071
1070- for ( ; boneWeight < lastWeight; boneWeight++,
1071- boneIndex++ )
1072+ for ( ; boneWeight < lastWeight; boneWeight++, boneIndex++ )
10721073 {
10731074 vec3_t tmp;
10741075
1075- TransformPoint ( &bones[ *boneIndex ], *surfacePosition , tmp );
1076+ TransformPoint ( &bones[ *boneIndex ], *vertexPosition , tmp );
10761077 VectorMA ( position, *boneWeight, tmp, position );
10771078 }
10781079
10791080 VectorCopy ( position, tessVertex->xyz );
10801081
1081- Vector2Copy ( surfaceVertex ->texCoords , tessVertex->texCoords );
1082+ Vector2Copy ( vertex ->texCoords , tessVertex->texCoords );
10821083 }
10831084 }
10841085 else
10851086 {
1086- for ( ; tessVertex < lastVertex; tessVertex++,
1087- surfaceVertex++ )
1087+ for ( size_t i = 0 ; i < srf->numVerts ; i++ )
10881088 {
1089- vec3_t tangent = {}, binormal = {}, normal = {}, position = {};
1089+ shaderVertex_t *tessVertex = modelTessVertex + i;
1090+ md5Vertex_t *vertex = surfaceVertex + i;
1091+
1092+ vec4_t *vertexPosition = &vertex->position ;
1093+ vec4_t *vertexNormal = &vertex->normal ;
1094+ vec4_t *vertexTangent = &vertex->tangent ;
1095+ vec4_t *vertexBinormal = &vertex->binormal ;
10901096
1091- float *boneWeight = surfaceVertex->boneWeights ;
1092- float *lastWeight = boneWeight + surfaceVertex->numWeights ;
1093- uint32_t *boneIndex = surfaceVertex->boneIndexes ;
1094- vec4_t *surfacePosition = &surfaceVertex->position ;
1095- vec4_t *surfaceNormal = &surfaceVertex->normal ;
1096- vec4_t *surfaceTangent = &surfaceVertex->tangent ;
1097- vec4_t *surfaceBinormal = &surfaceVertex->binormal ;
1097+ float *boneWeight = vertex->boneWeights ;
1098+ float *lastWeight = boneWeight + vertex->numWeights ;
1099+ uint32_t *boneIndex = vertex->boneIndexes ;
1100+
1101+ vec3_t tangent = {}, binormal = {}, normal = {}, position = {};
10981102
1099- for ( ; boneWeight < lastWeight; boneWeight++,
1100- boneIndex++ )
1103+ for ( ; boneWeight < lastWeight; boneWeight++, boneIndex++ )
11011104 {
11021105 vec3_t tmp;
11031106
1104- TransformPoint ( &bones[ *boneIndex ], *surfacePosition , tmp );
1107+ TransformPoint ( &bones[ *boneIndex ], *vertexPosition , tmp );
11051108 VectorMA ( position, *boneWeight, tmp, position );
11061109
1107- TransformNormalVector ( &bones[ *boneIndex ], *surfaceNormal , tmp );
1110+ TransformNormalVector ( &bones[ *boneIndex ], *vertexNormal , tmp );
11081111 VectorMA ( normal, *boneWeight, tmp, normal );
11091112
1110- TransformNormalVector ( &bones[ *boneIndex ], *surfaceTangent , tmp );
1113+ TransformNormalVector ( &bones[ *boneIndex ], *vertexTangent , tmp );
11111114 VectorMA ( tangent, *boneWeight, tmp, tangent );
11121115
1113- TransformNormalVector ( &bones[ *boneIndex ], *surfaceBinormal , tmp );
1116+ TransformNormalVector ( &bones[ *boneIndex ], *vertexBinormal , tmp );
11141117 VectorMA ( binormal, *boneWeight, tmp, binormal );
11151118 }
11161119
@@ -1121,7 +1124,7 @@ static void Tess_SurfaceMD5( md5Surface_t *srf )
11211124
11221125 R_TBNtoQtangentsFast ( tangent, binormal, normal, tessVertex->qtangents );
11231126
1124- Vector2Copy ( surfaceVertex ->texCoords , tessVertex->texCoords );
1127+ Vector2Copy ( vertex ->texCoords , tessVertex->texCoords );
11251128 }
11261129 }
11271130
0 commit comments