Created by: yohjimane
Description:
Camera yaw/pitch/roll can be incorrect when loading a save.
Bug repro steps:
- Load new game
- Look all the way up
- Save game
- check
cam_Active()->pitch
evaluates to -1.5 (which is within limits. 1.5 = looking down, -1.5 = looking up) - Load game from step 3
- Observe with breakpoint in CameraBase.h line 79:
cam_Active()->pitch
is set to value ofo_torso
(evaluates to ~4.865). This value is both incorrect, and invalid for pitch, as pitch values must be between -1.5 to 1.5.
Notes:
This bug is present, but does not cause any direct problems (that i can notice) in latest OpenXray dev build (429519f).
I found this bug while working on some hud inertia logic for my subproject, where some logic dependent on camera yaw value would get messed up after reloading a save while looking upwards.
Solution:
The bug is fixed by using packet to save and load camera yaw/pitch/roll. Now, we only initialize yaw/pitch/roll values from CSE_ALifeCreatureAbstract::o_torso
when packet data is missing.
Initializing values from CSE_ALifeCreatureAbstract::o_torso
is necessary for correct camera orientation when loading into new levels.
Unfortunately this approach will make save files incompatible.