- Return to center using tangent of pitch, as per original games (Duke/SW).

* Preserves the original return to center feel more accurately as original algorithm can't directly translate to pitch. If we ever get rid of Build's horizon throughout the games, this can go on the chopping block then as a necessity.
This commit is contained in:
Mitchell Richters 2020-12-30 18:02:14 +11:00
parent 0afaff2663
commit 5c87b7b894

View file

@ -289,27 +289,24 @@ void sethorizon(fixedhoriz* horiz, float const horz, ESyncBits* actions, double
pitch += scaleAdjust * amount;
}
// clamp pitch after processing
pitch = clamp(pitch, -90, 90);
// clamp before converting back to horizon
*horiz = q16horiz(clamp(PitchToHoriz(pitch), gi->playerHorizMin(), gi->playerHorizMax()));
// return to center if conditions met.
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
if (abs(pitch) > 0.1375)
if (abs(horiz->asq16()) > FloatToFixed(0.25))
{
// move pitch back to 0
pitch += -scaleAdjust * pitch * (9. / GameTicRate);
// move horiz back to 0
*horiz -= q16horiz(xs_CRoundToInt(scaleAdjust * horiz->asq16() * (10. / GameTicRate)));
}
else
{
// not looking anymore because pitch is back at 0
pitch = 0;
// not looking anymore because horiz is back at 0
*horiz = q16horiz(0);
*actions &= ~SB_CENTERVIEW;
}
}
// clamp before returning
*horiz = q16horiz(clamp(PitchToHoriz(pitch), gi->playerHorizMin(), gi->playerHorizMax()));
}
//---------------------------------------------------------------------------