Skip to content

Commit

Permalink
Renderers: Replace PATCH_STITCHING preprocessor define with r_patchSt…
Browse files Browse the repository at this point in the history
…itching cvar

Cherrypicked: (JACoders@540edeb)
Pull request: (JACoders#1199)

Co-Authored-By: razor <[email protected]>
  • Loading branch information
JKSunny and Razish committed Apr 15, 2024
1 parent df17bc6 commit db6c144
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
2 changes: 2 additions & 0 deletions codemp/rd-dedicated/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Ghoul2 Insert End

cvar_t *r_aviMotionJpegQuality;
cvar_t *r_screenshotJpegQuality;
cvar_t *r_patchStitching;

/*
** R_GetModeInfo
Expand Down Expand Up @@ -453,6 +454,7 @@ Ghoul2 Insert Start
/*
Ghoul2 Insert End
*/
r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" );
r_modelpoolmegs = ri.Cvar_Get("r_modelpoolmegs", "20", CVAR_ARCHIVE, "" );
if (ri.Sys_LowPhysicalMemory() )
ri.Cvar_Set("r_modelpoolmegs", "0");
Expand Down
2 changes: 0 additions & 2 deletions codemp/rd-dedicated/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,6 @@ CURVE TESSELATION
============================================================
*/

#define PATCH_STITCHING

srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );

Expand Down
12 changes: 6 additions & 6 deletions codemp/rd-vanilla/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,15 +1391,15 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor
}
}

#ifdef PATCH_STITCHING
R_StitchAllPatches(worldData);
#endif
if ( r_patchStitching->integer ) {
R_StitchAllPatches( worldData );
}

R_FixSharedVertexLodError(worldData);

#ifdef PATCH_STITCHING
R_MovePatchSurfacesToHunk(worldData);
#endif
if ( r_patchStitching->integer ) {
R_MovePatchSurfacesToHunk( worldData );
}

ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares );
}
Expand Down
11 changes: 0 additions & 11 deletions codemp/rd-vanilla/tr_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,
// copy the results out to a grid
size = (width * height - 1) * sizeof( drawVert_t ) + sizeof( *grid );

#ifdef PATCH_STITCHING
grid = (struct srfGridMesh_s *)/*Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH, qfalse );
memset(grid, 0, size);

Expand All @@ -315,16 +314,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,

grid->heightLodError = (float *)/*Hunk_Alloc*/ Z_Malloc( height * 4, TAG_GRIDMESH, qfalse );
memcpy( grid->heightLodError, errorTable[1], height * 4 );
#else
grid = Hunk_Alloc( size );
memset(grid, 0, size);

grid->widthLodError = Hunk_Alloc( width * 4 );
memcpy( grid->widthLodError, errorTable[0], width * 4 );

grid->heightLodError = Hunk_Alloc( height * 4 );
memcpy( grid->heightLodError, errorTable[1], height * 4 );
#endif

grid->width = width;
grid->height = height;
Expand Down
4 changes: 4 additions & 0 deletions codemp/rd-vanilla/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ cvar_t *se_language;
cvar_t *r_aviMotionJpegQuality;
cvar_t *r_screenshotJpegQuality;

cvar_t *r_patchStitching;

#if !defined(__APPLE__)
PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate;
#endif
Expand Down Expand Up @@ -1749,6 +1751,8 @@ Ghoul2 Insert End
ri.Cvar_CheckRange( r_aviMotionJpegQuality, 10, 100, qtrue );
ri.Cvar_CheckRange( r_screenshotJpegQuality, 10, 100, qtrue );

r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" );

for ( size_t i = 0; i < numCommands; i++ )
ri.Cmd_AddCommand( commands[i].cmd, commands[i].func, "" );
}
Expand Down
5 changes: 3 additions & 2 deletions codemp/rd-vanilla/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,9 @@ extern cvar_t *r_noServerGhoul2;
/*
Ghoul2 Insert End
*/

extern cvar_t *r_patchStitching;

//====================================================================

void R_SwapBuffers( int );
Expand Down Expand Up @@ -1608,8 +1611,6 @@ CURVE TESSELATION
============================================================
*/

#define PATCH_STITCHING

srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );

Expand Down

0 comments on commit db6c144

Please sign in to comment.