From f71ba63cd3f1217a2b2f7112f270f96bea4e5680 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Mar 2023 05:56:00 -0800 Subject: [PATCH] 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. --- src/deh_tables.c | 1 + src/r_defs.h | 2 ++ src/r_things.c | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index de88639e8..14d4696f8 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -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}, diff --git a/src/r_defs.h b/src/r_defs.h index d4606c8ad..4e947616b 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -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 diff --git a/src/r_things.c b/src/r_things.c index 5f29920a5..458eaac4e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -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++) {