Implement RB_SurfaceMarkFragment (#47)

Looks good
Btw it won't be possible to make a common function, because like others `RB_Surface*`, both functions use a different struct (even if some of the fields have the same name between structures)
This commit is contained in:
pryon 2023-07-01 20:51:14 +02:00 committed by GitHub
parent c83bbd6a58
commit ca468b9407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View file

@ -2087,6 +2087,7 @@ void R_MarkTerrainPatch(cTerraPatchUnpacked_t* pPatch);
void R_AddTerrainSurfaces();
void R_InitTerrain();
void R_TerrainPrepareFrame();
qboolean R_TerrainHeightForPoly(cTerraPatchUnpacked_t* pPatch, polyVert_t* pVerts, int nVerts);
/*
=============================================================

View file

@ -215,8 +215,45 @@ void RB_SurfacePolychain( srfPoly_t *p ) {
tess.numVertexes = numv;
}
/*
=============
RB_SurfaceMarkFragment
=============
*/
void RB_SurfaceMarkFragment(srfMarkFragment_t* p) {
// FIXME: unimplemented
int i;
int numv;
RB_CHECKOVERFLOW( p->numVerts, 3*(p->numVerts - 2) );
if (p->iIndex <= 0 || R_TerrainHeightForPoly(&tr.world->terraPatches[p->iIndex - 1], p->verts, p->numVerts))
{
// FIXME: from here on out, it's mostly the same code as in RB_SurfacePolychain,
// common part could be extracted into an inline func
// fan triangles into the tess array
numv = tess.numVertexes;
for ( i = 0; i < p->numVerts; i++ )
{
VectorCopy( p->verts[i].xyz, tess.xyz[numv] );
tess.texCoords[numv][0][0] = p->verts[i].st[0];
tess.texCoords[numv][0][1] = p->verts[i].st[1];
*(int *)&tess.vertexColors[numv] = *(int *)p->verts[ i ].modulate;
numv++;
}
// generate fan indexes into the tess array
for ( i = 0; i < p->numVerts - 2; i++ ) {
tess.indexes[tess.numIndexes + 0] = tess.numVertexes;
tess.indexes[tess.numIndexes + 1] = tess.numVertexes + i + 1;
tess.indexes[tess.numIndexes + 2] = tess.numVertexes + i + 2;
tess.numIndexes += 3;
}
tess.vertexColorValid = qtrue;
tess.numVertexes = numv;
}
}
/*