From 1a8386fcb9f819205f326d34000282b9f8232610 Mon Sep 17 00:00:00 2001 From: Aceeri Date: Tue, 25 Jul 2023 21:33:11 -0700 Subject: [PATCH 1/4] Apply scale after we initialize colliders --- src/plugin/plugin.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index 2b808a95..c81c0802 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -73,7 +73,9 @@ where .after(systems::update_character_controls) .in_set(RapierTransformPropagateSet), systems::init_async_colliders.after(RapierTransformPropagateSet), - systems::apply_scale.after(systems::init_async_colliders), + systems::apply_scale + .after(systems::init_async_colliders) + .after(systems::init_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), From 956e51e8c7a80ffc15da78569bffba7969270bf6 Mon Sep 17 00:00:00 2001 From: Aceeri Date: Tue, 25 Jul 2023 21:50:07 -0700 Subject: [PATCH 2/4] Use chain instead of manually doing so --- src/plugin/plugin.rs | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index c81c0802..57a3f7cc 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -70,31 +70,21 @@ 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) - .after(systems::init_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), + 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::sync_removals, ) + .chain() .into_configs(), PhysicsSet::SyncBackendFlush => (apply_deferred,).into_configs(), PhysicsSet::StepSimulation => ( From e511b51876d0140f30b2f60a7a7195051aa68e9e Mon Sep 17 00:00:00 2001 From: Aceeri Date: Wed, 26 Jul 2023 06:11:34 -0700 Subject: [PATCH 3/4] Move apply_deferred flush to after initialization/removal sync, but before applying user changes --- src/plugin/plugin.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index 57a3f7cc..779c49bb 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -77,16 +77,17 @@ where 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, - systems::sync_removals, ) .chain() .into_configs(), - PhysicsSet::SyncBackendFlush => (apply_deferred,).into_configs(), PhysicsSet::StepSimulation => ( systems::step_simulation::, Events::::update_system @@ -127,8 +128,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`]. @@ -187,7 +186,6 @@ where PostUpdate, ( PhysicsSet::SyncBackend, - PhysicsSet::SyncBackendFlush, PhysicsSet::StepSimulation, PhysicsSet::Writeback, ) @@ -199,8 +197,6 @@ where PostUpdate, ( 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), From 9ee4610a88f87e27af0def9d245c9dd9850c58fa Mon Sep 17 00:00:00 2001 From: Aceeri Date: Wed, 26 Jul 2023 06:18:36 -0700 Subject: [PATCH 4/4] Remove SyncBackendFlush, init_async_colliders dummy systems --- bevy_rapier2d/examples/custom_system_setup2.rs | 3 --- bevy_rapier3d/examples/custom_system_setup3.rs | 3 --- src/plugin/plugin.rs | 1 + src/plugin/systems.rs | 4 ---- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bevy_rapier2d/examples/custom_system_setup2.rs b/bevy_rapier2d/examples/custom_system_setup2.rs index 3e9c810e..8ee9d8eb 100644 --- a/bevy_rapier2d/examples/custom_system_setup2.rs +++ b/bevy_rapier2d/examples/custom_system_setup2.rs @@ -20,7 +20,6 @@ fn main() { PostUpdate, ( PhysicsSet::SyncBackend, - PhysicsSet::SyncBackendFlush, PhysicsSet::StepSimulation, PhysicsSet::Writeback, ) @@ -33,8 +32,6 @@ fn main() { ( RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) .in_set(PhysicsSet::SyncBackend), - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) - .in_set(PhysicsSet::SyncBackendFlush), ( RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation), despawn_one_box, diff --git a/bevy_rapier3d/examples/custom_system_setup3.rs b/bevy_rapier3d/examples/custom_system_setup3.rs index ea422422..073cd95f 100644 --- a/bevy_rapier3d/examples/custom_system_setup3.rs +++ b/bevy_rapier3d/examples/custom_system_setup3.rs @@ -20,7 +20,6 @@ fn main() { PostUpdate, ( PhysicsSet::SyncBackend, - PhysicsSet::SyncBackendFlush, PhysicsSet::StepSimulation, PhysicsSet::Writeback, ) @@ -33,8 +32,6 @@ fn main() { ( RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) .in_set(PhysicsSet::SyncBackend), - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) - .in_set(PhysicsSet::SyncBackendFlush), ( RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation), despawn_one_box, diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index 779c49bb..398b7bb4 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -73,6 +73,7 @@ where .in_set(RapierTransformPropagateSet), #[cfg(all(feature = "dim3", feature = "async-collider"))] 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, diff --git a/src/plugin/systems.rs b/src/plugin/systems.rs index acd9ec04..f14fda65 100644 --- a/src/plugin/systems.rs +++ b/src/plugin/systems.rs @@ -695,10 +695,6 @@ pub fn step_simulation( } } -/// 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"))]