From de5ff0aa5ae5933e008023614f537d416e475c2c Mon Sep 17 00:00:00 2001 From: SvenTS <73037851+SvenTS@users.noreply.github.com> Date: Thu, 26 Nov 2020 02:33:59 +0100 Subject: [PATCH] Remove Changed from parent update system (#907) System has to check for actual change of the value anyway. This way, children inserted after postupdate get synced in the next frame and are not lost. --- .../src/hierarchy/hierarchy_maintenance_system.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs index 6073300001..5eea65682e 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs @@ -1,15 +1,14 @@ use crate::components::*; -use bevy_ecs::{Changed, Commands, Entity, Query, Without}; +use bevy_ecs::{Commands, Entity, Query, Without}; use bevy_utils::HashMap; use smallvec::SmallVec; pub fn parent_update_system( commands: &mut Commands, removed_parent_query: Query<(Entity, &PreviousParent), Without>, - mut changed_parent_query: Query< - (Entity, &Parent, Option<&mut PreviousParent>), - Changed, - >, + // The next query could be run with a Changed filter. However, this would mean that modifications later in the frame are lost. + // See issue 891: https://github.com/bevyengine/bevy/issues/891 + mut parent_query: Query<(Entity, &Parent, Option<&mut PreviousParent>)>, mut children_query: Query<&mut Children>, ) { // Entities with a missing `Parent` (ie. ones that have a `PreviousParent`), remove @@ -25,7 +24,7 @@ pub fn parent_update_system( let mut children_additions = HashMap::>::default(); // Entities with a changed Parent (that also have a PreviousParent, even if None) - for (entity, parent, possible_previous_parent) in changed_parent_query.iter_mut() { + for (entity, parent, possible_previous_parent) in parent_query.iter_mut() { if let Some(mut previous_parent) = possible_previous_parent { // New and previous point to the same Entity, carry on, nothing to see here. if previous_parent.0 == parent.0 {