From cfa853d02263fe8dde21f7b12a60b74a4075a36e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 22:07:55 +0100 Subject: [PATCH] software: clip sprites that are out of view similar to what the frustum cull does in opengl, clips sprites that are out of view in vertical direction --- src/r_things.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/r_things.cpp b/src/r_things.cpp index ee0f75a72..12e7a2854 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1620,6 +1620,20 @@ static void R_ProjectSprite(mobj_t *thing) return; } + if (!papersprite) + { + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + 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 @@ -1969,6 +1983,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + return; + } + // aspect ratio stuff : yscale = FixedDiv(projectiony, tz);