From 64e323c3449f9be0b80d0879be762c9767eb09ad Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 14 Jul 2023 15:30:26 +0800 Subject: [PATCH] Fix panic when updating model sources Signed-off-by: Luca Della Vedova --- rmf_site_editor/src/aabb.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rmf_site_editor/src/aabb.rs b/rmf_site_editor/src/aabb.rs index 09fa995f..1fa2e77f 100644 --- a/rmf_site_editor/src/aabb.rs +++ b/rmf_site_editor/src/aabb.rs @@ -88,7 +88,7 @@ pub fn update_bounds( meshes: Res>, mut mesh_reassigned: Query<(Entity, &Handle, &mut Aabb), Changed>>, mut entity_mesh_map: ResMut, - mut mesh_events: EventReader>, + //mut mesh_events: EventReader>, entities_lost_mesh: RemovedComponents>, ) { for entity in entities_lost_mesh.iter() { @@ -105,6 +105,15 @@ pub fn update_bounds( } } + // Note (luca) This has been removed since entity despawns are not caught to cleanup the + // entity_mesh_map and there is a possibility of panic in case we try to add an aabb to an + // entity that has since been despawned (i.e. when updating models' AssetSource and their scene + // is despawned). + // Tracking issue here with the details https://github.com/open-rmf/rmf_site/issues/145 + // It seems we don't currently change meshes themselves outside of the model systems that cause + // the panic, with the general pattern in the editor being to reassign new handles + // so this event is never created anyway + /* let to_update = |event: &AssetEvent| { let handle = match event { AssetEvent::Modified { handle } => handle, @@ -120,6 +129,7 @@ pub fn update_bounds( commands.entity(*entity).insert(aabb.clone()); } } + */ } pub struct AabbUpdatePlugin;