Mate preview: hover a mate row and see the assembly move, commit nothing (G3)

refresh_preview() listed Tool::Mate among the features that produce no solid and
cleared the ghost, with a comment saying a mate has no 3D ghost. The kernel never
agreed: preview() routes a Mate candidate through apply_mate on a throwaway copy
of the bodies, and build_candidate already filled the mate fields. That one early
return was the whole of epic gap G3.

A mate makes no NEW geometry but it MOVES a body, and the moved assembly is the
ghost worth showing. Both the Mate card and the offer's mate palette now show it:
hovering a palette row previews that kind, leaving the row drops it, and choosing
one commits. Nothing is written to the document until the click.

The committed bodies are hidden while the ghost is up — it is the whole assembly
in its post-mate pose, not an added lump, so leaving them visible would draw the
mated body twice and z-fight every other body against its own copy. Same reason
Dressup and Draft hide them.

Cleanup is after PopupMenu rather than on a close event: PopupMenu is modal, so by
then the menu is gone and any command it raised has run. A flag distinguishes a
ghost this menu put up from a preview that was already on screen.

snaporca-b4sp. Reviewed and compiled (RC=0), not exercised.
This commit is contained in:
Tommaso Bianchi
2026-08-13 07:28:21 +02:00
parent 8e15ad23e2
commit 6b3711fb08
3 changed files with 117 additions and 15 deletions
+8
View File
@@ -241,6 +241,14 @@ private:
void set_hole_target_label(int face);
void set_thread_target_label(int face, int edge);
CadFeature build_candidate(Tool t) const;
// Merge per-body ghost meshes with the per-body display transforms applied. The kernel builds
// a ghost from the untransformed bodies, so without this it floats back at the origin once a
// body has been moved.
TriangleMesh ghost_from_bodies(const std::vector<TriangleMesh>& per_body) const;
// A mate makes no new geometry but it MOVES a body, and the moved assembly is the ghost worth
// showing. Used both by the Mate card and by hovering a row of the offer's mate palette.
bool show_mate_ghost(int kind, int cs_a, int cs_b,
double offset, double angle_deg, bool flip, std::string& err);
int resolve_extrude_sketch() const;
// Plane pickers: fill a choice with XY/XZ/YZ + the document's datum planes, and
// map a choice row back to the actual SketchPlane (rows 0-2 base, 3+ datum).