Skip to content

Commit

Permalink
enable change detection for hierarchy maintenance (#2411)
Browse files Browse the repository at this point in the history
# Objective

Noticed a comment saying changed detection should be enabled for hierarchy maintenance once stable

Fixes #891


## Solution

Added `Changed<Parent>` filter on the query
  • Loading branch information
mockersf committed Sep 27, 2021
1 parent d158e08 commit fb0aa8d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::components::*;
use bevy_ecs::{
entity::Entity,
prelude::Changed,
query::Without,
system::{Commands, Query},
};
Expand All @@ -10,9 +11,7 @@ use smallvec::SmallVec;
pub fn parent_update_system(
mut commands: Commands,
removed_parent_query: Query<(Entity, &PreviousParent), Without<Parent>>,
// The next query could be run with a Changed<Parent> 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 parent_query: Query<(Entity, &Parent, Option<&mut PreviousParent>), Changed<Parent>>,
mut children_query: Query<&mut Children>,
) {
// Entities with a missing `Parent` (ie. ones that have a `PreviousParent`), remove
Expand Down

0 comments on commit fb0aa8d

Please sign in to comment.