R_FindPlane: fix offsets rotation overflow for non-sloped planes

This commit is contained in:
James R. 2023-09-13 00:27:06 -07:00
parent 9e283a4993
commit 635d9dca3e

View file

@ -365,16 +365,27 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
if (!slope) // Don't mess with this right now if a slope is involved
{
xoff += viewx;
yoff -= viewy;
if (plangle != 0)
{
// Must use 64-bit math to avoid an overflow!
INT64 vx = xoff + viewx;
INT64 vy = yoff - viewy;
// Add the view offset, rotated by the plane angle.
float ang = ANG2RAD(plangle);
float x = FixedToFloat(xoff);
float y = FixedToFloat(yoff);
xoff = FloatToFixed(x * cos(ang) + y * sin(ang));
yoff = FloatToFixed(-x * sin(ang) + y * cos(ang));
float x = vx / (float)FRACUNIT;
float y = vy / (float)FRACUNIT;
vx = (x * cos(ang) + y * sin(ang)) * FRACUNIT;
vy = (-x * sin(ang) + y * cos(ang)) * FRACUNIT;
xoff = vx;
yoff = vy;
}
else
{
xoff += viewx;
yoff -= viewy;
}
}