diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-24 16:39:09 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-24 16:39:09 +0100 |
| commit | d98be2359df74a9844cd451c29e583c0c8ecb7d3 (patch) | |
| tree | 43b715daada2eb5372f53cd83d474f1464bb47f5 | |
| parent | 437748096d96d4bde5540711580be26a2b146b65 (diff) | |
| download | rapier-d98be2359df74a9844cd451c29e583c0c8ecb7d3.tar.gz rapier-d98be2359df74a9844cd451c29e583c0c8ecb7d3.tar.bz2 rapier-d98be2359df74a9844cd451c29e583c0c8ecb7d3.zip | |
Add methods to iterate through all the contact and proximity pairs.
| -rw-r--r-- | src/geometry/interaction_graph.rs | 12 | ||||
| -rw-r--r-- | src/geometry/narrow_phase.rs | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/geometry/interaction_graph.rs b/src/geometry/interaction_graph.rs index 2abb6d1..cae8095 100644 --- a/src/geometry/interaction_graph.rs +++ b/src/geometry/interaction_graph.rs @@ -74,15 +74,9 @@ impl<T> InteractionGraph<T> { self.graph.node_weight(id).cloned() } - /// All the interactions pairs on this graph. - pub fn interaction_pairs(&self) -> impl Iterator<Item = (ColliderHandle, ColliderHandle, &T)> { - self.graph.raw_edges().iter().map(move |edge| { - ( - self.graph[edge.source()], - self.graph[edge.target()], - &edge.weight, - ) - }) + /// All the interactions on this graph. + pub fn interactions(&self) -> impl Iterator<Item = &T> { + self.graph.raw_edges().iter().map(move |edge| &edge.weight) } /// The interaction between the two collision objects identified by their graph index. diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index a3d0ea7..a21d3c6 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -140,6 +140,16 @@ impl NarrowPhase { .map(|c| c.2) } + /// All the contact pairs maintained by this narrow-phase. + pub fn contact_pairs(&self) -> impl Iterator<Item = &ContactPair> { + self.contact_graph.interactions() + } + + /// All the proximity pairs maintained by this narrow-phase. + pub fn proximity_pairs(&self) -> impl Iterator<Item = &ProximityPair> { + self.proximity_graph.interactions() + } + // #[cfg(feature = "parallel")] // pub(crate) fn contact_pairs_vec_mut(&mut self) -> &mut Vec<ContactPair> { // &mut self.contact_graph.interactions |
