on second thought maybe we don't need extra tx clamping, it turns out to be more effort than it's worth (at least for now)

meanwhile, let's move x/yscale calculations down since we don't actually need them until later on
This commit is contained in:
Monster Iestyn 2020-05-19 22:00:34 +01:00
parent 65d6b04fd2
commit c3d576058a
1 changed files with 5 additions and 9 deletions

View File

@ -1556,10 +1556,8 @@ static void R_ProjectSprite(mobj_t *thing)
tr_x += FixedMul(offset, cosmul);
tr_y += FixedMul(offset, sinmul);
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
yscale = FixedDiv(projectiony, tz);
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
xscale = FixedDiv(projection, tz);
// Get paperoffset (offset) and paperoffset (distance)
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
@ -1574,10 +1572,8 @@ static void R_ProjectSprite(mobj_t *thing)
tr_x += FixedMul(offset2, cosmul);
tr_y += FixedMul(offset2, sinmul);
tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
yscale2 = FixedDiv(projectiony, tz2);
tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
xscale2 = FixedDiv(projection, tz2);
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
return;
@ -1588,22 +1584,19 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
tx += FixedDiv(tx2-tx, div);
tz = FixedMul(MINZ, this_scale);
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection, tz);
}
else if (tz2 < FixedMul(MINZ, this_scale))
{
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
tx2 += FixedDiv(tx-tx2, div);
tz2 = FixedMul(MINZ, this_scale);
yscale2 = FixedDiv(projectiony, tz2);
xscale2 = FixedDiv(projection, tz2);
}
if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side?
return;
// TODO: tx clamping
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection, tz);
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
@ -1611,6 +1604,9 @@ static void R_ProjectSprite(mobj_t *thing)
if (x1 > viewwidth)
return;
yscale2 = FixedDiv(projectiony, tz2);
xscale2 = FixedDiv(projection, tz2);
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
// off the left side