Skip to content

Commit

Permalink
Fix panic when updating model sources
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 Jul 14, 2023
1 parent 3697662 commit 64e323c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rmf_site_editor/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn update_bounds(
meshes: Res<Assets<Mesh>>,
mut mesh_reassigned: Query<(Entity, &Handle<Mesh>, &mut Aabb), Changed<Handle<Mesh>>>,
mut entity_mesh_map: ResMut<EntityMeshMap>,
mut mesh_events: EventReader<AssetEvent<Mesh>>,
//mut mesh_events: EventReader<AssetEvent<Mesh>>,
entities_lost_mesh: RemovedComponents<Handle<Mesh>>,
) {
for entity in entities_lost_mesh.iter() {
Expand All @@ -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<Mesh>| {
let handle = match event {
AssetEvent::Modified { handle } => handle,
Expand All @@ -120,6 +129,7 @@ pub fn update_bounds(
commands.entity(*entity).insert(aabb.clone());
}
}
*/
}

pub struct AabbUpdatePlugin;
Expand Down

0 comments on commit 64e323c

Please sign in to comment.