diff --git a/src/cvars.cpp b/src/cvars.cpp index fd93e79f8..b16d04987 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -878,6 +878,7 @@ consvar_t cv_debugrank = PlayerCheat("debugrank", "Off").description("Show GP ra consvar_t cv_debugrender_contrast = PlayerCheat("debugrender_contrast", "0.0").floating_point().min_max(-FRACUNIT, FRACUNIT).description("Change level lighting"); consvar_t cv_debugrender_portal = PlayerCheat("debugrender_portal", "Off").on_off().description("Highlight visual portals in red"); consvar_t cv_debugrender_spriteclip = PlayerCheat("debugrender_spriteclip", "Off").on_off().description("Let sprites draw through walls"); +consvar_t cv_debugrender_visplanes = PlayerCheat("debugrender_visplanes", "Off").on_off().description("Highlight the number of visplanes"); consvar_t cv_devmode_screen = PlayerCheat("devmode_screen", "1").min_max(1, 4).description("Choose which splitscreen player devmode applies to"); consvar_t cv_drawpickups = PlayerCheat("drawpickups", "Yes").yes_no().description("Hide rings, spheres, item capsules, prison capsules (visual only)"); consvar_t cv_drawinput = PlayerCheat("drawinput", "No").yes_no().description("Draw turn inputs outside of Record Attack (turn solver debugging)"); diff --git a/src/r_main.cpp b/src/r_main.cpp index 7277c2ace..2649fb3a1 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -55,6 +55,8 @@ INT64 mytotal = 0; #endif //profile stuff --------------------------------------------------------- +extern "C" consvar_t cv_debugrender_visplanes; + // Fineangles in the SCREENWIDTH wide window. #define FIELDOFVIEW 2048 @@ -1603,6 +1605,58 @@ void R_RenderPlayerView(void) R_DrawMasked(masks, nummasks); ps_sw_maskedtime = I_GetPreciseTime() - ps_sw_maskedtime; + if (cv_debugrender_visplanes.value) + { + for (INT32 i = 0; i < MAXVISPLANES; i++) + { + for (visplane_t* pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->minx > pl->maxx) + continue; + auto col = [](int x, int top, int bot) + { + if (top > bot) + std::swap(top, bot); + UINT8* p = &screens[0][x + top * vid.width]; + while (top <= bot) + { + *p = 35; + p += vid.width; + top++; + } + }; + auto span = [col](int x, int top, int bot) + { + if (top <= bot) + col(x, top, bot); + }; + INT32 top = pl->top[pl->minx]; + INT32 bottom = pl->bottom[pl->minx]; + span(pl->minx, top, bottom); + span(pl->maxx, pl->top[pl->maxx], pl->bottom[pl->maxx]); + for (INT32 x = pl->minx + 1; x < pl->maxx; ++x) + { + INT32 new_top = pl->top[x]; + INT32 new_bottom = pl->bottom[x]; + if (new_top > new_bottom) + continue; + if (top > bottom) + { + col(x, new_top, new_top); + col(x, new_bottom, new_bottom); + } + else + { + col(x, top, new_top); + col(x, bottom, new_bottom); + } + top = new_top; + bottom = new_bottom; + } + } + } + } + // debugrender_portal: fill portals with red, draw over everything if (portal_base && cv_debugrender_portal.value) {