From 7a3fc4e26fd7388d4193a5aded74670fc9a06055 Mon Sep 17 00:00:00 2001 From: JKSunny <60109631+JKSunny@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:18:17 +0200 Subject: [PATCH] Renderers: Replace PATCH_STITCHING preprocessor define with r_patchStitching cvar Cherrypicked: (https://github.com/JACoders/OpenJK/commit/540edeb67fd65cd08642fe4d324e3e49101755a4) Pull request: (https://github.com/JACoders/OpenJK/pull/1199) Co-Authored-By: razor <844370+razish@users.noreply.github.com> --- codemp/rd-dedicated/tr_init.cpp | 2 ++ codemp/rd-dedicated/tr_local.h | 2 -- codemp/rd-vanilla/tr_bsp.cpp | 12 ++++++------ codemp/rd-vanilla/tr_curve.cpp | 11 ----------- codemp/rd-vanilla/tr_init.cpp | 4 ++++ codemp/rd-vanilla/tr_local.h | 5 +++-- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/codemp/rd-dedicated/tr_init.cpp b/codemp/rd-dedicated/tr_init.cpp index 984b94d9e3..82304484c3 100644 --- a/codemp/rd-dedicated/tr_init.cpp +++ b/codemp/rd-dedicated/tr_init.cpp @@ -211,6 +211,7 @@ Ghoul2 Insert End cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_patchStitching; /* ** R_GetModeInfo @@ -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"); diff --git a/codemp/rd-dedicated/tr_local.h b/codemp/rd-dedicated/tr_local.h index 04c2ad723d..86673951d3 100644 --- a/codemp/rd-dedicated/tr_local.h +++ b/codemp/rd-dedicated/tr_local.h @@ -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] ); diff --git a/codemp/rd-vanilla/tr_bsp.cpp b/codemp/rd-vanilla/tr_bsp.cpp index feefe0e348..1596ae53dd 100644 --- a/codemp/rd-vanilla/tr_bsp.cpp +++ b/codemp/rd-vanilla/tr_bsp.cpp @@ -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 ); } diff --git a/codemp/rd-vanilla/tr_curve.cpp b/codemp/rd-vanilla/tr_curve.cpp index bc67911d0d..e3d75834f1 100644 --- a/codemp/rd-vanilla/tr_curve.cpp +++ b/codemp/rd-vanilla/tr_curve.cpp @@ -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); @@ -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; diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 37057891aa..c93302d9a8 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -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 @@ -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, "" ); } diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 89e814f979..b817b45a10 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -1284,6 +1284,9 @@ extern cvar_t *r_noServerGhoul2; /* Ghoul2 Insert End */ + +extern cvar_t *r_patchStitching; + //==================================================================== void R_SwapBuffers( int ); @@ -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] );