Fix transform gizmo drag using stale camera / transform state#24091
Open
mufeng1991 wants to merge 2 commits intobevyengine:mainfrom
Open
Fix transform gizmo drag using stale camera / transform state#24091mufeng1991 wants to merge 2 commits intobevyengine:mainfrom
mufeng1991 wants to merge 2 commits intobevyengine:mainfrom
Conversation
…form propagation Prior ordering caused viewport_to_world to use stale camera state; also default confine_cursor to false to avoid unreliable cursor_position during drags.
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
alice-i-cecile
approved these changes
May 3, 2026
alice-i-cecile
requested changes
May 3, 2026
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
The PR description doesn't match the code at all. Can you please rewrite it to clearly explain your changes?
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.
Fix transform gizmo drag by running hover/drag after transform propagation and camera updates.
Prior ordering caused
viewport_to_worldto use stale camera state; also defaultconfine_cursorto false to avoid unreliablecursor_positionduring drags.Objective
Camera::viewport_to_world: use an up-to-dateGlobalTransformand camera computed state when casting pointer rays each frame.Solution
transform_gizmo_hoverandtransform_gizmo_dragafterTransformSystems::PropagateandCameraUpdateSystems, and run hover before drag in the same frame sohovered_axismatches the current cursor beforejust_pressedstarts a drag.transform_gizmo_hover: return early whenTransformGizmoState::activebefore clearinghovered_axis, so drag state is not wiped at the start of the hover system while a drag is in progress.TransformGizmoSettings::confine_cursor: default tofalseand document thatCursorGrabMode::Confinedcan makeWindow::cursor_position()unreliable on some platforms, which breaks per-frameviewport_to_worldduring drags. Apps that want confinement can still setconfine_cursor: true.Testing
cargo check -p bevy_gizmos.cargo run --example transform_gizmo --features free_camera(and any app usingTransformGizmoPlugin): select an entity, drag translate/rotate/scale axes and view handles; confirm motion stays consistent for the whole press–drag–release cycle.main: if drag used to stall or jump when moving the camera (e.g. fly camera) while dragging, this branch should improve ray consistency.<your OS>. Cannot test on Linux Wayland / Windows ARM / web; if anyone sees cursor issues withconfine_cursor: true, that remains an opt-in path.Migration Guide
transform_gizmo_settings.confine_cursor = trueafter plugin init (defaults are nowfalsefor robustness).