Skip to content

fix: stop planes snapping heading after landing - #81

Merged
Drefvelin merged 1 commit into
mainfrom
fix/plane-landing-yaw-snap
Oct 26, 2026
Merged

Drefvelin merged 1 commit into
mainfrom
fix/plane-landing-yaw-snap

Conversation

@Drefvelin

Copy link
Copy Markdown
Contributor

Fixes the player report that planes suddenly turn about 90° left or right after landing (suggestion ywrgw-mbr96).

Cause

  • Stale driveYaw. Ground steering (RotateController.turn) sets the heading to driveYaw + turn and snaps instantly. driveYaw only changed on direct yaw input. Planes turn by banking (roll, then pitch), which changed the real heading but not driveYaw. The first SHIFT_A/D press after landing therefore snapped the plane back to its old heading, and its travel direction with it.
  • Wrong yaw in ConvertedAngle(Quaternionf). The yaw formula used y² + z² instead of x² + y², so it was only exact when pitch or roll was zero. The landing no_lift target keeps "current yaw" through this decode, which added up to about 11° of error at normal landing attitudes and more at steep ones.

Fix

  • Use the correct rotateYXZ inverse for yaw.
  • After every applied incremental rotation, rotateNoAdd re-reads driveYaw from the bone (syncDriveYaw()).

Level vehicles are unaffected because the old and new formulas agree when pitch and roll are zero.

Tests

  • ConvertedAngleTest round-trips rotateYXZ angles. Six of the eight cases fail on the old formula.
  • BoneRotatorDriveYawTest.bankedTurnHeadingIsWhereGroundTurningStarts banks and turns 62°, lands, then steers on the ground. On main, the plane snaps back to about 1°.

🤖 Generated with Claude Code

ConvertedAngle decoded yaw with the wrong denominator, so it was only
exact at zero pitch or roll. driveYaw also ignored heading changes from
banked turns, so the first ground turn after landing snapped the plane
back to its pre-flight heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:XS 0-9 effective changed lines (tests excluded in mixed PRs). label Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2b3b5a6c-9d5d-4be8-acc7-0ca550eedd1f
Commits

Reviewing files that changed from the base of the PR and between f77a54e and f3f7c8f.

Files selected for processing: 4
  • src/main/java/net/tfminecraft/vehicleframework/bones/BoneRotator.java
  • src/main/java/net/tfminecraft/vehicleframework/bones/ConvertedAngle.java
  • src/test/java/net/tfminecraft/vehicleframework/bones/BoneRotatorDriveYawTest.java
  • src/test/java/net/tfminecraft/vehicleframework/bones/ConvertedAngleTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved vehicle heading consistency when turning and banking. Heading is now retained more reliably when pitch and roll return to level, and subsequent turns respond more predictably.
    • Improved the accuracy of yaw, pitch and roll readings across a range of vehicle orientations.

The changes update quaternion yaw calculation and synchronise driveYaw from the resulting quaternion after an allowed rotation. New tests check angle conversions and heading changes after banking, levelling and turning.

Changes: Yaw calculation and rotation synchronisation

Layer / File(s) Summary
Update yaw calculation and rotation synchronisation
src/main/java/net/tfminecraft/vehicleframework/bones/ConvertedAngle.java, src/main/java/net/tfminecraft/vehicleframework/bones/BoneRotator.java, src/test/java/net/tfminecraft/vehicleframework/bones/ConvertedAngleTest.java, src/test/java/net/tfminecraft/vehicleframework/bones/BoneRotatorDriveYawTest.java
The yaw calculation now uses the X and Y quaternion components in its denominator. After an allowed incremental rotation, BoneRotator synchronises driveYaw from the resulting quaternion. Tests cover eight angle combinations and heading changes after banking and turning.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: ryanbarlow97, xxfran10xx

Merge Risk: Minimal · up to f3f7c

The heading fix appears ready to merge after normal checks; no actionable issue remains identified.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Drefvelin
Drefvelin merged commit e5efc1e into main Oct 26, 2026
3 checks passed
@Drefvelin
Drefvelin deleted the fix/plane-landing-yaw-snap branch October 26, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant