-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix localgrid grabbing #3527
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
base: master
Are you sure you want to change the base?
Fix localgrid grabbing #3527
Conversation
| let viewport_delta = input.mouse.position - self.mouse_position; | ||
| let document_space_transform = self.initial_transform * document_to_viewport.inverse(); | ||
| let delta_pos = if self.state.is_transforming_in_local_space { | ||
| let [local_x_axis, local_y_axis] = self.state.local_transform_axes; | ||
| let local_components = DVec2::new(viewport_delta.dot(local_x_axis), viewport_delta.dot(local_y_axis)); | ||
| document_space_transform.matrix2 * local_components | ||
| } else { | ||
| document_space_transform.transform_vector2(viewport_delta) | ||
| }; | ||
| let scale = document_to_viewport.y_axis.length(); | ||
| let delta_scaled = (if self.slow { delta_pos / SLOWING_DIVISOR } else { delta_pos }) / scale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with adding significant complexity here, you have also broken the «local x-axis constraint» feature (press G to grab then press X twice.
broken_local_grab.mp4
I don't see why there should be any changes to the functionality of the system, since the issue concerned only changing the overlays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
letme try this again
|
this solved the constraint breakage but now every scale is getting calculated with reference to global axis only |
The scale by pressing key S then X will scale in viewport space. Pressing X again will scale in local space. This is the intended behaviour. |
|
This is the issue in #3341 that you are trying to solve in this PR? I am confused since you linked an unrelated discord post… I assume you are referring to the blue numbers in your screenshot. These are drawn by the // A transformation to the local space of the transformation from the document
let document_to_local = glam::DMat2::from_cols(self.state.local_transform_axes[0], self.state.local_transform_axes[1]).inverse();
let transform_local = document_to_local * document_to_viewport.matrix2.inverse() * translation_viewport;
overlay_context.translation_box(transform_local, quad, typed_string); |
|
yeah sorry for the confusion created due to terminologies ill keep this in mind for my further contributions. |
Screen.Recording.2025-12-25.at.6.37.00.PM.1.movI have made some changes i guess it fixes the issue. Please review it and let me know if any breakage is caused or any suggestions. |
| let document_to_local = glam::DMat2::from_cols(self.state.local_transform_axes[0], self.state.local_transform_axes[1]).inverse(); | ||
| let transform_local = document_to_local * document_to_viewport.matrix2.inverse() * translation_viewport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let document_to_local = glam::DMat2::from_cols(self.state.local_transform_axes[0], self.state.local_transform_axes[1]).inverse(); | |
| let transform_local = document_to_local * document_to_viewport.matrix2.inverse() * translation_viewport; | |
| let viewport_to_local = glam::DMat2::from_cols(self.state.local_transform_axes[0], self.state.local_transform_axes[1]).inverse(); | |
| let transform_local = viewport_to_local * translation_viewport / document_to_viewport.matrix2.y_axis.length(); | |
I scuffed up the transformations sorry. The local_transform_axes are actually in viewport space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya i will update these changes
0HyperCube
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me; thanks for your work on these changes.
I'm a bit unsure as to if the local space should be shown when transforming on the global X-axis (G then X once). It also breaks the measuring number in that case when you type some digits to choose an exact translation. This is because the exact typed number is used to avoid rounding errors.
|
okay if that would be the case I will open another PR. |

fix the global state showcase when grabbed even after rotating with an angle
code todo - https://discord.com/channels/731730685944922173/881073965047636018/1399533117441835080
Screen.Recording.2025-12-24.at.6.13.43.AM.1.mov
@Keavon kindly review this
didnt got the issue no.