Extrude: with every body hidden, a new extrude stays New Body instead of turning to Cut (#9919) (#9920)

* claim: #9919

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Extrude: with every body hidden, a new extrude stays New Body instead of turning to Cut (#9919)

Smart Extrude passed the shown bodies as `participants` to keep hidden
ones out (#6901), but with none shown that list was empty, and the
engine reads an empty list as the whole scope: a profile on a hidden
body chose Cut, which has no shown body to change, so nothing was
previewed and OK did nothing. With no body shown it now chooses New
Body.

The operation it latches for a side is also decided again when a body
is shown or hidden while the window is open, as a new start already
does (#467): showing the body an extrude goes into turns it to Cut,
hiding it again back to New Body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
N3MI-DG
2026-10-31 09:16:30 +00:00
committed by GitHub
parent c4f9269409
commit 6b24775413
3 changed files with 44 additions and 4 deletions
+16 -3
View File
@@ -3027,20 +3027,33 @@ fn auto_operation(app: &SolveApp, d: &mut Dialog) {
smart.start = start;
smart.latch = None;
}
// Showing or hiding a body changes what the extrude meets: the latch was decided among the
// bodies shown before (#9919).
let shown = solidcraft_engine::shown_scope(&app.session);
if let Kind::Extrude { smart, .. } = &mut d.kind
&& smart.shown != shown
{
smart.shown = shown.clone();
smart.latch = None;
}
// To an object, the extrude goes to it on whichever side it is: that is the side (#1633).
if params.get("to").is_some()
&& let Some(reach) = solidcraft_engine::extrude_reach(&app.session, &params)
{
side = crate::smart_extrude::side(reach, 0);
}
// Hidden bodies are out of its scope (#6901).
// Hidden bodies are out of its scope (#6901). With none shown there is nothing to join or
// cut: an empty `participants` would read as every body, hidden ones too (#9919).
let mut params = params;
if let Some(shown) = solidcraft_engine::shown_scope(&app.session)
let mut nothing_shown = false;
if let Some(shown) = shown
&& params.get("participants").is_none()
{
nothing_shown = shown.is_empty();
params["participants"] = json!(shown);
}
let Some(fresh) = solidcraft_engine::auto_operation(&app.session, &params).and_then(|op| OPS.iter().position(|o| *o == op)) else {
let fresh = if nothing_shown { Some("new") } else { solidcraft_engine::auto_operation(&app.session, &params) };
let Some(fresh) = fresh.and_then(|op| OPS.iter().position(|o| *o == op)) else {
return;
};
if let Kind::Extrude { operation, smart, .. } = &mut d.kind {
+23
View File
@@ -214,6 +214,29 @@ fn hidden_bodies_take_no_part() {
assert_eq!(op(&mut h), NEW);
}
#[test]
fn into_a_hidden_body_with_nothing_shown_is_a_new_body_until_it_is_shown() {
// The profile on the hidden cube's base, extruded into it (#9919).
let mut h = cube();
h.app.run("browser.visibility", json!({"items": ["Base"], "visible": false})).unwrap();
rect_sketch(&mut h, [0.0, 0.0], [10.0, 10.0]);
h.step(&json!({"start": "solid.extrude"})).unwrap();
checked(&mut h);
assert_eq!(op(&mut h), NEW, "nothing shown to cut");
let preview = h.app.dialog.as_ref().map(|d| crate::dialogs::apply_commands(&h.app, d));
assert!(preview.is_some_and(|c| c.is_ok_and(|c| !c.is_empty())), "the extrude runs");
// Shown while the window is open: the extrude goes into it, a Cut.
h.app.run("browser.visibility", json!({"items": ["Base"], "visible": true})).unwrap();
checked(&mut h);
assert_eq!(op(&mut h), CUT, "the shown cube is cut");
// Hidden again: New Body again.
h.app.run("browser.visibility", json!({"items": ["Base"], "visible": false})).unwrap();
checked(&mut h);
assert_eq!(op(&mut h), NEW);
ok(&mut h);
assert_eq!(bodies(&h).len(), 2, "{:?}", bodies(&h));
}
#[test]
fn an_edited_feature_keeps_its_operation() {
let mut h = cube();
+5 -1
View File
@@ -11,7 +11,9 @@
//! one that starts as a Join does not turn into a Cut when it reaches another body. When
//! the distance passes through zero onto the other side (a drag reversed past the start, or
//! Reverse), the operation is decided afresh for that side and latched there. So is a new
//! start (From Object, a start offset): it moves the extrude to other bodies (#467). A zero
//! start (From Object, a start offset): it moves the extrude to other bodies (#467), and
//! so is a body shown or hidden while the window is open (#9919). With no body shown it is a
//! New Body: there is nothing to join or cut. A zero
//! distance changes nothing. Choosing an operation by hand ends the automatic choice for
//! the rest of the extrude.
@@ -31,6 +33,8 @@ pub struct Smart {
pub target: Option<Sel>,
/// Where the extrude starts (its From Object and start offset) when the latch was decided.
pub start: serde_json::Value,
/// The bodies shown when the latch was decided (None: every one), as `shown_scope` gives them.
pub shown: Option<Vec<String>>,
/// Picks off the profile plane become the To Object target (Preferences › Design).
pub auto_to_object: bool,
}