@@ -1532,24 +1532,24 @@ impl PhysicsWorld {
1532
1532
let body2_handle = joint. body2 ( ) ;
1533
1533
let params = joint. params ( ) . clone ( ) ;
1534
1534
1535
- // A native joint can be created iff both rigid bodies are correctly assigned.
1535
+ // A native joint can be created iff both rigid bodies are correctly assigned and their respective
1536
+ // native bodies exists.
1536
1537
if let ( Some ( body1) , Some ( body2) ) = (
1537
- nodes
1538
- . try_borrow ( body1_handle)
1539
- . and_then ( |n| n. cast :: < scene:: rigidbody:: RigidBody > ( ) ) ,
1540
- nodes
1541
- . try_borrow ( body2_handle)
1542
- . and_then ( |n| n. cast :: < scene:: rigidbody:: RigidBody > ( ) ) ,
1538
+ nodes. try_borrow ( body1_handle) . and_then ( |n| {
1539
+ n. cast :: < scene:: rigidbody:: RigidBody > ( )
1540
+ . filter ( |b| self . bodies . set . get ( b. native . get ( ) ) . is_some ( ) )
1541
+ } ) ,
1542
+ nodes. try_borrow ( body2_handle) . and_then ( |n| {
1543
+ n. cast :: < scene:: rigidbody:: RigidBody > ( )
1544
+ . filter ( |b| self . bodies . set . get ( b. native . get ( ) ) . is_some ( ) )
1545
+ } ) ,
1543
1546
) {
1544
1547
// Calculate local frames first.
1545
1548
let ( local_frame1, local_frame2) = calculate_local_frames ( joint, body1, body2) ;
1546
1549
1547
1550
let native_body1 = body1. native . get ( ) ;
1548
1551
let native_body2 = body2. native . get ( ) ;
1549
1552
1550
- assert ! ( self . bodies. set. get( native_body1) . is_some( ) ) ;
1551
- assert ! ( self . bodies. set. get( native_body2) . is_some( ) ) ;
1552
-
1553
1553
let mut native_joint = convert_joint_params ( params, local_frame1, local_frame2) ;
1554
1554
native_joint. contacts_enabled = joint. is_contacts_enabled ( ) ;
1555
1555
let native_handle =
0 commit comments