destroyBody method
Destroys a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.
Warning: This automatically deletes all associated shapes and joints. Warning: This function is locked during callbacks.
Implementation
void destroyBody(Body body) {
assert(bodies.isNotEmpty);
assert(!isLocked);
// Delete the attached joints.
while (body.joints.isNotEmpty) {
final joint = body.joints.first;
destroyListener?.onDestroyJoint(joint);
destroyJoint(joint);
}
// Delete the attached contacts.
while (body.contacts.isNotEmpty) {
contactManager.destroy(body.contacts.first);
}
body.contacts.clear();
for (final f in body.fixtures) {
destroyListener?.onDestroyFixture(f);
f.destroyProxies(contactManager.broadPhase);
}
bodies.remove(body);
}