Skip to content

Commit 0590c97

Browse files
committed
Fix CCD bodies adding multiple contact manifolds when using Jolt
1 parent 1f7630f commit 0590c97

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/jolt_physics/spaces/jolt_contact_listener_3d.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ bool JoltContactListener3D::_try_add_contacts(const JPH::Body &p_jolt_body1, con
193193
return manifolds_by_shape_pair[shape_pair];
194194
}();
195195

196+
if (unlikely(!manifold.contacts1.is_empty())) {
197+
// CCD collisions can result in two contact callbacks for the same shape pair, one in the earlier discrete stage and one in the later CCD stage.
198+
// We want the manifolds from the discrete stage, as the bodies still have their original velocities at that point, so we early-out if we've already stored something.
199+
return false;
200+
}
201+
196202
const JPH::uint contact_count = p_manifold.mRelativeContactPointsOn1.size();
197203

198204
manifold.contacts1.reserve((uint32_t)contact_count);

0 commit comments

Comments
 (0)