diff --git a/src/app/commands/layerprops.rs b/src/app/commands/layerprops.rs index 9c222b6fd..d0e2e8d97 100644 --- a/src/app/commands/layerprops.rs +++ b/src/app/commands/layerprops.rs @@ -343,6 +343,7 @@ impl OpenCADStudio { self.tabs[i].active_cmd = Some(Box::new(picker)); } Some((handle, pick)) => { + self.tabs[i].scene.restore_solid_models(&[handle]); let built = self.tabs[i] .scene .solid_models diff --git a/src/command.rs b/src/command.rs index 0ba7f8953..63c3d0e6e 100644 --- a/src/command.rs +++ b/src/command.rs @@ -384,6 +384,10 @@ impl CadCommand for UcsPickCommand { true } + fn entity_pick_includes_fills(&self) -> bool { + self.face + } + fn entity_pick_uses_surface_point(&self) -> bool { self.face } diff --git a/tests/ucs_face_plane.rs b/tests/ucs_face_plane.rs index be62fb000..b840d2984 100644 --- a/tests/ucs_face_plane.rs +++ b/tests/ucs_face_plane.rs @@ -78,3 +78,30 @@ fn the_curved_side_is_not_offered_as_a_plane() { ); } } + +#[test] +fn ucs_pick_command_enables_solid_face_picking() { + use OpenCADStudio::command::{CadCommand, CmdResult, UcsPickCommand}; + use glam::DVec3; + + let cmd_face = UcsPickCommand { face: true }; + assert!(cmd_face.needs_entity_pick(), "UCS FACE needs entity pick"); + assert!(cmd_face.entity_pick_includes_fills(), "UCS FACE must include fills to raycast solid faces"); + assert!(cmd_face.entity_pick_uses_surface_point(), "UCS FACE must use 3D surface point"); + assert!(cmd_face.entity_pick_highlights_hover(), "UCS FACE must highlight hovered solid face"); + + let cmd_obj = UcsPickCommand { face: false }; + assert!(cmd_obj.needs_entity_pick()); + assert!(!cmd_obj.entity_pick_includes_fills(), "UCS OBJECT operates on curves, not fills"); + assert!(!cmd_obj.entity_pick_uses_surface_point()); + + let handle = codec::Handle::new(0x2A); + let pt = DVec3::new(10.5, 20.25, 30.125); + let mut cmd = cmd_face; + match cmd.on_entity_pick(handle, pt) { + CmdResult::Dispatch(cmd_str) => { + assert_eq!(cmd_str, "UCS FACE 2A 10.5,20.25,30.125"); + } + _ => panic!("Expected CmdResult::Dispatch"), + } +}