File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,6 +186,29 @@ impl RigidBodySet {
186186 Some ( result)
187187 }
188188
189+ /// Gets a mutable reference to the two rigid-bodies with the given handles.
190+ ///
191+ /// If `handle1 == handle2`, only the first returned value will be `Some`.
192+ #[ cfg( not( feature = "dev-remove-slow-accessors" ) ) ]
193+ pub fn get_pair_mut (
194+ & mut self ,
195+ handle1 : RigidBodyHandle ,
196+ handle2 : RigidBodyHandle ,
197+ ) -> ( Option < & mut RigidBody > , Option < & mut RigidBody > ) {
198+ if handle1 == handle2 {
199+ ( self . get_mut ( handle1) , None )
200+ } else {
201+ let ( mut rb1, mut rb2) = self . bodies . get2_mut ( handle1. 0 , handle2. 0 ) ;
202+ if let Some ( rb1) = rb1. as_deref_mut ( ) {
203+ self . modified_bodies . push_once ( handle1, rb1) ;
204+ }
205+ if let Some ( rb2) = rb2. as_deref_mut ( ) {
206+ self . modified_bodies . push_once ( handle2, rb2) ;
207+ }
208+ ( rb1, rb2)
209+ }
210+ }
211+
189212 pub ( crate ) fn get_mut_internal ( & mut self , handle : RigidBodyHandle ) -> Option < & mut RigidBody > {
190213 self . bodies . get_mut ( handle. 0 )
191214 }
Original file line number Diff line number Diff line change @@ -299,6 +299,29 @@ impl ColliderSet {
299299 Some ( result)
300300 }
301301
302+ /// Gets a mutable reference to the two colliders with the given handles.
303+ ///
304+ /// If `handle1 == handle2`, only the first returned value will be `Some`.
305+ #[ cfg( not( feature = "dev-remove-slow-accessors" ) ) ]
306+ pub fn get_pair_mut (
307+ & mut self ,
308+ handle1 : ColliderHandle ,
309+ handle2 : ColliderHandle ,
310+ ) -> ( Option < & mut Collider > , Option < & mut Collider > ) {
311+ if handle1 == handle2 {
312+ ( self . get_mut ( handle1) , None )
313+ } else {
314+ let ( mut co1, mut co2) = self . colliders . get2_mut ( handle1. 0 , handle2. 0 ) ;
315+ if let Some ( co1) = co1. as_deref_mut ( ) {
316+ self . modified_colliders . push_once ( handle1, co1) ;
317+ }
318+ if let Some ( co2) = co2. as_deref_mut ( ) {
319+ self . modified_colliders . push_once ( handle2, co2) ;
320+ }
321+ ( co1, co2)
322+ }
323+ }
324+
302325 pub ( crate ) fn index_mut_internal ( & mut self , handle : ColliderHandle ) -> & mut Collider {
303326 & mut self . colliders [ handle. 0 ]
304327 }
You can’t perform that action at this time.
0 commit comments