Skip to content

Commit

Permalink
Despawn with children doesn't need to remove entities from parents ch…
Browse files Browse the repository at this point in the history
…ildren when parents are also removed (#2278)

Fixes #2274 

When calling `despawn_recursive`, the recursive loop doesn't need to remove the entity from the children list of its parent when the parent will also be deleted

Upside:
* Removes two entity lookup per entity being recursively despawned

Downside:
* The change detection on the `Children` component of a deleted entity in the despawned hierarchy will not be triggered
  • Loading branch information
mockersf committed May 30, 2021
1 parent 040ad7f commit 08e5939
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_transform/src/hierarchy/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn despawn_with_children_recursive(world: &mut World, entity: Entity) {
fn despawn_with_children_recursive_inner(world: &mut World, entity: Entity) {
if let Some(mut children) = world.get_mut::<Children>(entity) {
for e in std::mem::take(&mut children.0) {
despawn_with_children_recursive(world, e);
despawn_with_children_recursive_inner(world, e);
}
}

Expand Down

0 comments on commit 08e5939

Please sign in to comment.