Skip to content

Commit 5a8b718

Browse files
committed
Merge pull request #101044 from mihe/jolt/revert-100533
Revert "Stop reporting contacts for sleeping bodies when using Jolt Physics"
2 parents 8e66fac + 7bed84c commit 5a8b718

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

modules/jolt_physics/spaces/jolt_contact_listener_3d.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -405,28 +405,24 @@ void JoltContactListener3D::_flush_contacts() {
405405
const JPH::SubShapeIDPair &shape_pair = E.key;
406406
Manifold &manifold = E.value;
407407

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);
410410

411-
JoltBody3D *body1 = jolt_body1.as_body();
411+
JoltBody3D *body1 = jolt_bodies[0].as_body();
412412
ERR_FAIL_NULL(body1);
413413

414-
JoltBody3D *body2 = jolt_body2.as_body();
414+
JoltBody3D *body2 = jolt_bodies[1].as_body();
415415
ERR_FAIL_NULL(body2);
416416

417417
const int shape_index1 = body1->find_shape_index(shape_pair.GetSubShapeID1());
418418
const int shape_index2 = body2->find_shape_index(shape_pair.GetSubShapeID2());
419419

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);
424422
}
425423

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);
430426
}
431427

432428
manifold.contacts1.clear();

0 commit comments

Comments
 (0)