createJoint method
Adds a joint to constrain bodies together.
This may cause the connected bodies to cease colliding.
Adding a joint doesn't wake up the bodies.
Warning: This function is locked during callbacks.
Implementation
void createJoint(Joint joint) {
assert(!isLocked);
joints.add(joint);
final bodyA = joint.bodyA;
final bodyB = joint.bodyB;
bodyA.joints.add(joint);
bodyB.joints.add(joint);
// If the joint prevents collisions, then flag any contacts for filtering.
if (!joint.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();
}
}
}
}