Skip to content

Commit 08e5939

Browse files
committed
Despawn with children doesn't need to remove entities from parents children 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
1 parent 040ad7f commit 08e5939

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/bevy_transform/src/hierarchy/hierarchy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn despawn_with_children_recursive(world: &mut World, entity: Entity) {
2727
fn despawn_with_children_recursive_inner(world: &mut World, entity: Entity) {
2828
if let Some(mut children) = world.get_mut::<Children>(entity) {
2929
for e in std::mem::take(&mut children.0) {
30-
despawn_with_children_recursive(world, e);
30+
despawn_with_children_recursive_inner(world, e);
3131
}
3232
}
3333

0 commit comments

Comments
 (0)