Add RF_ALWAYSONTOP, renders sprite through walls

Specifically, it avoids sorting or clipping the sprite
against stuff like FOF planes, which are notorious for
messing up sprites. Useful for debug stuff which
absolutely must be visible.
This commit is contained in:
James R 2023-03-06 05:56:00 -08:00
parent aed9fe996c
commit f71ba63cd3
3 changed files with 17 additions and 2 deletions

View file

@ -6303,6 +6303,7 @@ struct int_const_s const INT_CONST[] = {
{"RF_FULLDARK",RF_FULLDARK},
{"RF_SEMIBRIGHT",RF_SEMIBRIGHT},
{"RF_NOCOLORMAPS",RF_NOCOLORMAPS},
{"RF_ALWAYSONTOP",RF_ALWAYSONTOP},
{"RF_SPRITETYPEMASK",RF_SPRITETYPEMASK},
{"RF_PAPERSPRITE",RF_PAPERSPRITE},
{"RF_FLOORSPRITE",RF_FLOORSPRITE},

View file

@ -932,6 +932,8 @@ typedef enum
RF_NOCOLORMAPS = 0x00000400, // Sprite is not drawn with colormaps
RF_ALWAYSONTOP = 0x00000800, // Sprite is drawn on top of level geometry
RF_SPRITETYPEMASK = 0x00003000, // --Different sprite types
RF_PAPERSPRITE = 0x00001000, // Paper sprite
RF_FLOORSPRITE = 0x00002000, // Floor sprite

View file

@ -2975,6 +2975,9 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev)
{
const boolean alwaysontop = cv_debugrender_spriteclip.value || (rover->renderflags & RF_ALWAYSONTOP);
const INT32 ontopflag = cv_debugrender_spriteclip.value ? 0 : (rover->renderflags & RF_ALWAYSONTOP);
if (rover->szt > vid.height || rover->sz < 0)
continue;
@ -2982,7 +2985,7 @@ 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)
if (alwaysontop)
{
// Only sort behind other sprites; sorts in
// front of everything else.
@ -2990,6 +2993,15 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
{
continue;
}
// Only sort behind other RF_ALWAYSONTOP sprites.
// This avoids sorting behind a sprite that is
// behind level geometry and thus sorting this
// one behind level geometry too.
if (r2->sprite->renderflags ^ ontopflag)
{
continue;
}
}
if (r2->plane)
@ -3254,7 +3266,7 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal)
fixed_t lowscale;
INT32 silhouette;
if (cv_debugrender_spriteclip.value)
if ((spr->renderflags & RF_ALWAYSONTOP) || cv_debugrender_spriteclip.value)
{
for (x = x1; x <= x2; x++)
{