R_ProjectSprite: fix overflow in sideways perspective clipping

Multiplications of perspective values can easily overflow
and flip sign bit at far distances. Instead, divide the
left operand.
This commit is contained in:
James R 2023-06-02 16:09:47 -07:00
parent 80584c9d2f
commit 54b3aff09f

View file

@ -1989,7 +1989,7 @@ static void R_ProjectSprite(mobj_t *thing)
tz2 = FixedMul(MINZ, this_scale);
}
if (tx2 < -(FixedMul(tz2, fovtan[viewssnum])<<2) || tx > FixedMul(tz, fovtan[viewssnum])<<2) // too far off the side?
if ((tx2 / 4) < -(FixedMul(tz2, fovtan[viewssnum])) || (tx / 4) > FixedMul(tz, fovtan[viewssnum])) // too far off the side?
return;
yscale = FixedDiv(projectiony[viewssnum], tz);