Add snap option to gizmos (Ctrl+drag)#994
Conversation
MrNeRF
left a comment
There was a problem hiding this comment.
Thanks for this pr. I have added two comments which make it a bit more general.
Could be also 10 degrees? Wdyt?
| inline const float* computeSnapPtr(float* buf, ImGuizmo::OPERATION op) { | ||
| if (!ImGui::GetIO().KeyCtrl) | ||
| return nullptr; | ||
| if (op == ImGuizmo::ROTATE) |
There was a problem hiding this comment.
should be & instead == to match individual axes.
There was a problem hiding this comment.
Fixed. Now using bitmask comparison consistent with TRANSLATE/SCALE. 36d3ad2
| else if (op & ImGuizmo::TRANSLATE) | ||
| buf[0] = buf[1] = buf[2] = TRANSLATE_SNAP_UNITS; | ||
| else if (op & ImGuizmo::SCALE) | ||
| buf[0] = SCALE_SNAP_RATIO; |
There was a problem hiding this comment.
buf[0] = buf[1] = buf[2] = SCALE_SNAP_RATIO; // to snap all scale axes, no?
There was a problem hiding this comment.
Fixed. All three axes now receive the snap value. 36d3ad2
- ROTATE comparison changed from == to & for consistency with TRANSLATE/SCALE - SCALE snap now fills all three axes instead of only buf[0]
Thanks for the review! I hardcoded 5° to match Blender's default. Ideally this would be |
Thank you. Let's start with 5 degrees and let's see how it goes. Configuration can be added later, too! |
Summary
Details
Introduces a computeSnapPtr() helper that returns snap values based on the active gizmo operation
when Ctrl is held, or nullptr otherwise. Applied to all three ImGuizmo::Manipulate call sites in
GizmoManager (node gizmo, standard gizmo, and the third gizmo path).
#746