Offer the origin planes while choosing a sketch plane, not only before the first body

Delete a sketch on a document that still has a body and you could not start a new
one. Pressing Sketch said "click a face or a reference plane in the viewport" —
while update_reference_planes had already called clear_base_pick, because a body
existed. The instruction named something that was no longer there, and short of
finding a face to click there was no way back into sketching at all.

The planes are now offered when there is no solid yet OR while the UI is in
Sketch mode, and set_ui_mode refreshes them so they appear the moment you press
Sketch rather than at the next tree rebuild — which is not an event that pressing
Sketch causes.

Deliberately not always-on. m_dbp_active both RENDERS and picks, so leaving it
set would float three translucent planes over every finished model. Tying them to
the mode shows them exactly when they are the thing being chosen and takes them
away again on Finish.

Safe against stealing clicks: a base-plane pick is the last resort in on_mouse,
firing only on a click that hit no geometry, so solids and committed sketches
still win where they overlap.

Found on the rig by Tommaso: "if i remove a sketch, i cannot create sketches
anymore".
This commit is contained in:
Tommaso Bianchi
2026-08-13 17:36:24 +02:00
parent 81876a6ce6
commit 57b42bc059
+15 -1
View File
@@ -3964,6 +3964,10 @@ void DesignPanel::set_ui_mode(UiMode m)
m_form->FitInside();
}
update_action_bar(); // Sketch/Constrain modes show the unified ✓/✗; Feature idle hides it
// The origin planes follow the mode: entering Sketch offers them even when a body exists,
// leaving it takes them back. Without this they would only refresh on the next tree
// rebuild, which is not an event that happens when you merely press Sketch.
update_reference_planes();
}
void DesignPanel::on_shape_changed()
@@ -9510,7 +9514,17 @@ void DesignPanel::update_reference_planes()
// yet — so they persist through the 2D-sketch phase and reappear after a sketch is confirmed
// (a sketch creates no body). They no longer block selection: clicking existing geometry wins,
// a base-plane pick only fires on a click that hit nothing else (see on_mouse fall-through).
if (m_doc.bodies.empty())
// Available while there is no solid yet OR while the user is actually choosing a sketch
// plane. The second half fixes a dead end: delete a sketch on a document that still has a
// body, press Sketch, and act_sketch says "click a face or a reference plane" — with the
// reference planes already taken away, because a body existed. The instruction was
// impossible to follow and there was no way to start a sketch at all short of finding a
// face to click.
//
// Not simply always-on: m_dbp_active both RENDERS and picks, so three translucent planes
// would otherwise float over every finished model. Tying them to Sketch mode shows them
// exactly when they are the thing being chosen, and hides them again on Finish.
if (m_doc.bodies.empty() || m_ui_mode == UiMode::Sketch)
m_viewport->set_base_pick(std::move(bp), std::move(bi), std::move(bl));
else
m_viewport->clear_base_pick();