- SW: Uplift `playerSetHoriz()` similar to uplift to `playerSetAngle()` in b832442e31.

This commit is contained in:
Mitchell Richters 2020-09-09 22:04:46 +10:00
parent b832442e31
commit e24521b189
3 changed files with 23 additions and 3 deletions

View File

@ -1009,7 +1009,7 @@ struct PLAYERstruct
// Input helper variables and setters.
double horizAdjust, angAdjust, pitchAdjust;
fixed_t angTarget;
fixed_t horizTarget, angTarget;
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
void setang(int v) { q16ang = IntToFixed(v); }
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }

View File

@ -284,7 +284,18 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
DoPlayerHorizon(pp, q16horz, scaleAdjust);
}
if (pp->horizAdjust)
if (pp->horizTarget)
{
fixed_t horizDelta = pp->horizTarget - pp->q16horiz;
pp->q16horiz += xs_CRoundToInt(scaleAdjust * horizDelta);
if (abs(pp->q16horiz) >= abs(horizDelta))
{
pp->q16horiz = pp->horizTarget;
pp->horizTarget = 0;
}
}
else if (pp->horizAdjust)
{
pp->q16horiz += FloatToFixed(scaleAdjust * pp->horizAdjust);
}

View File

@ -7834,7 +7834,16 @@ void playerSetHoriz(PLAYERp pp, double horiz)
{
if (!cl_syncinput)
{
pp->horizAdjust += -1. * ((pp->q16horiz / 65536.) - horiz);
// Cancel out any horizon adjustments as we're setting horizon now.
pp->horizAdjust = 0;
// Add slight offset if input horizon is coming in as absolute 0.
if (horiz == 0)
{
horiz += 0.1;
}
pp->horizTarget = FloatToFixed(horiz);
}
else
{