Skip to content

Commit

Permalink
Optimize outline update for new meshes
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
  • Loading branch information
luca-della-vedova committed Jun 23, 2023
1 parent 2d567db commit 5461c93
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions rmf_site_editor/src/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ 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_cursor_hover_visualization.after(maintain_selected_entities),
)
Expand Down
24 changes: 23 additions & 1 deletion rmf_site_editor/src/interaction/outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn update_outline_visualization(
mut commands: Commands,
outlinable: Query<
(Entity, &Hovered, &Selected, &OutlineVisualization),
Or<(Changed<Hovered>, Changed<Selected>, Changed<Children>)>,
Or<(Changed<Hovered>, Changed<Selected>)>,
>,
descendants: Query<(Option<&Children>, Option<&ComputedVisualCue>)>,
) {
Expand Down Expand Up @@ -185,3 +185,25 @@ 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;
}
}
}
}

0 comments on commit 5461c93

Please sign in to comment.