From effe3aeb37d27765f12da19a1d4b545a3cd7e94e Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos <jp6781615@gmail.com> Date: Tue, 12 Oct 2021 15:41:44 -0300 Subject: [PATCH] Hide shadows completely below or above a fake floor or ceiling --- src/hardware/hw_main.c | 19 ++++++++++++++++++- src/r_things.c | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9b89f288cd..2bf7025ecd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3614,6 +3614,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) FBITFIELD blendmode = PF_Translucent|PF_Modulated; INT32 shader = SHADER_DEFAULT; UINT8 i; + INT32 heightsec, phs; SINT8 flip = P_MobjFlip(thing); INT32 light; @@ -3626,7 +3627,23 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) groundz = R_GetShadowZ(thing, &groundslope); - //if (abs(groundz - gl_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes + heightsec = thing->subsector->sector->heightsec; + if (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 + { + if (gl_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? + thing->z >= sectors[heightsec].floorheight : + thing->z < sectors[heightsec].floorheight) + return; + if (gl_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? + thing->z < sectors[heightsec].ceilingheight && gl_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : + thing->z >= sectors[heightsec].ceilingheight) + return; + } floordiff = abs((flip < 0 ? thing->height : 0) + thing->z - groundz); diff --git a/src/r_things.c b/src/r_things.c index e114ef08aa..6c510c68d6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1265,6 +1265,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, vissprite_t *shadow; patch_t *patch; fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; + INT32 heightsec, phs; INT32 light = 0; fixed_t scalemul; UINT8 trans; fixed_t floordiff; @@ -1276,6 +1277,24 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, if (abs(groundz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes + heightsec = thing->subsector->sector->heightsec; + if (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 + { + if (viewz < sectors[phs].floorheight ? + groundz >= sectors[heightsec].floorheight : + groundz < sectors[heightsec].floorheight) + return; + if (viewz > sectors[phs].ceilingheight ? + groundz < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + groundz >= sectors[heightsec].ceilingheight) + return; + } + floordiff = abs((isflipped ? thing->height : 0) + thing->z - groundz); trans = floordiff / (100*FRACUNIT) + 3; -- GitLab