Size the Design move/rotate gizmo from the body, like Orca's Prepare gizmos

The Design gizmo already had both move arrows and rotation rings, but drew them
at a fixed 70 px arm regardless of the body: on a 40 mm cube everything
collapsed into a ~100 px tangle buried inside the solid, so the rings were
effectively invisible and the tool read as "move only, no rotate".

Orca's Prepare gizmos size themselves from the selection's bounding sphere
(GLGizmoRotate3D: m_radius = Offset + sphere radius) so the handles always clear
the object. Same rule here: DesignPanel passes the body's bounding-sphere radius
(scale-aware) into the gizmo, and move_gizmo_arm() returns
max(70 px, 1.25 * radius) — the screen-space floor keeps it grabbable on a tiny
body or when zoomed far out. Ring radius and BOTH hit-tests derive from that one
helper, so picking cannot drift from what is drawn.

Verified on a 40 mm cube: rings now encircle the body, arrow drag moves with a
live mm readout, ring drag rotates live.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVzKmX6Y1aEteit1HTXG4Q
This commit is contained in:
Tommaso Bianchi
2026-07-19 08:36:26 +02:00
co-authored by Claude Opus 4.8
parent f4160595b0
commit 8d529ad413
5 changed files with 39 additions and 11 deletions
+7 -2
View File
@@ -3453,8 +3453,13 @@ void DesignPanel::on_move_body()
// Delta gizmo: pivot at the body's CURRENT world centroid; the tool composes the drag deltas
// onto its current pose, so move + rotate both work (incl. on an already place-on-face'd body).
const Transform3d base = m_body_xform[b];
const Vec3d pivot = base * m_doc.display_body_meshes[b].bounding_box().center();
m_viewport->begin_move_body(b, pivot, base);
const BoundingBoxf3 bb = m_doc.display_body_meshes[b].bounding_box();
const Vec3d pivot = base * bb.center();
// Bounding-sphere radius (world): the gizmo scales with it so the rotation rings sit clear of
// the body instead of collapsing into a tangle inside it — same sizing rule as Orca's Prepare
// gizmos. The scale part of `base` is applied so a scaled body still gets a correct radius.
const double radius = (base.linear() * (bb.size() * 0.5)).norm();
m_viewport->begin_move_body(b, pivot, base, radius);
m_move_body = b; // for the action bar: Cancel reverts to this pose
m_move_prev = base;
update_action_bar(); // surface the unified ✓/✗ while moving