OpenGL2: Really obvious optimization to previous commit.

This commit is contained in:
SmileTheory 2014-05-27 20:52:36 -07:00
parent 318d45cff5
commit 9efaf819dc

View file

@ -598,15 +598,10 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
#ifdef USE_VERT_TANGENT_SPACE #ifdef USE_VERT_TANGENT_SPACE
// calc tangent spaces // calc tangent spaces
{ {
vec3_t *sdirs, *tdirs; for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++)
sdirs = ri.Malloc(sizeof(*sdirs) * surf->numVerts * mdvModel->numFrames);
tdirs = ri.Malloc(sizeof(*tdirs) * surf->numVerts * mdvModel->numFrames);
for (j = 0; j < (surf->numVerts * mdvModel->numFrames); j++)
{ {
VectorSet(sdirs[j], 0.0f, 0.0f, 0.0f); VectorClear(v->tangent);
VectorSet(tdirs[j], 0.0f, 0.0f, 0.0f); VectorClear(v->bitangent);
} }
for(f = 0; f < mdvModel->numFrames; f++) for(f = 0; f < mdvModel->numFrames; f++)
@ -631,25 +626,27 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
R_CalcTexDirs(sdir, tdir, v0, v1, v2, t0, t1, t2); R_CalcTexDirs(sdir, tdir, v0, v1, v2, t0, t1, t2);
VectorAdd(sdir, sdirs[index0], sdirs[index0]); VectorAdd(sdir, surf->verts[index0].tangent, surf->verts[index0].tangent);
VectorAdd(sdir, sdirs[index1], sdirs[index1]); VectorAdd(sdir, surf->verts[index1].tangent, surf->verts[index1].tangent);
VectorAdd(sdir, sdirs[index2], sdirs[index2]); VectorAdd(sdir, surf->verts[index2].tangent, surf->verts[index2].tangent);
VectorAdd(tdir, tdirs[index0], tdirs[index0]); VectorAdd(tdir, surf->verts[index0].bitangent, surf->verts[index0].bitangent);
VectorAdd(tdir, tdirs[index1], tdirs[index1]); VectorAdd(tdir, surf->verts[index1].bitangent, surf->verts[index1].bitangent);
VectorAdd(tdir, tdirs[index2], tdirs[index2]); VectorAdd(tdir, surf->verts[index2].bitangent, surf->verts[index2].bitangent);
} }
} }
for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++)
{ {
VectorNormalize(sdirs[j]); vec3_t sdir, tdir;
VectorNormalize(tdirs[j]);
R_CalcTbnFromNormalAndTexDirs(v->tangent, v->bitangent, v->normal, sdirs[j], tdirs[j]); VectorCopy(v->tangent, sdir);
VectorCopy(v->bitangent, tdir);
VectorNormalize(sdir);
VectorNormalize(tdir);
R_CalcTbnFromNormalAndTexDirs(v->tangent, v->bitangent, v->normal, sdir, tdir);
} }
ri.Free(sdirs);
ri.Free(tdirs);
} }
#endif #endif