Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix]: Save/load camera data with packet, fix incorrect camera yaw/pitch/roll on load #1358

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

yohjimane
Copy link
Contributor

@yohjimane yohjimane commented May 30, 2023

Description:

Camera yaw/pitch/roll can be incorrect when loading a save.

Bug repro steps:

  1. Load new game
  2. Look all the way up
  3. Save game
  4. check cam_Active()->pitch evaluates to -1.5 (which is within limits. 1.5 = looking down, -1.5 = looking up)
  5. Load game from step 3
  6. Observe with breakpoint in CameraBase.h line 79: cam_Active()->pitch is set to value of o_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.

@yohjimane yohjimane changed the title [Bugfix]: Save/load camera data from packet, fix incorrect camera yaw/pitch/roll on load [Bugfix]: Save/load camera data with packet, fix incorrect camera yaw/pitch/roll on load May 30, 2023
@Xottab-DUTY
Copy link
Member

Can we fix it without adding data to net packets? Doing so will cause previous game saves incompatibility

@Xottab-DUTY Xottab-DUTY added Enhancement Bug The issue in the run-time. labels May 31, 2023
@yohjimane
Copy link
Contributor Author

yohjimane commented May 31, 2023

@Xottab-DUTY i am not sure 😢

I was thinking maybe we could just clamp the pitch/yaw values from o_torso, but the values are too different. For example, when camera pitch = -1.5 then o_torso pitch = 4.5, clamping that to proper limits would give inverted value of 1.5.

@yohjimane yohjimane added the Breaking change This breaks saves compatibility, or changes binary formats, etc. label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change This breaks saves compatibility, or changes binary formats, etc. Bug The issue in the run-time. Enhancement
Projects
Status: Postponed
Development

Successfully merging this pull request may close these issues.

2 participants