- Tidy up nested branch in calcChaseCamPos().

This commit is contained in:
Mitchell Richters 2023-03-27 20:43:55 +11:00
parent 6c2717fcde
commit 892dde030f

View file

@ -61,7 +61,7 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, const
// If something is in the way, make cameradist lower if necessary
if (npos.XY().Sum() > hpos.XY().Sum())
{
double DVector3::* c = fabs(npos.X) > fabs(npos.Y) ? &DVector3::X : &DVector3::Y;
const auto c = fabs(npos.X) > fabs(npos.Y) ? &DVector3::X : &DVector3::Y;
if (hitinfo.hitWall != nullptr)
{
@ -75,25 +75,22 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, const
*psect = hitinfo.hitSector;
hpos.*c -= npos.*c * (1. / 32.);
}
else
else if (!(hitinfo.hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
{
// If you hit a sprite that's not a wall sprite - try again.
if (!(hitinfo.hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
{
bakcstat = hitinfo.hitActor->spr.cstat;
hitinfo.hitActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
calcChaseCamPos(ppos, act, psect, angles, interpfrac, backamp);
hitinfo.hitActor->spr.cstat = bakcstat;
return false;
}
else
{
// same as wall calculation.
hpos.*c -= npos.*c * npos.XY().dot((act->spr.Angles.Yaw - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.);
}
bakcstat = hitinfo.hitActor->spr.cstat;
hitinfo.hitActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
calcChaseCamPos(ppos, act, psect, angles, interpfrac, backamp);
hitinfo.hitActor->spr.cstat = bakcstat;
return false;
}
else
{
// same as wall calculation.
hpos.*c -= npos.*c * npos.XY().dot((act->spr.Angles.Yaw - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.);
}
double newdist = hpos.*c / npos.*c;
const double newdist = hpos.*c / npos.*c;
if (newdist < cameradist) cameradist = newdist;
}