added basic culling of papersprites if tx for either is too large, proper clamping to be added later

also removed some commented out old code
This commit is contained in:
Monster Iestyn 2020-05-19 17:19:44 +01:00
parent c8320b6c9d
commit 1a790235c6

View file

@ -1557,7 +1557,6 @@ static void R_ProjectSprite(mobj_t *thing)
tr_y += FixedMul(offset, sinmul); tr_y += FixedMul(offset, sinmul);
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
yscale = FixedDiv(projectiony, tz); yscale = FixedDiv(projectiony, tz);
//if (yscale < 64) return; // Fix some funky visuals
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
xscale = FixedDiv(projection, tz); xscale = FixedDiv(projection, tz);
@ -1577,7 +1576,6 @@ static void R_ProjectSprite(mobj_t *thing)
tr_y += FixedMul(offset2, sinmul); tr_y += FixedMul(offset2, sinmul);
tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
yscale2 = FixedDiv(projectiony, tz2); yscale2 = FixedDiv(projectiony, tz2);
//if (yscale2 < 64) return; // ditto
tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
xscale2 = FixedDiv(projection, tz2); xscale2 = FixedDiv(projection, tz2);
@ -1586,6 +1584,9 @@ static void R_ProjectSprite(mobj_t *thing)
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
return; return;
if (tx2 < -(tz2<<2) || tx > tz<<2) // too far off the side?
return;
// Needs partially clipped // Needs partially clipped
if (tz < FixedMul(MINZ, this_scale)) if (tz < FixedMul(MINZ, this_scale))
{ {
@ -1606,6 +1607,8 @@ static void R_ProjectSprite(mobj_t *thing)
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
} }
// TODO: tx clamping
// off the right side? // off the right side?
if (x1 > viewwidth) if (x1 > viewwidth)
return; return;