mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
OpenGL2: Really obvious optimization to previous commit.
This commit is contained in:
parent
318d45cff5
commit
9efaf819dc
1 changed files with 18 additions and 21 deletions
|
@ -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++)
|
||||||
|
@ -630,26 +625,28 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
||||||
t2 = surf->st[tri[2]].st;
|
t2 = surf->st[tri[2]].st;
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue