From b08ea09f68ee675f7b074859a364786448c0eb39 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Wed, 18 Sep 2024 13:29:48 +0200 Subject: [PATCH 1/2] =?UTF-8?q?remove=20dbg!=20which=20shouldn=C2=B4t=20be?= =?UTF-8?q?=20there=20(#587)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pipeline/events.rs | 3 +-- src/plugin/systems/multiple_rapier_contexts.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pipeline/events.rs b/src/pipeline/events.rs index 9ae050f6..4a169932 100644 --- a/src/pipeline/events.rs +++ b/src/pipeline/events.rs @@ -256,8 +256,7 @@ mod test { std::time::Duration::from_secs_f32(1f32 / 60f32), )); - for i in 0..100 { - dbg!(i); + for _ in 0..100 { app.update(); } return; diff --git a/src/plugin/systems/multiple_rapier_contexts.rs b/src/plugin/systems/multiple_rapier_contexts.rs index 062cf688..ec3dbb3a 100644 --- a/src/plugin/systems/multiple_rapier_contexts.rs +++ b/src/plugin/systems/multiple_rapier_contexts.rs @@ -75,7 +75,7 @@ pub fn on_change_world( }) .unwrap_or(false) { - remove_old_physics(dbg!(entity), &mut commands); + remove_old_physics(entity, &mut commands); bubble_down_world_change( &mut commands, entity, From 3cf2b93af0af14d0c72c432f296ebd7b74fed4f1 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Fri, 20 Sep 2024 15:11:42 +0200 Subject: [PATCH 2/2] Improve system schedules (#584) --- src/plugin/plugin.rs | 55 ++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index 94a89643..8933a7c8 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -99,7 +99,7 @@ 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, @@ -107,30 +107,38 @@ where ) .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::).into_configs(), + PhysicsSet::StepSimulation => (systems::step_simulation::) + .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(), } } @@ -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::();