From dea19e4416d54cfde6e7e5c89fca6b95f78d94e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jan 2024 11:20:54 +0100 Subject: [PATCH] forgor R_GetSlopeZAt --- src/r_plane.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/r_plane.c b/src/r_plane.c index e6306560b..33249a6c0 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -742,6 +742,18 @@ static void R_DrawSkyPlane(visplane_t *pl) } } +// Returns the height of the sloped plane at (x, y) as a 32.16 fixed_t +static INT64 R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) +{ + INT64 x64 = ((INT64)x - (INT64)slope->o.x); + INT64 y64 = ((INT64)y - (INT64)slope->o.y); + + x64 = (x64 * (INT64)slope->d.x) / FRACUNIT; + y64 = (y64 * (INT64)slope->d.y) / FRACUNIT; + + return (INT64)slope->o.z + ((x64 + y64) * (INT64)slope->zdelta) / FRACUNIT; +} + // Sets the texture origin vector of the sloped plane. static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) { @@ -759,7 +771,7 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f // errors if the flat is rotated. p->x = vxf * cos(ang) - vyf * sin(ang); p->z = vxf * sin(ang) + vyf * cos(ang); - p->y = (R_GetZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; + p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; } // This function calculates all of the vectors necessary for drawing a sloped plane.