mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-29 06:07:57 +03:00
Move RB_StaticMesh to tr_model.cpp for info world tris
This commit is contained in:
parent
548a3efe5a
commit
78fa90c59b
3 changed files with 167 additions and 158 deletions
|
@ -2195,6 +2195,8 @@ void R_DebugSkeleton(void);
|
||||||
extern int g_nStaticSurfaces;
|
extern int g_nStaticSurfaces;
|
||||||
extern qboolean g_bInfostaticmodels;
|
extern qboolean g_bInfostaticmodels;
|
||||||
extern qboolean g_bInfoworldtris;
|
extern qboolean g_bInfoworldtris;
|
||||||
|
extern int entityNumIndexes[];
|
||||||
|
extern int staticModelNumIndexes[];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================
|
=============================================================
|
||||||
|
|
|
@ -1168,6 +1168,7 @@ void RB_SkelMesh( skelSurfaceGame_t *sf ) {
|
||||||
tess.indexes[baseIndex + i] = baseVertex + triangles[i];
|
tess.indexes[baseIndex + i] = baseVertex + triangles[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entityNumIndexes[backEnd.currentEntity - backEnd.refdef.entities] += indexes;
|
||||||
tess.numIndexes += indexes;
|
tess.numIndexes += indexes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1199,6 +1200,8 @@ void RB_SkelMesh( skelSurfaceGame_t *sf ) {
|
||||||
tess.indexes[baseIndex + i + 1] = baseVertex + collapse[triangles[i + 1]];
|
tess.indexes[baseIndex + i + 1] = baseVertex + collapse[triangles[i + 1]];
|
||||||
tess.indexes[baseIndex + i + 2] = baseVertex + collapse[triangles[i + 2]];
|
tess.indexes[baseIndex + i + 2] = baseVertex + collapse[triangles[i + 2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entityNumIndexes[backEnd.currentEntity - backEnd.refdef.entities] += indexes;
|
||||||
tess.numIndexes += i;
|
tess.numIndexes += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,6 +1471,168 @@ void RB_SkelMesh( skelSurfaceGame_t *sf ) {
|
||||||
//tess.numVertexes += sf->numVerts;
|
//tess.numVertexes += sf->numVerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
RB_StaticMesh
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
void RB_StaticMesh(staticSurface_t *staticSurf)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
dtiki_t *tiki;
|
||||||
|
skelSurfaceGame_t *surf;
|
||||||
|
int meshNum;
|
||||||
|
skelHeaderGame_t *skelmodel;
|
||||||
|
int render_count;
|
||||||
|
skelIndex_t *collapse_map;
|
||||||
|
skelIndex_t *triangles;
|
||||||
|
int indexes;
|
||||||
|
int baseIndex, baseVertex;
|
||||||
|
short collapse[1000];
|
||||||
|
|
||||||
|
if (!r_drawstaticmodelpoly->integer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(backEnd.currentStaticModel);
|
||||||
|
tiki = backEnd.currentStaticModel->tiki;
|
||||||
|
surf = staticSurf->surface;
|
||||||
|
|
||||||
|
assert(surf->pStaticXyz);
|
||||||
|
|
||||||
|
meshNum = staticSurf->meshNum;
|
||||||
|
skelmodel = TIKI_GetSkel(tiki->mesh[meshNum]);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Process LOD
|
||||||
|
//
|
||||||
|
if (skelmodel->pLOD && r_staticlod->integer) {
|
||||||
|
float lod_val;
|
||||||
|
|
||||||
|
lod_val = backEnd.currentStaticModel->lodpercentage[0];
|
||||||
|
|
||||||
|
if (surf->numVerts > 3) {
|
||||||
|
skelIndex_t *collapseIndex;
|
||||||
|
int mid, low, high;
|
||||||
|
int lod_cutoff;
|
||||||
|
|
||||||
|
if (lod_tool->integer && !strcmp(backEnd.currentStaticModel->tiki->a->name, lod_tikiname->string)
|
||||||
|
&& meshNum == lod_mesh->integer) {
|
||||||
|
lod_cutoff = GetToolLodCutoff(skelmodel, backEnd.currentStaticModel->lodpercentage[0]);
|
||||||
|
} else {
|
||||||
|
lod_cutoff = GetLodCutoff(skelmodel, backEnd.currentStaticModel->lodpercentage[0], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
collapseIndex = surf->pCollapseIndex;
|
||||||
|
if (collapseIndex[2] < lod_cutoff) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
low = mid = 3;
|
||||||
|
high = surf->numVerts;
|
||||||
|
while (high >= low) {
|
||||||
|
mid = (low + high) >> 1;
|
||||||
|
if (collapseIndex[mid] < lod_cutoff) {
|
||||||
|
high = mid - 1;
|
||||||
|
if (collapseIndex[mid - 1] >= lod_cutoff) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mid++;
|
||||||
|
low = mid;
|
||||||
|
if (high == mid || collapseIndex[mid] < lod_cutoff) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render_count = mid;
|
||||||
|
} else {
|
||||||
|
render_count = surf->numVerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!render_count) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
render_count = surf->numVerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
indexes = surf->numTriangles * 3;
|
||||||
|
RB_CHECKOVERFLOW(render_count, surf->numTriangles);
|
||||||
|
|
||||||
|
collapse_map = surf->pCollapse;
|
||||||
|
triangles = surf->pTriangles;
|
||||||
|
baseIndex = tess.numIndexes;
|
||||||
|
baseVertex = tess.numVertexes;
|
||||||
|
tess.numVertexes += render_count;
|
||||||
|
|
||||||
|
if (render_count == surf->numVerts) {
|
||||||
|
for (j = 0; j < indexes; j++) {
|
||||||
|
tess.indexes[baseIndex + j] = baseVertex + triangles[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
staticModelNumIndexes[backEnd.currentStaticModel - backEnd.refdef.staticModels] += indexes;
|
||||||
|
tess.numIndexes += indexes;
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < render_count; i++) {
|
||||||
|
collapse[i] = i;
|
||||||
|
}
|
||||||
|
for (i = render_count; i < surf->numVerts; i++) {
|
||||||
|
collapse[i] = collapse[collapse_map[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < indexes; j += 3) {
|
||||||
|
if (collapse[triangles[j]] == collapse[triangles[j + 1]]
|
||||||
|
|| collapse[triangles[j + 1]] == collapse[triangles[j + 2]]
|
||||||
|
|| collapse[triangles[j + 2]] == collapse[triangles[j]]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tess.indexes[baseIndex + j] = baseVertex + collapse[triangles[j]];
|
||||||
|
tess.indexes[baseIndex + j + 1] = baseVertex + collapse[triangles[j + 1]];
|
||||||
|
tess.indexes[baseIndex + j + 2] = baseVertex + collapse[triangles[j + 2]];
|
||||||
|
}
|
||||||
|
|
||||||
|
staticModelNumIndexes[backEnd.currentStaticModel - backEnd.refdef.staticModels] += j;
|
||||||
|
tess.numIndexes += j;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < render_count; j++) {
|
||||||
|
Vector4Copy(surf->pStaticXyz[j], tess.xyz[baseVertex + j]);
|
||||||
|
Vector4Copy(surf->pStaticNormal[j], tess.normal[baseVertex + j]);
|
||||||
|
tess.texCoords[baseVertex + j][0][0] = surf->pStaticTexCoords[j][0][0];
|
||||||
|
tess.texCoords[baseVertex + j][0][1] = surf->pStaticTexCoords[j][0][1];
|
||||||
|
tess.texCoords[baseVertex + j][1][0] = surf->pStaticTexCoords[j][1][0];
|
||||||
|
tess.texCoords[baseVertex + j][1][1] = surf->pStaticTexCoords[j][1][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backEndData[backEnd.smpFrame]->staticModelData) {
|
||||||
|
const size_t offset =
|
||||||
|
backEnd.currentStaticModel->firstVertexData + staticSurf->ofsStaticData * sizeof(color4ub_t);
|
||||||
|
assert(offset < tr.world->numStaticModelData * sizeof(color4ub_t));
|
||||||
|
assert(offset + render_count * sizeof(color4ub_t) <= tr.world->numStaticModelData * sizeof(color4ub_t));
|
||||||
|
|
||||||
|
const color4ub_t *in = (const color4ub_t *)&backEndData[backEnd.smpFrame]->staticModelData[offset];
|
||||||
|
|
||||||
|
for (i = 0; i < render_count; i++) {
|
||||||
|
tess.vertexColors[baseVertex + i][0] = in[i][0];
|
||||||
|
tess.vertexColors[baseVertex + i][1] = in[i][1];
|
||||||
|
tess.vertexColors[baseVertex + i][2] = in[i][2];
|
||||||
|
tess.vertexColors[baseVertex + i][3] = in[i][3];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < render_count; i++) {
|
||||||
|
tess.vertexColors[baseVertex + i][0] = 0xFF;
|
||||||
|
tess.vertexColors[baseVertex + i][1] = 0xFF;
|
||||||
|
tess.vertexColors[baseVertex + i][2] = 0xFF;
|
||||||
|
tess.vertexColors[baseVertex + i][3] = 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tess.vertexColorValid = qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_InfoWorldTris_f
|
R_InfoWorldTris_f
|
||||||
|
|
|
@ -503,164 +503,6 @@ void R_InfoStaticModels_f()
|
||||||
g_bInfostaticmodels = qtrue;
|
g_bInfostaticmodels = qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
RB_StaticMesh
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
void RB_StaticMesh(staticSurface_t *staticSurf)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
dtiki_t *tiki;
|
|
||||||
skelSurfaceGame_t *surf;
|
|
||||||
int meshNum;
|
|
||||||
skelHeaderGame_t *skelmodel;
|
|
||||||
int render_count;
|
|
||||||
skelIndex_t *collapse_map;
|
|
||||||
skelIndex_t *triangles;
|
|
||||||
int indexes;
|
|
||||||
int baseIndex, baseVertex;
|
|
||||||
short collapse[1000];
|
|
||||||
|
|
||||||
if (!r_drawstaticmodelpoly->integer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(backEnd.currentStaticModel);
|
|
||||||
tiki = backEnd.currentStaticModel->tiki;
|
|
||||||
surf = staticSurf->surface;
|
|
||||||
|
|
||||||
assert(surf->pStaticXyz);
|
|
||||||
|
|
||||||
meshNum = staticSurf->meshNum;
|
|
||||||
skelmodel = TIKI_GetSkel(tiki->mesh[meshNum]);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Process LOD
|
|
||||||
//
|
|
||||||
if (skelmodel->pLOD && r_staticlod->integer) {
|
|
||||||
float lod_val;
|
|
||||||
|
|
||||||
lod_val = backEnd.currentStaticModel->lodpercentage[0];
|
|
||||||
|
|
||||||
if (surf->numVerts > 3) {
|
|
||||||
skelIndex_t *collapseIndex;
|
|
||||||
int mid, low, high;
|
|
||||||
int lod_cutoff;
|
|
||||||
|
|
||||||
if (lod_tool->integer && !strcmp(backEnd.currentStaticModel->tiki->a->name, lod_tikiname->string)
|
|
||||||
&& meshNum == lod_mesh->integer) {
|
|
||||||
lod_cutoff = GetToolLodCutoff(skelmodel, backEnd.currentStaticModel->lodpercentage[0]);
|
|
||||||
} else {
|
|
||||||
lod_cutoff = GetLodCutoff(skelmodel, backEnd.currentStaticModel->lodpercentage[0], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
collapseIndex = surf->pCollapseIndex;
|
|
||||||
if (collapseIndex[2] < lod_cutoff) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
low = mid = 3;
|
|
||||||
high = surf->numVerts;
|
|
||||||
while (high >= low) {
|
|
||||||
mid = (low + high) >> 1;
|
|
||||||
if (collapseIndex[mid] < lod_cutoff) {
|
|
||||||
high = mid - 1;
|
|
||||||
if (collapseIndex[mid - 1] >= lod_cutoff) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mid++;
|
|
||||||
low = mid;
|
|
||||||
if (high == mid || collapseIndex[mid] < lod_cutoff) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render_count = mid;
|
|
||||||
} else {
|
|
||||||
render_count = surf->numVerts;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!render_count) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
render_count = surf->numVerts;
|
|
||||||
}
|
|
||||||
|
|
||||||
indexes = surf->numTriangles * 3;
|
|
||||||
RB_CHECKOVERFLOW(render_count, surf->numTriangles);
|
|
||||||
|
|
||||||
collapse_map = surf->pCollapse;
|
|
||||||
triangles = surf->pTriangles;
|
|
||||||
baseIndex = tess.numIndexes;
|
|
||||||
baseVertex = tess.numVertexes;
|
|
||||||
tess.numVertexes += render_count;
|
|
||||||
|
|
||||||
if (render_count == surf->numVerts) {
|
|
||||||
for (j = 0; j < indexes; j++) {
|
|
||||||
tess.indexes[baseIndex + j] = baseVertex + triangles[j];
|
|
||||||
}
|
|
||||||
tess.numIndexes += indexes;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < render_count; i++) {
|
|
||||||
collapse[i] = i;
|
|
||||||
}
|
|
||||||
for (i = render_count; i < surf->numVerts; i++) {
|
|
||||||
collapse[i] = collapse[collapse_map[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < indexes; j += 3) {
|
|
||||||
if (collapse[triangles[j]] == collapse[triangles[j + 1]]
|
|
||||||
|| collapse[triangles[j + 1]] == collapse[triangles[j + 2]]
|
|
||||||
|| collapse[triangles[j + 2]] == collapse[triangles[j]]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tess.indexes[baseIndex + j] = baseVertex + collapse[triangles[j]];
|
|
||||||
tess.indexes[baseIndex + j + 1] = baseVertex + collapse[triangles[j + 1]];
|
|
||||||
tess.indexes[baseIndex + j + 2] = baseVertex + collapse[triangles[j + 2]];
|
|
||||||
}
|
|
||||||
tess.numIndexes += j;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < render_count; j++) {
|
|
||||||
Vector4Copy(surf->pStaticXyz[j], tess.xyz[baseVertex + j]);
|
|
||||||
Vector4Copy(surf->pStaticNormal[j], tess.normal[baseVertex + j]);
|
|
||||||
tess.texCoords[baseVertex + j][0][0] = surf->pStaticTexCoords[j][0][0];
|
|
||||||
tess.texCoords[baseVertex + j][0][1] = surf->pStaticTexCoords[j][0][1];
|
|
||||||
tess.texCoords[baseVertex + j][1][0] = surf->pStaticTexCoords[j][1][0];
|
|
||||||
tess.texCoords[baseVertex + j][1][1] = surf->pStaticTexCoords[j][1][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backEndData[backEnd.smpFrame]->staticModelData) {
|
|
||||||
const size_t offset =
|
|
||||||
backEnd.currentStaticModel->firstVertexData + staticSurf->ofsStaticData * sizeof(color4ub_t);
|
|
||||||
assert(offset < tr.world->numStaticModelData * sizeof(color4ub_t));
|
|
||||||
assert(offset + render_count * sizeof(color4ub_t) <= tr.world->numStaticModelData * sizeof(color4ub_t));
|
|
||||||
|
|
||||||
const color4ub_t *in = (const color4ub_t *)&backEndData[backEnd.smpFrame]->staticModelData[offset];
|
|
||||||
|
|
||||||
for (i = 0; i < render_count; i++) {
|
|
||||||
tess.vertexColors[baseVertex + i][0] = in[i][0];
|
|
||||||
tess.vertexColors[baseVertex + i][1] = in[i][1];
|
|
||||||
tess.vertexColors[baseVertex + i][2] = in[i][2];
|
|
||||||
tess.vertexColors[baseVertex + i][3] = in[i][3];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < render_count; i++) {
|
|
||||||
tess.vertexColors[baseVertex + i][0] = 0xFF;
|
|
||||||
tess.vertexColors[baseVertex + i][1] = 0xFF;
|
|
||||||
tess.vertexColors[baseVertex + i][2] = 0xFF;
|
|
||||||
tess.vertexColors[baseVertex + i][3] = 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tess.vertexColorValid = qtrue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
R_PrintInfoStaticModels
|
R_PrintInfoStaticModels
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue