Skip to content

Commit d1f4262

Browse files
authored
Only propagate transforms entities with GlobalTransforms. (#14384)
# Objective Fixes a performance issue when you have 1000s of entities in a bevy hierarchy without transforms. This was prominently happening in `bevy_ecs_tilemap`. ## Solution Filter out entities that don't have a global transform. ## Testing CI We should test some other way... ## Migration Guide - To avoid surprising performance pitfalls, `Transform` / `GlobalTransform` propagation is no longer performed down through hierarchies where intermediate parent are missing a `GlobalTransform`. To restore the previous behavior, add `GlobalTransform::default` to intermediate entities.
1 parent 8f53455 commit d1f4262

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_transform/src/systems.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn propagate_transforms(
5353
>,
5454
mut orphaned: RemovedComponents<Parent>,
5555
transform_query: Query<(Ref<Transform>, &mut GlobalTransform, Option<&Children>), With<Parent>>,
56-
parent_query: Query<(Entity, Ref<Parent>)>,
56+
parent_query: Query<(Entity, Ref<Parent>), With<GlobalTransform>>,
5757
mut orphaned_entities: Local<Vec<Entity>>,
5858
) {
5959
orphaned_entities.clear();
@@ -114,7 +114,7 @@ unsafe fn propagate_recursive(
114114
(Ref<Transform>, &mut GlobalTransform, Option<&Children>),
115115
With<Parent>,
116116
>,
117-
parent_query: &Query<(Entity, Ref<Parent>)>,
117+
parent_query: &Query<(Entity, Ref<Parent>), With<GlobalTransform>>,
118118
entity: Entity,
119119
mut changed: bool,
120120
) {

0 commit comments

Comments
 (0)