From 28fe5fdb432e9eef19be53a93ce572f27c6cee87 Mon Sep 17 00:00:00 2001 From: Colin Faulkingham Date: Sun, 25 Oct 2026 01:25:29 +0000 Subject: [PATCH] Extrude: accept manually selected target planes (#4974) (#6030) * claim: #4974 * fix(ui): accept manual extrude plane targets (#4974) --- crates/ui-egui/src/dialogs.rs | 12 +++++------- .../ui-egui/src/extrude_auto_to_object_tests.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 1a13ff751..2031a062d 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -1209,15 +1209,13 @@ impl Dialog { inp.accepts(h, |body, face| snap.and_then(|f| f.planar(body, face)).unwrap_or_else(|| planar_face(s, body, face).is_some())) } - /// Extrude's automatic To Object: with profiles picked, a face or vertex off their plane, or - /// a plane parallel to it, is the object to extrude to rather than another profile. While the - /// To Object input is active, a parallel plane is taken too (as a place on it). + /// With automatic To Object enabled and profiles picked, a face or vertex off their plane, + /// or a parallel plane, is the target rather than another profile. An explicitly active + /// To Object input accepts parallel planes regardless of the automatic switching preference. fn extrude_target(&self, s: &Session, h: &Hit) -> Option { - if !matches!(self.kind, Kind::Extrude { thin: false, smart: crate::smart_extrude::Smart { auto_to_object: true, .. }, .. }) { - return None; - } + let Kind::Extrude { thin: false, smart, .. } = &self.kind else { return None }; let to_active = self.active_input().is_some_and(|i| i.label == TO_OBJECT); - if self.active != 0 && !to_active { + if !to_active && (self.active != 0 || !smart.auto_to_object) { return None; } let reference = profile_plane(s, self.inputs.first()?.items.first()?)?; diff --git a/crates/ui-egui/src/extrude_auto_to_object_tests.rs b/crates/ui-egui/src/extrude_auto_to_object_tests.rs index d1f894b64..757d89e0f 100644 --- a/crates/ui-egui/src/extrude_auto_to_object_tests.rs +++ b/crates/ui-egui/src/extrude_auto_to_object_tests.rs @@ -194,3 +194,18 @@ fn off_by_default_a_face_off_the_profile_plane_joins_the_profiles() { assert!(!click(&mut h, |_| Hit::Plane { name: "Lid".into(), point: Vec3::new(5.0, 5.0, 25.0) })); assert!(to_object(dialog(&h)).is_none()); } + +#[test] +fn manual_to_object_accepts_a_parallel_plane_with_automatic_switching_off() { + let mut h = scene_with(false); + h.step(&json!({"click": {"handle": "dialog:Extent Type"}})).unwrap(); + h.step(&json!({"click": {"handle": "dialog:Extent Type:To Object"}})).unwrap(); + assert_eq!(dialog(&h).active_input().unwrap().label, "To Object"); + assert!(!click(&mut h, |_| Hit::Plane { name: "YZ".into(), point: Vec3::new(0.0, 5.0, 5.0) })); + assert!(!click(&mut h, |_| Hit::Plane { name: "XY".into(), point: Vec3::new(5.0, 5.0, 0.0) })); + assert!(to_object(dialog(&h)).is_none()); + assert!(click(&mut h, |_| Hit::Plane { name: "Lid".into(), point: Vec3::new(5.0, 5.0, 25.0) })); + let commands = apply_commands(&h.app, dialog(&h)).unwrap(); + assert_eq!(commands[0].1["to"], json!([0.0, 0.0, 25.0])); + assert!((solidcraft_engine::extrude_reach(&h.app.session, &commands[0].1).unwrap() - 25.0).abs() < 1e-9); +}