From 03ec537178bd20a99033d1b83a72effe46ddffbb Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 2 Apr 2023 01:10:14 -0700 Subject: [PATCH] Add debugrender_portal command - Fills portals with red - Draws portals over planes and masked --- src/r_debug.cpp | 1 + src/r_main.c | 29 ++++++++++++++++++++++++++++- src/r_main.h | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/r_debug.cpp b/src/r_debug.cpp index bb7590a5c..2c77d162b 100644 --- a/src/r_debug.cpp +++ b/src/r_debug.cpp @@ -33,6 +33,7 @@ consvar_t cv_debugrender_contrast = CVAR_INIT("debugrender_contrast", "0.0", CV_CHEAT | CV_FLOAT, contrast_cons_t, nullptr); consvar_t cv_debugrender_spriteclip = CVAR_INIT("debugrender_spriteclip", "Off", CV_CHEAT, CV_OnOff, nullptr); +consvar_t cv_debugrender_portal = CVAR_INIT("debugrender_portal", "Off", CV_CHEAT, CV_OnOff, nullptr); UINT32 debugrender_highlight; diff --git a/src/r_main.c b/src/r_main.c index 5a0bb0db2..5731f7695 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1567,7 +1567,7 @@ void R_RenderPlayerView(void) // Portal rendering. Hijacks the BSP traversal. ps_sw_portaltime = I_GetPreciseTime(); - if (portal_base) + if (portal_base && !cv_debugrender_portal.value) { portal_t *portal; @@ -1622,6 +1622,32 @@ void R_RenderPlayerView(void) R_DrawMasked(masks, nummasks); ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime; + // debugrender_portal: fill portals with red, draw over everything + if (portal_base && cv_debugrender_portal.value) + { + const UINT8 pal = 0x23; // red + portal_t *portal; + + for(portal = portal_base; portal; portal = portal_base) + { + INT32 width = (portal->end - portal->start); + INT32 i; + + for (i = 0; i < width; ++i) + { + INT32 yl = max(portal->ceilingclip[i] + 1, 0); + INT32 yh = min(portal->floorclip[i], viewheight); + + for (; yl < yh; ++yl) + { + screens[0][portal->start + i + (yl * vid.width)] = pal; + } + } + + Portal_Remove(portal); + } + } + free(masks); } @@ -1685,6 +1711,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_debugrender_contrast); CV_RegisterVar(&cv_debugrender_spriteclip); + CV_RegisterVar(&cv_debugrender_portal); COM_AddCommand("debugrender_highlight", Command_Debugrender_highlight); } diff --git a/src/r_main.h b/src/r_main.h index 62d6cd1d3..786b1eaf6 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -148,7 +148,8 @@ void Command_Debugrender_highlight(void); extern consvar_t cv_debugrender_contrast, - cv_debugrender_spriteclip; + cv_debugrender_spriteclip, + cv_debugrender_portal; // Called by startup code. void R_Init(void);