diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-03-31 10:53:44 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-03-31 10:53:44 +0200 |
| commit | e9f6384081e7f3722976b9fefda6926f5206e0a2 (patch) | |
| tree | 19f32cc7b9d60f386c9e6fcc119f0aecaa0f1f95 /src/pipeline | |
| parent | 88933bd4317c6ae522a4af906919dffd2becc6f9 (diff) | |
| download | rapier-e9f6384081e7f3722976b9fefda6926f5206e0a2.tar.gz rapier-e9f6384081e7f3722976b9fefda6926f5206e0a2.tar.bz2 rapier-e9f6384081e7f3722976b9fefda6926f5206e0a2.zip | |
Fix the parallel solver to work properly with CCD.
Diffstat (limited to 'src/pipeline')
| -rw-r--r-- | src/pipeline/physics_pipeline.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs index 40ae5d1..bab10b7 100644 --- a/src/pipeline/physics_pipeline.rs +++ b/src/pipeline/physics_pipeline.rs @@ -123,6 +123,36 @@ impl PhysicsPipeline { ) } } + + #[cfg(feature = "parallel")] + { + use crate::geometry::ContactManifold; + use rayon::prelude::*; + use std::sync::atomic::Ordering; + + let num_islands = bodies.num_islands(); + let solvers = &mut self.solvers[..num_islands]; + let bodies = &std::sync::atomic::AtomicPtr::new(bodies as *mut _); + + rayon::scope(|scope| { + enable_flush_to_zero!(); + + solvers + .par_iter_mut() + .enumerate() + .for_each(|(island_id, solver)| { + let bodies: &mut RigidBodySet = + unsafe { std::mem::transmute(bodies.load(Ordering::Relaxed)) }; + + solver.solve_position_constraints( + scope, + island_id, + integration_parameters, + bodies, + ) + }); + }); + } } fn build_islands_and_solve_velocity_constraints( @@ -216,7 +246,7 @@ impl PhysicsPipeline { let joints: &mut Vec<JointGraphEdge> = unsafe { std::mem::transmute(joints.load(Ordering::Relaxed)) }; - solver.solve_island( + solver.init_constraints_and_solve_velocity_constraints( scope, island_id, integration_parameters, @@ -225,7 +255,6 @@ impl PhysicsPipeline { &manifold_indices[island_id], joints, &joint_constraint_indices[island_id], - is_last_substep, ) }); }); |
