diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-07-01 14:26:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-01 14:26:57 +0200 |
| commit | 1ba37b8f635bd79db2e48b07c038723f9e8c172f (patch) | |
| tree | fa31ce984ba86601a3bfbe9b2b231c02ba08c45a /src/geometry/narrow_phase.rs | |
| parent | 8546434f35d8a8a3e6e6bb09c7985ab409a17d8d (diff) | |
| parent | d3ca956565dc361fe5583dc756f10de7c2ee1bbd (diff) | |
| download | rapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.tar.gz rapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.tar.bz2 rapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.zip | |
Merge pull request #353 from dimforge/force-events
Add force reporting
Diffstat (limited to 'src/geometry/narrow_phase.rs')
| -rw-r--r-- | src/geometry/narrow_phase.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index e7b9a34..a1256b8 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -1,6 +1,7 @@ #[cfg(feature = "parallel")] use rayon::prelude::*; +use crate::data::graph::EdgeIndex; use crate::data::Coarena; use crate::dynamics::{ CoefficientCombineRule, IslandManager, RigidBodyDominance, RigidBodySet, RigidBodyType, @@ -8,7 +9,7 @@ use crate::dynamics::{ use crate::geometry::{ BroadPhasePairEvent, ColliderChanges, ColliderGraphIndex, ColliderHandle, ColliderPair, ColliderSet, CollisionEvent, ContactData, ContactManifold, ContactManifoldData, ContactPair, - InteractionGraph, IntersectionPair, SolverContact, SolverFlags, + InteractionGraph, IntersectionPair, SolverContact, SolverFlags, TemporaryInteractionIndex, }; use crate::math::{Real, Vector}; use crate::pipeline::{ @@ -164,6 +165,11 @@ impl NarrowPhase { }) } + /// Returns the contact pair at the given temporary index. + pub fn contact_pair_at_index(&self, id: TemporaryInteractionIndex) -> &ContactPair { + &self.contact_graph.graph.edges[id.index()].weight + } + /// The contact pair involving two specific colliders. /// /// It is strongly recommended to use the [`NarrowPhase::contact_pair`] method instead. This @@ -975,6 +981,7 @@ impl NarrowPhase { &'a mut self, islands: &IslandManager, bodies: &RigidBodySet, + out_contact_pairs: &mut Vec<TemporaryInteractionIndex>, out_manifolds: &mut Vec<&'a mut ContactManifold>, out: &mut Vec<Vec<ContactManifoldIndex>>, ) { @@ -983,7 +990,9 @@ impl NarrowPhase { } // TODO: don't iterate through all the interactions. - for inter in self.contact_graph.graph.edges.iter_mut() { + for (pair_id, inter) in self.contact_graph.graph.edges.iter_mut().enumerate() { + let mut push_pair = false; + for manifold in &mut inter.weight.manifolds { if manifold .data @@ -1027,9 +1036,14 @@ impl NarrowPhase { out[island_index].push(out_manifolds.len()); out_manifolds.push(manifold); + push_pair = true; } } } + + if push_pair { + out_contact_pairs.push(EdgeIndex::new(pair_id as u32)); + } } } } |
