@@ -7,7 +7,7 @@ use crate::data_structures::{
77use crate :: prelude:: * ;
88use bevy:: { platform_support:: collections:: HashSet , prelude:: * } ;
99
10- use super :: { ContactPairFlags , Contacts } ;
10+ use super :: { ContactPair , ContactPairFlags } ;
1111
1212/// A resource that stores all contact pairs in the physics world
1313/// in an [undirected graph](UnGraph).
@@ -70,7 +70,7 @@ use super::{ContactPairFlags, Contacts};
7070pub struct ContactGraph {
7171 // TODO: We could have a separate intersection graph for sensors.
7272 /// The internal undirected graph where nodes are entities and edges are contact pairs.
73- pub internal : UnGraph < Entity , Contacts > ,
73+ pub internal : UnGraph < Entity , ContactPair > ,
7474
7575 /// A set of all contact pairs for fast lookup.
7676 ///
@@ -89,9 +89,9 @@ impl ContactGraph {
8989 /// If the pair does not exist, `None` is returned.
9090 ///
9191 /// A contact pair exists between two entities if their [`ColliderAabb`]s intersect.
92- /// Use [`Contacts ::is_touching`] to determine if the actual collider shapes are touching.
92+ /// Use [`ContactPair ::is_touching`] to determine if the actual collider shapes are touching.
9393 #[ inline]
94- pub fn get ( & self , entity1 : Entity , entity2 : Entity ) -> Option < & Contacts > {
94+ pub fn get ( & self , entity1 : Entity , entity2 : Entity ) -> Option < & ContactPair > {
9595 let ( Some ( & index1) , Some ( & index2) ) = (
9696 self . entity_graph_index . get ( entity1) ,
9797 self . entity_graph_index . get ( entity2) ,
@@ -108,9 +108,9 @@ impl ContactGraph {
108108 /// If the pair does not exist, `None` is returned.
109109 ///
110110 /// A contact pair exists between two entities if their [`ColliderAabb`]s intersect.
111- /// Use [`Contacts ::is_touching`] to determine if the actual collider shapes are touching.
111+ /// Use [`ContactPair ::is_touching`] to determine if the actual collider shapes are touching.
112112 #[ inline]
113- pub fn get_mut ( & mut self , entity1 : Entity , entity2 : Entity ) -> Option < & mut Contacts > {
113+ pub fn get_mut ( & mut self , entity1 : Entity , entity2 : Entity ) -> Option < & mut ContactPair > {
114114 let ( Some ( & index1) , Some ( & index2) ) = (
115115 self . entity_graph_index . get ( entity1) ,
116116 self . entity_graph_index . get ( entity2) ,
@@ -150,15 +150,15 @@ impl ContactGraph {
150150 ///
151151 /// If you only want touching contacts, use [`iter_touching`](Self::iter_touching) instead.
152152 #[ inline]
153- pub fn iter ( & self ) -> impl Iterator < Item = & Contacts > {
153+ pub fn iter ( & self ) -> impl Iterator < Item = & ContactPair > {
154154 self . internal . all_edge_weights ( )
155155 }
156156
157157 /// Returns an iterator yielding immutable access to all contact pairs that are currently touching.
158158 ///
159159 /// This is a subset of [`iter`](Self::iter) that only includes pairs where the colliders are touching.
160160 #[ inline]
161- pub fn iter_touching ( & self ) -> impl Iterator < Item = & Contacts > {
161+ pub fn iter_touching ( & self ) -> impl Iterator < Item = & ContactPair > {
162162 self . internal
163163 . all_edge_weights ( )
164164 . filter ( |contacts| contacts. flags . contains ( ContactPairFlags :: TOUCHING ) )
@@ -171,15 +171,15 @@ impl ContactGraph {
171171 ///
172172 /// If you only want touching contacts, use [`iter_touching_mut`](Self::iter_touching_mut) instead.
173173 #[ inline]
174- pub fn iter_mut ( & mut self ) -> impl Iterator < Item = & mut Contacts > {
174+ pub fn iter_mut ( & mut self ) -> impl Iterator < Item = & mut ContactPair > {
175175 self . internal . all_edge_weights_mut ( )
176176 }
177177
178178 /// Returns a iterator yielding mutable access to all contact pairs that are currently touching.
179179 ///
180180 /// This is a subset of [`iter_mut`](Self::iter_mut) that only includes pairs where the colliders are touching.
181181 #[ inline]
182- pub fn iter_touching_mut ( & mut self ) -> impl Iterator < Item = & mut Contacts > {
182+ pub fn iter_touching_mut ( & mut self ) -> impl Iterator < Item = & mut ContactPair > {
183183 self . internal
184184 . all_edge_weights_mut ( )
185185 . filter ( |contacts| contacts. flags . contains ( ContactPairFlags :: TOUCHING ) )
@@ -190,9 +190,9 @@ impl ContactGraph {
190190 /// A contact pair exists between two entities if their [`ColliderAabb`]s intersect,
191191 /// even if the shapes themselves are not yet touching.
192192 ///
193- /// Use [`Contacts ::is_touching`](Contacts ::is_touching) to determine if the actual collider shapes are touching.
193+ /// Use [`ContactPair ::is_touching`](ContactPair ::is_touching) to determine if the actual collider shapes are touching.
194194 #[ inline]
195- pub fn collisions_with ( & self , entity : Entity ) -> impl Iterator < Item = & Contacts > {
195+ pub fn collisions_with ( & self , entity : Entity ) -> impl Iterator < Item = & ContactPair > {
196196 self . entity_graph_index
197197 . get ( entity)
198198 . into_iter ( )
@@ -204,9 +204,12 @@ impl ContactGraph {
204204 /// A contact pair exists between two entities if their [`ColliderAabb`]s intersect,
205205 /// even if the shapes themselves are not yet touching.
206206 ///
207- /// Use [`Contacts ::is_touching`](Contacts ::is_touching) to determine if the actual collider shapes are touching.
207+ /// Use [`ContactPair ::is_touching`](ContactPair ::is_touching) to determine if the actual collider shapes are touching.
208208 #[ inline]
209- pub fn collisions_with_mut ( & mut self , entity : Entity ) -> impl Iterator < Item = & mut Contacts > {
209+ pub fn collisions_with_mut (
210+ & mut self ,
211+ entity : Entity ,
212+ ) -> impl Iterator < Item = & mut ContactPair > {
210213 if let Some ( & index) = self . entity_graph_index . get ( entity) {
211214 self . internal . edge_weights_mut ( index)
212215 } else {
@@ -243,7 +246,7 @@ impl ContactGraph {
243246 /// Creating a collision pair with this method will *not* trigger any collision events
244247 /// or wake up the entities involved. Only use this method if you know what you are doing.
245248 #[ inline]
246- pub fn add_pair ( & mut self , contacts : Contacts ) {
249+ pub fn add_pair ( & mut self , contacts : ContactPair ) {
247250 let pair_key = PairKey :: new ( contacts. entity1 . index ( ) , contacts. entity2 . index ( ) ) ;
248251 self . add_pair_with_key ( contacts, pair_key) ;
249252 }
@@ -262,7 +265,7 @@ impl ContactGraph {
262265 /// Creating a collision pair with this method will *not* trigger any collision events
263266 /// or wake up the entities involved. Only use this method if you know what you are doing.
264267 #[ inline]
265- pub fn add_pair_with_key ( & mut self , contacts : Contacts , pair_key : PairKey ) {
268+ pub fn add_pair_with_key ( & mut self , contacts : ContactPair , pair_key : PairKey ) {
266269 // Add the pair to the pair set for fast lookup.
267270 if !self . pair_set . insert ( pair_key) {
268271 // The pair already exists.
@@ -295,7 +298,7 @@ impl ContactGraph {
295298 /// Inserting a collision pair with this method will *not* trigger any collision events
296299 /// or wake up the entities involved. Only use this method if you know what you are doing.
297300 #[ inline]
298- pub fn insert_pair ( & mut self , contacts : Contacts ) {
301+ pub fn insert_pair ( & mut self , contacts : ContactPair ) {
299302 let pair_key = PairKey :: new ( contacts. entity1 . index ( ) , contacts. entity2 . index ( ) ) ;
300303 self . insert_pair_with_key ( contacts, pair_key) ;
301304 }
@@ -314,7 +317,7 @@ impl ContactGraph {
314317 /// Inserting a collision pair with this method will *not* trigger any collision events
315318 /// or wake up the entities involved. Only use this method if you know what you are doing.
316319 #[ inline]
317- pub fn insert_pair_with_key ( & mut self , contacts : Contacts , pair_key : PairKey ) {
320+ pub fn insert_pair_with_key ( & mut self , contacts : ContactPair , pair_key : PairKey ) {
318321 // Add the pair to the pair set for fast lookup.
319322 self . pair_set . insert ( pair_key) ;
320323
@@ -344,7 +347,7 @@ impl ContactGraph {
344347 ///
345348 /// For filtering and modifying collisions, consider using [`CollisionHooks`] instead.
346349 #[ inline]
347- pub fn remove_pair ( & mut self , entity1 : Entity , entity2 : Entity ) -> Option < Contacts > {
350+ pub fn remove_pair ( & mut self , entity1 : Entity , entity2 : Entity ) -> Option < ContactPair > {
348351 let ( Some ( & index1) , Some ( & index2) ) = (
349352 self . entity_graph_index . get ( entity1) ,
350353 self . entity_graph_index . get ( entity2) ,
@@ -372,7 +375,7 @@ impl ContactGraph {
372375 #[ inline]
373376 pub fn remove_collider_with < F > ( & mut self , entity : Entity , mut pair_callback : F )
374377 where
375- F : FnMut ( Contacts ) ,
378+ F : FnMut ( ContactPair ) ,
376379 {
377380 let Some ( & index) = self . entity_graph_index . get ( entity) else {
378381 return ;
0 commit comments