From 7e0de354c2b219236ffaeaea35c87114d23ffd44 Mon Sep 17 00:00:00 2001 From: myT <> Date: Sat, 25 Feb 2023 23:01:11 +0100 Subject: [PATCH] added the R_SetPVSCulling extension --- code/client/cl_cgame.cpp | 5 +++++ code/qcommon/cg_public.h | 3 ++- code/renderer/tr_init.cpp | 8 ++++++++ code/renderer/tr_local.h | 2 ++ code/renderer/tr_public.h | 3 +++ code/renderer/tr_world.cpp | 8 +++++++- 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 97acc6a..4046333 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -356,6 +356,7 @@ static qbool CL_CG_GetValue( char* value, int valueSize, const char* key ) { "trap_CNQ3_NDP_StartVideo", CG_EXT_NDP_STARTVIDEO }, { "trap_CNQ3_NDP_StopVideo", CG_EXT_NDP_STOPVIDEO }, { "trap_CNQ3_R_RenderScene", CG_EXT_R_RENDERSCENE }, + { "trap_CNQ3_R_SetPVSCulling", CG_EXT_R_SETPVSCULLING }, // commands { "screenshotnc", 1 }, { "screenshotncJPEG", 1 }, @@ -708,6 +709,10 @@ static intptr_t CL_CgameSystemCalls( intptr_t *args ) re.RenderScene( VMA(1), args[2] ); return 0; + case CG_EXT_R_SETPVSCULLING: + re.SetPVSCulling( (qbool)args[1] ); + return 0; + default: Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] ); } diff --git a/code/qcommon/cg_public.h b/code/qcommon/cg_public.h index 88144f8..089582d 100644 --- a/code/qcommon/cg_public.h +++ b/code/qcommon/cg_public.h @@ -202,7 +202,8 @@ typedef enum { CG_EXT_NDP_READUNTIL, CG_EXT_NDP_STARTVIDEO, CG_EXT_NDP_STOPVIDEO, - CG_EXT_R_RENDERSCENE + CG_EXT_R_RENDERSCENE, + CG_EXT_R_SETPVSCULLING } cgameImport_t; diff --git a/code/renderer/tr_init.cpp b/code/renderer/tr_init.cpp index 82cbbfe..8e9b625 100644 --- a/code/renderer/tr_init.cpp +++ b/code/renderer/tr_init.cpp @@ -683,6 +683,12 @@ static qbool RE_IsDepthClampEnabled() } +static void RE_SetPVSCulling( qbool enable ) +{ + tr.drawEntireMap = !enable; +} + + const refexport_t* GetRefAPI( const refimport_t* rimp ) { static refexport_t re; @@ -736,5 +742,7 @@ const refexport_t* GetRefAPI( const refimport_t* rimp ) re.DepthClamp = RE_IsDepthClampEnabled; + re.SetPVSCulling = RE_SetPVSCulling; + return &re; } diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h index 177c91a..74ebd16 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -936,6 +936,8 @@ typedef struct { float mipFilter[4]; // only used by the GPU generators qbool worldSurface; // is the currently added draw surface a world surface? + + qbool drawEntireMap; } trGlobals_t; extern backEndState_t backEnd; diff --git a/code/renderer/tr_public.h b/code/renderer/tr_public.h index e5422f7..a39525f 100644 --- a/code/renderer/tr_public.h +++ b/code/renderer/tr_public.h @@ -170,6 +170,9 @@ typedef struct { // is depth clamping enabled? qbool (*DepthClamp)(); + + // qfalse will force drawing the entire map + void (*SetPVSCulling)( qbool enable ); } refexport_t; // diff --git a/code/renderer/tr_world.cpp b/code/renderer/tr_world.cpp index 183e890..abae9c8 100644 --- a/code/renderer/tr_world.cpp +++ b/code/renderer/tr_world.cpp @@ -512,6 +512,12 @@ static void R_MarkLeaves() return; } + // when playing a demo on a different map, the area masks might not match + // it's safest to ignore the demo's area mask and mark all nodes as visible + if ( tr.drawEntireMap ) { + tr.refdef.areamaskModified = qtrue; + } + // current viewcluster leaf = R_PointInLeaf( tr.viewParms.pvsOrigin ); cluster = leaf->cluster; @@ -528,7 +534,7 @@ static void R_MarkLeaves() tr.visCount++; tr.viewCluster = cluster; - if ( r_novis->integer || tr.viewCluster == -1 ) { + if ( r_novis->integer || tr.viewCluster == -1 || tr.drawEntireMap ) { for ( i = 0; i < tr.world->numnodes; ++i ) { if (tr.world->nodes[i].contents != CONTENTS_SOLID) { tr.world->nodes[i].visframe = tr.visCount;