@@ -1052,66 +1052,69 @@ static void Tess_SurfaceMD5( md5Surface_t *srf )
10521052 tessIndex[ 2 ] = tess.numVertexes + surfaceTriangle->indexes [ 2 ];
10531053 }
10541054
1055- shaderVertex_t *tessVertex = tess.verts + tess.numVertexes ;
1056- shaderVertex_t *lastVertex = tessVertex + srf->numVerts ;
1055+ shaderVertex_t *modelTessVertex = tess.verts + tess.numVertexes ;
10571056
10581057 // Deform the vertices by the lerped bones.
10591058 if ( tess.skipTangents )
10601059 {
1061- for ( ; tessVertex < lastVertex; tessVertex++,
1062- surfaceVertex++ )
1060+ for ( size_t i = 0 ; i < srf->numVerts ; i++ )
10631061 {
1064- vec3_t position = {};
1062+ shaderVertex_t *tessVertex = modelTessVertex + i;
1063+ md5Vertex_t *vertex = surfaceVertex + i;
10651064
1066- float *boneWeight = surfaceVertex->boneWeights ;
1067- float *lastWeight = boneWeight + surfaceVertex->numWeights ;
1068- uint32_t *boneIndex = surfaceVertex->boneIndexes ;
1069- vec4_t *surfacePosition = &surfaceVertex->position ;
1065+ vec4_t *vertexPosition = &vertex->position ;
1066+
1067+ float *boneWeight = vertex->boneWeights ;
1068+ float *lastWeight = boneWeight + vertex->numWeights ;
1069+ uint32_t *boneIndex = vertex->boneIndexes ;
1070+
1071+ vec3_t position = {};
10701072
1071- for ( ; boneWeight < lastWeight; boneWeight++,
1072- boneIndex++ )
1073+ for ( ; boneWeight < lastWeight; boneWeight++, boneIndex++ )
10731074 {
10741075 vec3_t tmp;
10751076
1076- TransformPoint ( &bones[ *boneIndex ], *surfacePosition , tmp );
1077+ TransformPoint ( &bones[ *boneIndex ], *vertexPosition , tmp );
10771078 VectorMA ( position, *boneWeight, tmp, position );
10781079 }
10791080
10801081 VectorCopy ( position, tessVertex->xyz );
10811082
1082- Vector2Copy ( surfaceVertex ->texCoords , tessVertex->texCoords );
1083+ Vector2Copy ( vertex ->texCoords , tessVertex->texCoords );
10831084 }
10841085 }
10851086 else
10861087 {
1087- for ( ; tessVertex < lastVertex; tessVertex++,
1088- surfaceVertex++ )
1088+ for ( size_t i = 0 ; i < srf->numVerts ; i++ )
10891089 {
1090- vec3_t tangent = {}, binormal = {}, normal = {}, position = {};
1090+ shaderVertex_t *tessVertex = modelTessVertex + i;
1091+ md5Vertex_t *vertex = surfaceVertex + i;
1092+
1093+ vec4_t *vertexPosition = &vertex->position ;
1094+ vec4_t *vertexNormal = &vertex->normal ;
1095+ vec4_t *vertexTangent = &vertex->tangent ;
1096+ vec4_t *vertexBinormal = &vertex->binormal ;
10911097
1092- float *boneWeight = surfaceVertex->boneWeights ;
1093- float *lastWeight = boneWeight + surfaceVertex->numWeights ;
1094- uint32_t *boneIndex = surfaceVertex->boneIndexes ;
1095- vec4_t *surfacePosition = &surfaceVertex->position ;
1096- vec4_t *surfaceNormal = &surfaceVertex->normal ;
1097- vec4_t *surfaceTangent = &surfaceVertex->tangent ;
1098- vec4_t *surfaceBinormal = &surfaceVertex->binormal ;
1098+ float *boneWeight = vertex->boneWeights ;
1099+ float *lastWeight = boneWeight + vertex->numWeights ;
1100+ uint32_t *boneIndex = vertex->boneIndexes ;
1101+
1102+ vec3_t tangent = {}, binormal = {}, normal = {}, position = {};
10991103
1100- for ( ; boneWeight < lastWeight; boneWeight++,
1101- boneIndex++ )
1104+ for ( ; boneWeight < lastWeight; boneWeight++, boneIndex++ )
11021105 {
11031106 vec3_t tmp;
11041107
1105- TransformPoint ( &bones[ *boneIndex ], *surfacePosition , tmp );
1108+ TransformPoint ( &bones[ *boneIndex ], *vertexPosition , tmp );
11061109 VectorMA ( position, *boneWeight, tmp, position );
11071110
1108- TransformNormalVector ( &bones[ *boneIndex ], *surfaceNormal , tmp );
1111+ TransformNormalVector ( &bones[ *boneIndex ], *vertexNormal , tmp );
11091112 VectorMA ( normal, *boneWeight, tmp, normal );
11101113
1111- TransformNormalVector ( &bones[ *boneIndex ], *surfaceTangent , tmp );
1114+ TransformNormalVector ( &bones[ *boneIndex ], *vertexTangent , tmp );
11121115 VectorMA ( tangent, *boneWeight, tmp, tangent );
11131116
1114- TransformNormalVector ( &bones[ *boneIndex ], *surfaceBinormal , tmp );
1117+ TransformNormalVector ( &bones[ *boneIndex ], *vertexBinormal , tmp );
11151118 VectorMA ( binormal, *boneWeight, tmp, binormal );
11161119 }
11171120
@@ -1122,7 +1125,7 @@ static void Tess_SurfaceMD5( md5Surface_t *srf )
11221125
11231126 R_TBNtoQtangentsFast ( tangent, binormal, normal, tessVertex->qtangents );
11241127
1125- Vector2Copy ( surfaceVertex ->texCoords , tessVertex->texCoords );
1128+ Vector2Copy ( vertex ->texCoords , tessVertex->texCoords );
11261129 }
11271130 }
11281131
0 commit comments