From 6682f1df69be32509cd54f8a47f0b599b7ed30da Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 29 Nov 2025 17:11:08 -0500 Subject: [PATCH] R_ProjectSprite: move fakeflat clipping before light maths https://github.com/Indev450/SRB2Kart-Saturn/commit/c81cd48552d9e63cda680ceea9ddf47a20b507e2 --- src/r_things.cpp | 60 ++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 899ad4a9e..754e67e94 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2333,6 +2333,38 @@ static void R_ProjectSprite(mobj_t *thing) return; } + // killough 3/27/98: exclude things totally separated + // from the viewer, by either water or fake ceilings + // killough 4/11/98: improve sprite clipping for underwater/fake ceilings + + heightsec = thing->subsector->sector->heightsec; + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) + phs = viewplayer->mo->subsector->sector->heightsec; + else + phs = -1; + + if (heightsec != -1 && phs != -1) // only clip things which are in special sectors + { + fixed_t secheight; + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + gzt < secheight) + return; + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + gzt < secheight && viewz >= secheight : + interp.z >= secheight) + return; + } + + if (thing->terrain != NULL) + { + floorClip = thing->terrain->floorClip; + } + if (thing->renderflags & RF_ABSOLUTELIGHTLEVEL) { const UINT8 n = R_ThingLightLevel(thing); @@ -2404,34 +2436,6 @@ static void R_ProjectSprite(mobj_t *thing) lights_array = scalelight[lightnum]; } - heightsec = thing->subsector->sector->heightsec; - if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) - phs = viewplayer->mo->subsector->sector->heightsec; - else - phs = -1; - - if (heightsec != -1 && phs != -1) // only clip things which are in special sectors - { - fixed_t secheight; - - secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); - if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? - interp.z >= secheight : - gzt < secheight) - return; - - secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); - if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? - gzt < secheight && viewz >= secheight : - interp.z >= secheight) - return; - } - - if (thing->terrain != NULL) - { - floorClip = thing->terrain->floorClip; - } - // store information in a vissprite vis = R_NewVisSprite(); vis->renderflags = thing->renderflags;