Skip to content

Commit

Permalink
Improve system schedules (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz authored Sep 20, 2024
1 parent b08ea09 commit 3cf2b93
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions src/plugin/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,46 @@ where
match set {
PhysicsSet::SyncBackend => (
// Run the character controller before the manual transform propagation.
systems::update_character_controls,
systems::update_character_controls.in_set(PhysicsSet::SyncBackend),
// Run Bevy transform propagation additionally to sync [`GlobalTransform`]
(
bevy::transform::systems::sync_simple_transforms,
bevy::transform::systems::propagate_transforms,
)
.chain()
.in_set(RapierTransformPropagateSet),
systems::on_add_entity_with_parent,
systems::on_change_world,
systems::sync_removals,
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_scene_colliders,
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_colliders,
systems::init_rigid_bodies,
systems::init_colliders,
systems::init_joints,
systems::apply_scale,
systems::apply_collider_user_changes,
systems::apply_rigid_body_user_changes,
systems::apply_joint_user_changes,
systems::apply_initial_rigid_body_impulses,
(
systems::on_add_entity_with_parent,
systems::on_change_world,
systems::sync_removals,
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_scene_colliders,
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_colliders,
systems::init_rigid_bodies,
systems::init_colliders,
systems::init_joints,
systems::apply_scale,
systems::apply_collider_user_changes,
systems::apply_rigid_body_user_changes,
systems::apply_joint_user_changes,
systems::apply_initial_rigid_body_impulses,
)
.chain()
.in_set(PhysicsSet::SyncBackend),
)
.chain()
.into_configs(),
PhysicsSet::StepSimulation => (systems::step_simulation::<PhysicsHooks>).into_configs(),
PhysicsSet::StepSimulation => (systems::step_simulation::<PhysicsHooks>)
.in_set(PhysicsSet::StepSimulation)
.into_configs(),
PhysicsSet::Writeback => (
systems::update_colliding_entities,
systems::writeback_rigid_bodies,
systems::writeback_mass_properties,
// Each writeback write to different properties.
systems::writeback_mass_properties.ambiguous_with(systems::writeback_rigid_bodies),
)
.in_set(PhysicsSet::Writeback)
.into_configs(),
}
}
Expand Down Expand Up @@ -244,14 +252,17 @@ where
.chain()
.before(TransformSystem::TransformPropagate),
);
app.configure_sets(
self.schedule,
RapierTransformPropagateSet.in_set(PhysicsSet::SyncBackend),
);

app.add_systems(
self.schedule,
(
Self::get_systems(PhysicsSet::SyncBackend).in_set(PhysicsSet::SyncBackend),
Self::get_systems(PhysicsSet::StepSimulation)
.in_set(PhysicsSet::StepSimulation),
Self::get_systems(PhysicsSet::Writeback).in_set(PhysicsSet::Writeback),
Self::get_systems(PhysicsSet::SyncBackend),
Self::get_systems(PhysicsSet::StepSimulation),
Self::get_systems(PhysicsSet::Writeback),
),
);
app.init_resource::<TimestepMode>();
Expand Down

0 comments on commit 3cf2b93

Please sign in to comment.