diff --git a/src/r_things.cpp b/src/r_things.cpp index 497f5a1ec..e250e877b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1612,6 +1612,33 @@ 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->frame & FF_ABSOLUTELIGHTLEVEL) { const UINT8 n = R_ThingLightLevel(thing); @@ -1689,29 +1716,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; - } - // store information in a vissprite vis = R_NewVisSprite(); vis->heightsec = heightsec; //SoM: 3/17/2000