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.
This commit is contained in:
John 2024-07-22 20:07:21 +01:00 committed by GitHub
parent 8f5345573c
commit d1f4262d7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,7 +53,7 @@ pub fn propagate_transforms(
>,
mut orphaned: RemovedComponents<Parent>,
transform_query: Query<(Ref<Transform>, &mut GlobalTransform, Option<&Children>), With<Parent>>,
parent_query: Query<(Entity, Ref<Parent>)>,
parent_query: Query<(Entity, Ref<Parent>), With<GlobalTransform>>,
mut orphaned_entities: Local<Vec<Entity>>,
) {
orphaned_entities.clear();
@ -114,7 +114,7 @@ unsafe fn propagate_recursive(
(Ref<Transform>, &mut GlobalTransform, Option<&Children>),
With<Parent>,
>,
parent_query: &Query<(Entity, Ref<Parent>)>,
parent_query: &Query<(Entity, Ref<Parent>), With<GlobalTransform>>,
entity: Entity,
mut changed: bool,
) {