Skip to content

Commit

Permalink
Change outline update to use set_changed()
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Aug 31, 2023
1 parent 5b6e2fa commit e2b35dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
1 change: 0 additions & 1 deletion rmf_site_editor/src/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ impl Plugin for InteractionPlugin {
.with_system(update_point_visual_cues.after(maintain_selected_entities))
.with_system(update_path_visual_cues.after(maintain_selected_entities))
.with_system(update_outline_visualization.after(maintain_selected_entities))
.with_system(update_outline_for_new_meshes.after(maintain_selected_entities))
.with_system(update_highlight_visualization.after(maintain_selected_entities))
.with_system(
update_cursor_hover_visualization.after(maintain_selected_entities),
Expand Down
22 changes: 0 additions & 22 deletions rmf_site_editor/src/interaction/outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,3 @@ pub fn update_outline_visualization(
}
}
}

pub fn update_outline_for_new_meshes(
mut commands: Commands,
new_meshes: Query<Entity, Added<Handle<Mesh>>>,
outlines: Query<(&OutlineVolume, &SetOutlineDepth)>,
parents: Query<&Parent>,
) {
for e in &new_meshes {
for p in AncestorIter::new(&parents, e) {
if let Ok((outline, depth)) = outlines.get(p) {
commands
.entity(e)
.insert(OutlineBundle {
outline: outline.clone(),
..default()
})
.insert(depth.clone());
break;
}
}
}
}
22 changes: 19 additions & 3 deletions rmf_site_editor/src/site/door.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*
*/

use crate::{interaction::Selectable, shapes::*, site::*};
use crate::{
interaction::{Hovered, Selectable},
shapes::*,
site::*,
};
use bevy::{
prelude::*,
render::mesh::{Indices, PrimitiveTopology},
Expand Down Expand Up @@ -393,7 +397,13 @@ fn update_door_visuals(
pub fn update_changed_door(
mut commands: Commands,
mut doors: Query<
(Entity, &Edge<Entity>, &DoorType, &mut DoorSegments),
(
Entity,
&Edge<Entity>,
&DoorType,
&mut DoorSegments,
&mut Hovered,
),
Or<(Changed<Edge<Entity>>, Changed<DoorType>)>,
>,
anchors: AnchorParams,
Expand All @@ -402,7 +412,8 @@ pub fn update_changed_door(
mut mesh_assets: ResMut<Assets<Mesh>>,
assets: Res<SiteAssets>,
) {
for (entity, edge, kind, mut segments) in &mut doors {
for (entity, edge, kind, mut segments, mut hovered) in &mut doors {
let old_door_count = segments.body.entities().len();
if let Some(new_body) = update_door_visuals(
&mut commands,
entity,
Expand All @@ -416,6 +427,11 @@ pub fn update_changed_door(
&assets,
) {
segments.body = new_body;
if segments.body.entities().len() > old_door_count {
// A new door was spawned, trigger hovered change detection to update the outline
// for the new mesh
hovered.set_changed();
}
}
}
}
Expand Down

0 comments on commit e2b35dd

Please sign in to comment.