@@ -405,28 +405,24 @@ void JoltContactListener3D::_flush_contacts() {
405
405
const JPH::SubShapeIDPair &shape_pair = E.key ;
406
406
Manifold &manifold = E.value ;
407
407
408
- const JoltReadableBody3D jolt_body1 = space-> read_body ( shape_pair.GetBody1ID ()) ;
409
- const JoltReadableBody3D jolt_body2 = space->read_body (shape_pair. GetBody2ID () );
408
+ const JPH::BodyID body_ids[ 2 ] = { shape_pair.GetBody1ID (), shape_pair. GetBody2ID () } ;
409
+ const JoltReadableBodies3D jolt_bodies = space->read_bodies (body_ids, 2 );
410
410
411
- JoltBody3D *body1 = jolt_body1 .as_body ();
411
+ JoltBody3D *body1 = jolt_bodies[ 0 ] .as_body ();
412
412
ERR_FAIL_NULL (body1);
413
413
414
- JoltBody3D *body2 = jolt_body2 .as_body ();
414
+ JoltBody3D *body2 = jolt_bodies[ 1 ] .as_body ();
415
415
ERR_FAIL_NULL (body2);
416
416
417
417
const int shape_index1 = body1->find_shape_index (shape_pair.GetSubShapeID1 ());
418
418
const int shape_index2 = body2->find_shape_index (shape_pair.GetSubShapeID2 ());
419
419
420
- if (jolt_body1->IsActive ()) {
421
- for (const Contact &contact : manifold.contacts1 ) {
422
- body1->add_contact (body2, manifold.depth , shape_index1, shape_index2, contact.normal , contact.point_self , contact.point_other , contact.velocity_self , contact.velocity_other , contact.impulse );
423
- }
420
+ for (const Contact &contact : manifold.contacts1 ) {
421
+ body1->add_contact (body2, manifold.depth , shape_index1, shape_index2, contact.normal , contact.point_self , contact.point_other , contact.velocity_self , contact.velocity_other , contact.impulse );
424
422
}
425
423
426
- if (jolt_body2->IsActive ()) {
427
- for (const Contact &contact : manifold.contacts2 ) {
428
- body2->add_contact (body1, manifold.depth , shape_index2, shape_index1, contact.normal , contact.point_self , contact.point_other , contact.velocity_self , contact.velocity_other , contact.impulse );
429
- }
424
+ for (const Contact &contact : manifold.contacts2 ) {
425
+ body2->add_contact (body1, manifold.depth , shape_index2, shape_index1, contact.normal , contact.point_self , contact.point_other , contact.velocity_self , contact.velocity_other , contact.impulse );
430
426
}
431
427
432
428
manifold.contacts1 .clear ();
0 commit comments