DRAFT Fix vehicle exit shake#143
Draft
AJBats wants to merge 2 commits into
Draft
Conversation
87bf818 to
0912708
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is just a draft of a fix for the vehicle exit shake bug. I'm putting it up in an unfinished draft state because i want to get in front of maintaner's eyes sooner rather than later to get their take on it. For full transparency, this was coded with assistance from Claude Opus 4.5, and I don't fully understand the fix here, though Claude has walked me through it and it makes sense to me. So please consider this when reviewing.
Summary
Problem
When exiting a vehicle, InputHandler::UpdateCamera() computes yaw = atan2(lookHMD) - atan2(lookGame). Because lookGame still points in the vehicle's facing direction while lookHMD points where the player's head is, this produces a large delta that overshoots. Each subsequent frame overcorrects in the opposite direction, creating a diverging feedback loop visible as violent camera shake. This was confirmed by diagnostic CSV captures showing yawGame oscillating with growing magnitude while yawHMD remained steady.
Vehicle enter is unaffected because vehicle mode uses UpdateCameraForVehicles() (joystick-based), which doesn't compute HMD deltas.
Fix
Rotation (UpdateCamera): Zero yaw/pitch deltas for 90 frames (~1s) after vehicle exit so the game's native camera transition runs without VR correction interference. On cooldown expiry, sync LastLookDir and lookDir to the current HMD direction so tracking resumes with near-zero delta.
Position (PreDrawFrame): EMA smooth the camera position (alpha=0.04) from the vehicle camera to first-person, disabling automatically when converged.
Testing
I've only tested a single scenario so far. I'm going to keep testing.