Skip to content

Commit

Permalink
Merge pull request #409 from Aceeri/apply-scale-ordering
Browse files Browse the repository at this point in the history
Clean up `SyncBackend` SystemConfigs, apply scale after `init_colliders`
  • Loading branch information
sebcrozet authored Aug 6, 2023
2 parents 9f372db + 9ee4610 commit c5d12af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 36 deletions.
3 changes: 0 additions & 3 deletions bevy_rapier2d/examples/custom_system_setup2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fn main() {
PostUpdate,
(
PhysicsSet::SyncBackend,
PhysicsSet::SyncBackendFlush,
PhysicsSet::StepSimulation,
PhysicsSet::Writeback,
)
Expand All @@ -33,8 +32,6 @@ fn main() {
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_set(PhysicsSet::SyncBackend),
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackendFlush)
.in_set(PhysicsSet::SyncBackendFlush),
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation),
despawn_one_box,
Expand Down
3 changes: 0 additions & 3 deletions bevy_rapier3d/examples/custom_system_setup3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fn main() {
PostUpdate,
(
PhysicsSet::SyncBackend,
PhysicsSet::SyncBackendFlush,
PhysicsSet::StepSimulation,
PhysicsSet::Writeback,
)
Expand All @@ -33,8 +32,6 @@ fn main() {
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_set(PhysicsSet::SyncBackend),
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackendFlush)
.in_set(PhysicsSet::SyncBackendFlush),
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation),
despawn_one_box,
Expand Down
41 changes: 15 additions & 26 deletions src/plugin/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,25 @@ where
bevy::transform::systems::propagate_transforms,
)
.chain()
.after(systems::update_character_controls)
.in_set(RapierTransformPropagateSet),
systems::init_async_colliders.after(RapierTransformPropagateSet),
systems::apply_scale.after(systems::init_async_colliders),
systems::apply_collider_user_changes.after(systems::apply_scale),
systems::apply_rigid_body_user_changes.after(systems::apply_collider_user_changes),
systems::apply_joint_user_changes.after(systems::apply_rigid_body_user_changes),
systems::init_rigid_bodies.after(systems::apply_joint_user_changes),
systems::init_colliders
.after(systems::init_rigid_bodies)
.after(systems::init_async_colliders),
systems::init_joints.after(systems::init_colliders),
systems::apply_initial_rigid_body_impulses
.after(systems::init_colliders)
.ambiguous_with(systems::init_joints),
systems::sync_removals
.after(systems::init_joints)
.after(systems::apply_initial_rigid_body_impulses),
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_scene_colliders
.after(bevy::scene::scene_spawner_system)
.before(systems::init_async_colliders),
systems::init_async_scene_colliders.after(bevy::scene::scene_spawner_system),
#[cfg(all(feature = "dim3", feature = "async-collider"))]
systems::init_async_colliders,
systems::init_rigid_bodies,
systems::init_colliders,
systems::init_joints,
systems::sync_removals,
// Run this here so the folowwing systems do not have a 1 frame delay.
apply_deferred,
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()
.into_configs(),
PhysicsSet::SyncBackendFlush => (apply_deferred,).into_configs(),
PhysicsSet::StepSimulation => (
systems::step_simulation::<PhysicsHooks>,
Events::<CollisionEvent>::update_system
Expand Down Expand Up @@ -152,8 +146,6 @@ pub enum PhysicsSet {
/// initializing) backend data structures with current component state.
/// These systems typically run at the after [`CoreSet::Update`].
SyncBackend,
/// The copy of [`apply_system_buffers`] that runs immediately after [`PhysicsSet::SyncBackend`].
SyncBackendFlush,
/// The systems responsible for advancing the physics simulation, and
/// updating the internal state for scene queries.
/// These systems typically run immediately after [`PhysicsSet::SyncBackend`].
Expand Down Expand Up @@ -212,7 +204,6 @@ where
self.schedule.clone(),
(
PhysicsSet::SyncBackend,
PhysicsSet::SyncBackendFlush,
PhysicsSet::StepSimulation,
PhysicsSet::Writeback,
)
Expand All @@ -227,8 +218,6 @@ where
self.schedule.clone(),
(
Self::get_systems(PhysicsSet::SyncBackend).in_set(PhysicsSet::SyncBackend),
Self::get_systems(PhysicsSet::SyncBackendFlush)
.in_set(PhysicsSet::SyncBackendFlush),
Self::get_systems(PhysicsSet::StepSimulation)
.in_set(PhysicsSet::StepSimulation),
Self::get_systems(PhysicsSet::Writeback).in_set(PhysicsSet::Writeback),
Expand Down
4 changes: 0 additions & 4 deletions src/plugin/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,6 @@ pub fn step_simulation<Hooks>(
}
}

/// NOTE: This currently does nothing in 2D, or without the async-collider feature
#[cfg(any(feature = "dim2", not(feature = "async-collider")))]
pub fn init_async_colliders() {}

/// System responsible for creating `Collider` components from `AsyncCollider` components if the
/// corresponding mesh has become available.
#[cfg(all(feature = "dim3", feature = "async-collider"))]
Expand Down

0 comments on commit c5d12af

Please sign in to comment.