- check for angular overflow in pitch calculations.

This commit is contained in:
Christoph Oelckers 2020-01-29 21:52:17 +01:00
parent a0fa0560d4
commit 4aaf6c4cf6
2 changed files with 2 additions and 0 deletions

View file

@ -5507,6 +5507,7 @@ RECHECK:
}
}
horizAngle = clamp(horizAngle, -255.f, 255.f); // keep the angle within ]-90°..90°[
pPlayer->q16horiz = F16(100) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f)));
if (pPlayer->return_to_center > 0 && !TEST_SYNC_KEY(playerBits, SK_LOOK_UP) && !TEST_SYNC_KEY(playerBits, SK_LOOK_DOWN))

View file

@ -282,6 +282,7 @@ void PlayerInterruptKeys()
// so we convert horiz to 1024 angle units
float horizAngle = atan2f(nVertPan[nLocalPlayer] - F16(92), F16(128)) * (512.f / fPI) + fix16_to_float(q16horz);
horizAngle = clamp(horizAngle, -255.f, 255.f);
nVertPan[nLocalPlayer] = fix16_clamp(F16(92) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f))), F16(0), F16(184));
}