From 205d3ec38fbc22a2b3d002ba539846f1c3446ad3 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 27 Aug 2024 15:00:52 +0800 Subject: [PATCH] Fix filtering for fiducial anchor selection Signed-off-by: Michael X. Grey --- .../src/interaction/select/select_anchor.rs | 87 +++++++++++++++---- rmf_site_editor/src/site/fiducial.rs | 20 +++-- .../src/widgets/inspector/inspect_fiducial.rs | 9 +- 3 files changed, 91 insertions(+), 25 deletions(-) diff --git a/rmf_site_editor/src/interaction/select/select_anchor.rs b/rmf_site_editor/src/interaction/select/select_anchor.rs index 01c41d14..5e30f42b 100644 --- a/rmf_site_editor/src/interaction/select/select_anchor.rs +++ b/rmf_site_editor/src/interaction/select/select_anchor.rs @@ -18,8 +18,8 @@ use bevy::prelude::*; use bevy_impulse::*; -use crate::interaction::select::*; -use rmf_site_format::{Fiducial, Floor, Location, Path, Point}; +use crate::{site::CurrentLevel, interaction::select::*}; +use rmf_site_format::{Fiducial, Floor, Location, Path, Point, LevelElevation}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Resource)] pub enum AnchorScope { @@ -407,6 +407,7 @@ pub fn anchor_selection_setup>( mut current_anchor_scope: ResMut, mut cursor: ResMut, mut highlight: ResMut, + mut gizmo_blockers: ResMut, ) -> SelectionNodeResult where State: 'static + Send + Sync, @@ -436,6 +437,7 @@ where } highlight.0 = true; + gizmo_blockers.selecting = true; *current_anchor_scope = *scope; @@ -453,6 +455,7 @@ pub fn cleanup_anchor_selection( mut hidden_anchors: ResMut, mut anchor_scope: ResMut, mut highlight: ResMut, + mut gizmo_blockers: ResMut, ) { cursor.remove_mode(SELECT_ANCHOR_MODE_LABEL, &mut visibility); set_visibility(cursor.site_anchor_placement, &mut visibility, false); @@ -462,6 +465,7 @@ pub fn cleanup_anchor_selection( } highlight.0 = false; + gizmo_blockers.selecting = false; *anchor_scope = AnchorScope::General; } @@ -509,29 +513,24 @@ pub struct AnchorFilter<'w, 's> { commands: Commands<'w, 's>, current_drawing: Res<'w, CurrentEditDrawing>, drawings: Query<'w, 's, &'static PixelsPerMeter, With>, + parents: Query<'w, 's, &'static Parent>, + levels: Query<'w, 's, (), With>, + current_level: Res<'w, CurrentLevel>, } impl<'w, 's> SelectionFilter for AnchorFilter<'w, 's> { fn filter_pick(&mut self, select: Entity) -> Option { self.inspect.filter_pick(select).and_then(|e| { - if self.anchors.contains(e) { - Some(e) - } else { - None - } + self.filter_target(e) }) } fn filter_select(&mut self, target: Entity) -> Option { - if self.anchors.contains(target) { - Some(target) - } else { - None - } + self.filter_target(target) } fn on_click(&mut self, hovered: Hover) -> Option