1
0
Fork 0

Merge pull request #101044 from mihe/jolt/revert-100533

Revert "Stop reporting contacts for sleeping bodies when using Jolt Physics"
This commit is contained in:
Rémi Verschelde 2025-01-03 00:50:13 +01:00
commit 5a8b7188af
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 12 deletions

View File

@ -405,29 +405,25 @@ void JoltContactListener3D::_flush_contacts() {
const JPH::SubShapeIDPair &shape_pair = E.key; const JPH::SubShapeIDPair &shape_pair = E.key;
Manifold &manifold = E.value; Manifold &manifold = E.value;
const JoltReadableBody3D jolt_body1 = space->read_body(shape_pair.GetBody1ID()); const JPH::BodyID body_ids[2] = { shape_pair.GetBody1ID(), shape_pair.GetBody2ID() };
const JoltReadableBody3D jolt_body2 = space->read_body(shape_pair.GetBody2ID()); const JoltReadableBodies3D jolt_bodies = space->read_bodies(body_ids, 2);
JoltBody3D *body1 = jolt_body1.as_body(); JoltBody3D *body1 = jolt_bodies[0].as_body();
ERR_FAIL_NULL(body1); ERR_FAIL_NULL(body1);
JoltBody3D *body2 = jolt_body2.as_body(); JoltBody3D *body2 = jolt_bodies[1].as_body();
ERR_FAIL_NULL(body2); ERR_FAIL_NULL(body2);
const int shape_index1 = body1->find_shape_index(shape_pair.GetSubShapeID1()); const int shape_index1 = body1->find_shape_index(shape_pair.GetSubShapeID1());
const int shape_index2 = body2->find_shape_index(shape_pair.GetSubShapeID2()); const int shape_index2 = body2->find_shape_index(shape_pair.GetSubShapeID2());
if (jolt_body1->IsActive()) {
for (const Contact &contact : manifold.contacts1) { for (const Contact &contact : manifold.contacts1) {
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); 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);
} }
}
if (jolt_body2->IsActive()) {
for (const Contact &contact : manifold.contacts2) { for (const Contact &contact : manifold.contacts2) {
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); 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);
} }
}
manifold.contacts1.clear(); manifold.contacts1.clear();
manifold.contacts2.clear(); manifold.contacts2.clear();