Extrude: accept manually selected target planes (#4974) (#6030)

* claim: #4974

* fix(ui): accept manual extrude plane targets (#4974)
This commit is contained in:
Colin Faulkingham
2026-10-25 01:25:29 +00:00
committed by GitHub
parent 26c9d1c445
commit 28fe5fdb43
2 changed files with 20 additions and 7 deletions
+5 -7
View File
@@ -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<Sel> {
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()?)?;
@@ -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);
}