From 4d90c9137244e7e31b7c659a31886f4a49f167b7 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Fri, 11 Sep 2026 10:34:22 +0300 Subject: [PATCH] Validate wipeout boundary before asking to erase its source --- src/modules/draw/draw/wipeout.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/draw/draw/wipeout.rs b/src/modules/draw/draw/wipeout.rs index d9b689958..1ea1c4d26 100644 --- a/src/modules/draw/draw/wipeout.rs +++ b/src/modules/draw/draw/wipeout.rs @@ -30,6 +30,7 @@ pub struct WipeoutCommand { plane: WorkingPlane, selected_polyline: Option, frame_mode: i16, + picked_entity: Option, } #[derive(Clone, Copy, PartialEq)] @@ -50,6 +51,7 @@ impl WipeoutCommand { plane: WorkingPlane::default(), selected_polyline: None, frame_mode: frame_mode.clamp(0, 2), + picked_entity: None, } } @@ -61,6 +63,7 @@ impl WipeoutCommand { plane: WorkingPlane::default(), selected_polyline: None, frame_mode: 1, + picked_entity: None, } } @@ -73,6 +76,7 @@ impl WipeoutCommand { plane: WorkingPlane::default(), selected_polyline: None, frame_mode: 1, + picked_entity: None, } } @@ -238,6 +242,15 @@ impl CadCommand for WipeoutCommand { } fn on_entity_pick(&mut self, handle: Handle, _point: DVec3) -> CmdResult { + let Some(entity)=self.picked_entity.take().filter(|e|e.common().handle==handle) else { + return CmdResult::NeedPoint; + }; + if !matches!(entity,EntityType::LwPolyline(_)|EntityType::Polyline2D(_)) { + return CmdResult::NeedPoint; + } + if wipeout_from_polyline(&entity).is_none() { + return CmdResult::Measurement("WIPEOUT: select a closed planar polyline made of zero-width straight segments.".into()); + } if handle.is_null() { CmdResult::NeedPoint } else { @@ -247,6 +260,9 @@ impl CadCommand for WipeoutCommand { } } + fn inject_before_entity_pick(&self)->bool {self.mode==WipeoutMode::Polyline} + fn inject_picked_entity(&mut self,entity:EntityType){self.picked_entity=Some(entity);} + fn wants_text_input(&self) -> bool { matches!( self.mode,