Skip to content

Commit

Permalink
Some scheduling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceeri committed Oct 9, 2023
1 parent 68b8879 commit 2d52447
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#[cfg(feature = "rapier")]
pub mod rapier;
pub use rapier::*;
Expand Down
5 changes: 2 additions & 3 deletions src/backend/rapier/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

use bevy::prelude::*;
use super::rapier::prelude::*;
use bevy::prelude::*;

/// Contains common physics settings for character controllers.
#[derive(Bundle)]
Expand Down Expand Up @@ -35,7 +34,7 @@ impl Default for RapierPhysicsBundle {
fn default() -> Self {
Self {
rigidbody: default(),
collider: Collider::capsule(Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.0, 0.5, 0.0), 0.5),
collider: Collider::capsule(Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.0, 0.5, 0.0), 0.3),
velocity: default(),
gravity: GravityScale(0.0),
sleeping: default(),
Expand Down
2 changes: 1 addition & 1 deletion src/backend/rapier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mod mass;
pub use mass::get_mass_from_backend;
mod velocity;
pub use velocity::get_velocity_from_backend;
mod query;
mod plugin;
mod query;
pub use plugin::WanderlustRapierPlugin;

use rapier::prelude::Collider;
Expand Down
6 changes: 6 additions & 0 deletions src/backend/rapier/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ impl Plugin for WanderlustRapierPlugin {
app.add_systems(Startup, super::setup_physics_context);
}

app.configure_sets(
self.schedule.clone(),
(WanderlustSet::Apply,).before(crate::rapier::PhysicsSet::SyncBackend),
);

app.add_systems(
self.schedule.clone(),
(
super::update_delta_time,
super::get_mass_from_backend,
super::get_velocity_from_backend,
)
Expand Down
20 changes: 11 additions & 9 deletions src/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Plugin for WanderlustPlugin {
.register_type::<ForceSettings>()
.register_type::<HashSet<Entity>>();

app.insert_resource(PhysicsDeltaTime(0.0));
app.insert_resource(PhysicsDeltaTime(0.016));

if self.default_system_setup {
#[cfg(feature = "rapier")]
Expand All @@ -94,16 +94,18 @@ impl Plugin for WanderlustPlugin {
tweaks: self.tweaks,
schedule: self.schedule.clone(),
});

app.configure_sets(
self.schedule.clone(),
(
WanderlustSet::Apply,
)
.before(crate::backend::rapier::backend_label()),
);
};

app.configure_sets(
self.schedule.clone(),
(
WanderlustSet::Sync,
WanderlustSet::Compute,
WanderlustSet::Apply,
)
.chain(),
);

app.add_systems(
self.schedule.clone(),
(
Expand Down

0 comments on commit 2d52447

Please sign in to comment.