From 3a3a5e06d9a2e579a2481340ba4d4842b7613a8e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Jun 2025 00:43:03 +0200 Subject: [PATCH] =?UTF-8?q?fix=20da=20rippled=20w=C3=B6ter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i hate fixed point maths lmao --- src/r_plane.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 5cb69f607..5598a0d3d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -149,7 +149,7 @@ static fixed_t R_CalculateRippleOffset(drawspandata_t* ds, INT32 y) { fixed_t distance = FixedMul(ds->planeheight, yslope[y]); const INT32 yay = (ds->planeripple.offset + (distance>>9)) & 8191; - return FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; + return FixedDiv(FINESINE(yay), (1<<12) + (distance>>11)); } static void R_CalculatePlaneRipple(drawspandata_t* ds, angle_t angle) @@ -221,6 +221,11 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 ds->ystep = FixedMul(distance, baseyscale); } + // [RH] Instead of using the xtoviewangle array, I calculated the fractional values + // at the middle of the screen, then used the calculated ds_xstep and ds_ystep + // to step from those to the proper texture coordinate to start drawing at. + // That way, the texture coordinate is always calculated by its position + // on the screen and not by its position relative to the edge of the visplane. ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep; ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep; @@ -232,6 +237,7 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 ds->xfrac += ds->planeripple.xfrac; ds->yfrac += ds->planeripple.yfrac; + ds->bgofs >>= FRACBITS; if ((y + ds->bgofs) >= viewheight) ds->bgofs = viewheight-y-1; @@ -274,6 +280,8 @@ static void R_MapTiltedPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); R_SetSlopePlaneVectors(ds, ds->currentplane, y, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac)); + ds->bgofs >>= FRACBITS; + if ((y + ds->bgofs) >= viewheight) ds->bgofs = viewheight-y-1; if ((y + ds->bgofs) < 0)