R_ProjectSprite: move fakeflat clipping before light maths

c81cd48552
This commit is contained in:
NepDisk 2025-11-29 17:11:08 -05:00
parent b1662cc407
commit 6682f1df69

View file

@ -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(&sectors[heightsec], viewx, viewy);
if (viewz < P_GetSectorFloorZAt(&sectors[phs], interp.x, interp.y) ?
interp.z >= secheight :
gzt < secheight)
return;
secheight = P_GetSectorCeilingZAt(&sectors[heightsec], viewx, viewy);
if (viewz > P_GetSectorCeilingZAt(&sectors[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(&sectors[heightsec], viewx, viewy);
if (viewz < P_GetSectorFloorZAt(&sectors[phs], interp.x, interp.y) ?
interp.z >= secheight :
gzt < secheight)
return;
secheight = P_GetSectorCeilingZAt(&sectors[heightsec], viewx, viewy);
if (viewz > P_GetSectorCeilingZAt(&sectors[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;