enable change detection for hierarchy maintenance (#2411)
# 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
This commit is contained in:
parent
d158e0893e
commit
fb0aa8d286
@ -1,6 +1,7 @@
|
|||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
|
prelude::Changed,
|
||||||
query::Without,
|
query::Without,
|
||||||
system::{Commands, Query},
|
system::{Commands, Query},
|
||||||
};
|
};
|
||||||
@ -10,9 +11,7 @@ use smallvec::SmallVec;
|
|||||||
pub fn parent_update_system(
|
pub fn parent_update_system(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
removed_parent_query: Query<(Entity, &PreviousParent), Without<Parent>>,
|
removed_parent_query: Query<(Entity, &PreviousParent), Without<Parent>>,
|
||||||
// The next query could be run with a Changed<Parent> filter. However, this would mean that
|
mut parent_query: Query<(Entity, &Parent, Option<&mut PreviousParent>), Changed<Parent>>,
|
||||||
// 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>,
|
mut children_query: Query<&mut Children>,
|
||||||
) {
|
) {
|
||||||
// Entities with a missing `Parent` (ie. ones that have a `PreviousParent`), remove
|
// Entities with a missing `Parent` (ie. ones that have a `PreviousParent`), remove
|
||||||
|
Loading…
Reference in New Issue
Block a user