no longer tessellating in RB_SurfaceSizeGrid

This commit is contained in:
myT 2023-11-12 01:02:12 +01:00
parent e3f0afc117
commit 457ca2ab65
2 changed files with 24 additions and 9 deletions

View file

@ -524,6 +524,8 @@ struct drawSurf_t {
void R_TessellateSurface( const surfaceType_t* surfType ); void R_TessellateSurface( const surfaceType_t* surfType );
void R_ComputeTessellatedSize( int* numVertexes, int* numIndexes, const surfaceType_t* surfType ); void R_ComputeTessellatedSize( int* numVertexes, int* numIndexes, const surfaceType_t* surfType );
// R_ComputeTessellatedSize is unused for now but might be of use a bit later
// we can use it to compute the required size of the static geometry buffers in the GRP
struct litSurf_t { struct litSurf_t {

View file

@ -868,15 +868,28 @@ static void RB_SurfaceSizeFace( int* numVertexes, int* numIndexes, const srfSurf
static void RB_SurfaceSizeGrid( int* numVertexes, int* numIndexes, const srfGridMesh_t* surf ) static void RB_SurfaceSizeGrid( int* numVertexes, int* numIndexes, const srfGridMesh_t* surf )
{ {
// @TODO: estimate properly... srfGridMesh_t* const cv = (srfGridMesh_t*)surf;
// @TODO: this can overflow and call the old EndSurface/BeginSurface pair...
const int prevNumVertexes = tess.numVertexes; const float lodError = LodErrorForVolume( cv->lodOrigin, cv->lodRadius );
const int prevNumIndexes = tess.numIndexes;
RB_SurfaceGrid((srfGridMesh_t*)surf); int lodWidth = 1;
*numVertexes = tess.numVertexes - prevNumVertexes; for ( int i = 1; i < cv->width - 1; i++ ) {
*numIndexes = tess.numIndexes - prevNumIndexes; if ( cv->widthLodError[i] <= lodError ) {
tess.numVertexes = prevNumVertexes; lodWidth++;
tess.numIndexes = prevNumIndexes; }
}
lodWidth++;
int lodHeight = 1;
for ( int i = 1; i < cv->height - 1; i++ ) {
if ( cv->heightLodError[i] <= lodError ) {
lodHeight++;
}
}
lodHeight++;
*numVertexes = lodWidth * lodHeight;
*numIndexes = max( lodWidth - 1, 0 ) * max( lodHeight - 1, 0 ) * 6;
} }