From 0477e0ba4e61a7d0459a851caa59af951536abeb Mon Sep 17 00:00:00 2001 From: semmelrinde <124386289+semmelrinde@users.noreply.github.com> Date: Sun, 25 Oct 2026 01:25:12 +0000 Subject: [PATCH] Shell: the dialog sends the picked face's body (#4555) (#6092) Where a body's face lies flush with another body's face, the face point alone could resolve to the other body, and Shell then refused with "select at least one face to remove". The dialog now passes the body of the picked faces, as the command already accepts. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/dialogs.rs | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index db332f230..d5466d570 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -3531,7 +3531,15 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result, S } Kind::Shell { .. } => { need(0, "faces to remove")?; - ("solid.shell", json!({"faces": face_points(0)})) + let mut p = json!({"faces": face_points(0)}); + // The picked faces' body: a point alone may name a flush face of another body (#4555). + let mut bodies = sels(d, 0).iter().filter_map(|s| if let Sel::Face { body, .. } = s { Some(body) } else { None }); + if let Some(first) = bodies.next() + && bodies.all(|b| b == first) + { + p["body"] = json!(first); + } + ("solid.shell", p) } Kind::Draft { .. } => { need(0, "faces")?; @@ -5532,3 +5540,33 @@ mod extrude_mixed_pick_tests { assert!((volume - 8000.0).abs() < 1e-6, "the box grown to 20 mm: {volume}"); } } + +#[cfg(test)] +mod shell_body_tests { + //! The Shell dialog says whose face it removes (#4555). + + use super::*; + use crate::scenario::Harness; + + /// Two boxes stacked flush: the upper one's bottom face lies in the lower one's top. Picked + /// from below with the lower box hidden, the face is the upper box's, and the dialog says so. + #[test] + fn a_face_flush_with_another_body_is_shelled_on_its_own_body() { + let mut h = Harness::new(); + h.app.run("solid.box", json!({"length":20,"width":20,"height":20,"corner":[0,0,0]})).unwrap(); + h.app.run("solid.box", json!({"length":20,"width":20,"height":10,"corner":[0,0,20],"operation":"new"})).unwrap(); + let st = h.app.session.world_state(); + let (lower, upper) = (st.bodies[0].name.to_string(), st.bodies[1].name.to_string()); + h.app.run("browser.visibility", json!({"visible":false,"items":[lower]})).unwrap(); + h.step(&json!({"call":"ui.view","params":{"view":"bottom"}})).unwrap(); + h.settle(); + h.step(&json!({"start":"solid.shell"})).unwrap(); + h.step(&json!({"click":{"world":[10,10,20]}})).unwrap(); + h.frames(2); + let d = h.app.dialog.as_ref().expect("the shell dialog"); + let commands = dialog_commands(&h.app, d).unwrap(); + let (cmd, p) = commands.first().unwrap(); + assert_eq!(cmd, "solid.shell"); + assert_eq!(p["body"], json!(upper), "{p}"); + } +}