Add cv_debugrender_spriteclip, toggle sprite clipping

This cvar can be used to reveal which sprites are
technically drawn but clipped completely by level
geometry.
This commit is contained in:
James R 2023-03-06 05:14:57 -08:00
parent 53b2922fbb
commit aed9fe996c
4 changed files with 25 additions and 1 deletions

View file

@ -31,6 +31,8 @@ CV_PossibleValue_t contrast_cons_t[] = {{-FRACUNIT, "MIN"}, {FRACUNIT, "MAX"}, {
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);
UINT32 debugrender_highlight;
void R_CheckDebugHighlight(debugrender_highlight_t k)

View file

@ -1660,6 +1660,7 @@ void R_RegisterEngineStuff(void)
// debugging
CV_RegisterVar(&cv_debugrender_contrast);
CV_RegisterVar(&cv_debugrender_spriteclip);
COM_AddCommand("debugrender_highlight", Command_Debugrender_highlight);
}

View file

@ -145,7 +145,8 @@ INT32 R_AdjustLightLevel(INT32 light);
void Command_Debugrender_highlight(void);
extern consvar_t
cv_debugrender_contrast;
cv_debugrender_contrast,
cv_debugrender_spriteclip;
// Called by startup code.
void R_Init(void);

View file

@ -2982,6 +2982,16 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
for (r2 = head->next; r2 != head; r2 = r2->next)
{
if (cv_debugrender_spriteclip.value)
{
// Only sort behind other sprites; sorts in
// front of everything else.
if (!r2->sprite)
{
continue;
}
}
if (r2->plane)
{
fixed_t planeobjectz, planecameraz;
@ -3244,6 +3254,16 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal)
fixed_t lowscale;
INT32 silhouette;
if (cv_debugrender_spriteclip.value)
{
for (x = x1; x <= x2; x++)
{
spr->clipbot[x] = (INT16)viewheight;
spr->cliptop[x] = (INT16)con_clipviewtop;
}
return;
}
for (x = x1; x <= x2; x++)
{
spr->clipbot[x] = spr->cliptop[x] = CLIP_UNDEF;