[Bugfix]: Save/load camera data with packet, fix incorrect camera yaw/pitch/roll on load #1358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Camera yaw/pitch/roll can be incorrect when loading a save.
Bug repro steps:
cam_Active()->pitch
evaluates to -1.5 (which is within limits. 1.5 = looking down, -1.5 = looking up)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.