From 5c87b7b894a4c57f90aea480fd083d26e82a17b6 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 30 Dec 2020 18:02:14 +1100 Subject: [PATCH] - 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. --- source/core/gameinput.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index ce515f974..077e082b6 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -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())); } //---------------------------------------------------------------------------