aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline/physics_pipeline.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-02-04 17:12:40 +0100
committerCrozet Sébastien <developer@crozet.re>2021-02-04 17:12:40 +0100
commit09b867d0be5378f249a3dc4722527ed2e0233645 (patch)
tree9c5ae3c2e389c988338e697bd5471c1bbd3035f9 /src/pipeline/physics_pipeline.rs
parent822f0d81bf2fbcb3a7f0733ce9bf24569a591bf7 (diff)
downloadrapier-09b867d0be5378f249a3dc4722527ed2e0233645.tar.gz
rapier-09b867d0be5378f249a3dc4722527ed2e0233645.tar.bz2
rapier-09b867d0be5378f249a3dc4722527ed2e0233645.zip
Experiment with incremental island having only one awake island.
Diffstat (limited to 'src/pipeline/physics_pipeline.rs')
-rw-r--r--src/pipeline/physics_pipeline.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs
index 70474a7..cd83baf 100644
--- a/src/pipeline/physics_pipeline.rs
+++ b/src/pipeline/physics_pipeline.rs
@@ -77,10 +77,18 @@ impl PhysicsPipeline {
events: &dyn EventHandler,
) {
self.counters.step_started();
- bodies.maintain(islands, colliders);
+ bodies.maintain(
+ islands,
+ colliders,
+ &mut self.bodies_with_changed_sleep_state,
+ );
broad_phase.maintain(colliders);
narrow_phase.maintain(colliders, bodies);
+ for handle in self.bodies_with_changed_sleep_state.drain(..) {
+ islands.body_sleep_state_changed(bodies, handle);
+ }
+
// Update kinematic bodies velocities.
// TODO: what is the best place for this? It should at least be
// located before the island computation because we test the velocity
@@ -165,7 +173,7 @@ impl PhysicsPipeline {
self.counters.stages.update_time.start();
for handle in islands.active_bodies() {
- if let Some(rb) = bodies.get_mut(handle) {
+ if let Some(rb) = bodies.get_mut(*handle) {
rb.update_world_mass_properties();
rb.integrate_accelerations(integration_parameters.dt, *gravity)
}
@@ -243,7 +251,7 @@ impl PhysicsPipeline {
// Update colliders positions and kinematic bodies positions.
// FIXME: do this in the solver?
for handle in islands.active_bodies() {
- if let Some(rb) = bodies.get_mut(handle) {
+ if let Some(rb) = bodies.get_mut(*handle) {
rb.update_predicted_position(integration_parameters.dt);
rb.update_colliders_positions(colliders);
@@ -252,15 +260,17 @@ impl PhysicsPipeline {
rb.update_energy();
if prev_sleep_state != rb.can_sleep() {
- self.bodies_with_changed_sleep_state.push(handle);
+ self.bodies_with_changed_sleep_state.push(*handle);
}
}
}
for handle in self.bodies_with_changed_sleep_state.drain(..) {
- islands.body_sleep_state_changed(&bodies[handle]);
+ islands.body_sleep_state_changed(bodies, handle);
}
+ islands.update_sleeping_islands(bodies, colliders, narrow_phase);
+
bodies.foreach_active_kinematic_body_mut_internal(|_, rb| {
rb.position = rb.predicted_position;
rb.linvel = na::zero();