Skip to content

Commit 91ce046

Browse files
committed
Propagate transforms in fixed update
1 parent 66d9882 commit 91ce046

File tree

1 file changed

+21
-20
lines changed
  • crates/bevy_transform/src

1 file changed

+21
-20
lines changed

crates/bevy_transform/src/lib.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ pub enum TransformSystem {
8484
TransformPropagate,
8585
}
8686

87+
// A set for `propagate_transforms` to mark it as ambiguous with `sync_simple_transforms`.
88+
// Used instead of the `SystemTypeSet` as that would not allow multiple instances of the system.
89+
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
90+
struct PropagateTransformsSet;
91+
8792
/// The base plugin for handling [`Transform`] components
8893
#[derive(Default)]
8994
pub struct TransformPlugin;
9095

9196
impl Plugin for TransformPlugin {
9297
fn build(&self, app: &mut App) {
93-
// A set for `propagate_transforms` to mark it as ambiguous with `sync_simple_transforms`.
94-
// Used instead of the `SystemTypeSet` as that would not allow multiple instances of the system.
95-
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
96-
struct PropagateTransformsSet;
97-
9898
app.register_type::<Transform>()
9999
.register_type::<GlobalTransform>()
100100
.add_plugin(ValidParentCheckPlugin::<GlobalTransform>::default())
@@ -105,21 +105,22 @@ impl Plugin for TransformPlugin {
105105
schedule.configure_set(
106106
TransformSystem::TransformPropagate.in_base_set(StartupSet::PostStartup),
107107
);
108+
propagate_in_schedule(schedule);
108109
})
109-
// FIXME: https://github.com/bevyengine/bevy/issues/4381
110-
// These systems cannot access the same entities,
111-
// due to subtle query filtering that is not yet correctly computed in the ambiguity detector
112-
.add_startup_system(
113-
sync_simple_transforms
114-
.in_set(TransformSystem::TransformPropagate)
115-
.ambiguous_with(PropagateTransformsSet),
116-
)
117-
.add_startup_system(propagate_transforms.in_set(PropagateTransformsSet))
118-
.add_system(
119-
sync_simple_transforms
120-
.in_set(TransformSystem::TransformPropagate)
121-
.ambiguous_with(PropagateTransformsSet),
122-
)
123-
.add_system(propagate_transforms.in_set(PropagateTransformsSet));
110+
.edit_schedule(CoreSchedule::FixedUpdate, propagate_in_schedule)
111+
.edit_schedule(CoreSchedule::Main, propagate_in_schedule);
124112
}
125113
}
114+
115+
fn propagate_in_schedule(schedule: &mut Schedule) {
116+
// FIXME: https://github.com/bevyengine/bevy/issues/4381
117+
// These systems cannot access the same entities,
118+
// due to subtle query filtering that is not yet correctly computed in the ambiguity detector
119+
schedule
120+
.add_system(
121+
sync_simple_transforms
122+
.in_set(TransformSystem::TransformPropagate)
123+
.ambiguous_with(PropagateTransformsSet),
124+
)
125+
.add_system(propagate_transforms.in_set(PropagateTransformsSet));
126+
}

0 commit comments

Comments
 (0)