destroyJoint method
Destroys a joint. This may cause the connected bodies to begin colliding.
Warning: This function is locked during callbacks.
Implementation
void destroyJoint(Joint joint) {
assert(!isLocked);
final collideConnected = joint.collideConnected;
joints.remove(joint);
// Disconnect from island graph.
final bodyA = joint.bodyA;
final bodyB = joint.bodyB;
// Wake up connected bodies.
bodyA.setAwake(true);
bodyB.setAwake(true);
bodyA.joints.remove(joint);
bodyB.joints.remove(joint);
Joint.destroy(joint);
// If the joint prevents collisions, then flag any contacts for filtering.
if (!collideConnected) {
for (final contact in bodyB.contacts) {
if (contact.getOtherBody(bodyB) == bodyA) {
// Flag the contact for filtering at the next time step (where either
// body is awake).
contact.flagForFiltering();
}
}
}
}