mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
try_insert Aabbs (#10801)
# Objective avoid panics from `calculate_bounds` systems if entities are despawned in PostUpdate. there's a running general discussion (#10166) about command panicking. in the meantime we may as well fix up some cases where it's clear a failure to insert is safe. ## Solution change `.insert(aabb)` to `.try_insert(aabb)`
This commit is contained in:
parent
220b08d379
commit
960af2b2c9
2 changed files with 4 additions and 4 deletions
|
@ -269,7 +269,7 @@ pub fn calculate_bounds(
|
|||
for (entity, mesh_handle) in &without_aabb {
|
||||
if let Some(mesh) = meshes.get(mesh_handle) {
|
||||
if let Some(aabb) = mesh.compute_aabb() {
|
||||
commands.entity(entity).insert(aabb);
|
||||
commands.entity(entity).try_insert(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ pub fn calculate_bounds_2d(
|
|||
for (entity, mesh_handle) in &meshes_without_aabb {
|
||||
if let Some(mesh) = meshes.get(&mesh_handle.0) {
|
||||
if let Some(aabb) = mesh.compute_aabb() {
|
||||
commands.entity(entity).insert(aabb);
|
||||
commands.entity(entity).try_insert(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ pub fn calculate_bounds_2d(
|
|||
center: (-sprite.anchor.as_vec() * size).extend(0.0).into(),
|
||||
half_extents: (0.5 * size).extend(0.0).into(),
|
||||
};
|
||||
commands.entity(entity).insert(aabb);
|
||||
commands.entity(entity).try_insert(aabb);
|
||||
}
|
||||
}
|
||||
for (entity, atlas_sprite, atlas_handle) in &atlases_without_aabb {
|
||||
|
@ -158,7 +158,7 @@ pub fn calculate_bounds_2d(
|
|||
center: (-atlas_sprite.anchor.as_vec() * size).extend(0.0).into(),
|
||||
half_extents: (0.5 * size).extend(0.0).into(),
|
||||
};
|
||||
commands.entity(entity).insert(aabb);
|
||||
commands.entity(entity).try_insert(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue