removeBody method
Remove a rigid body from the simulation.
Implementation
void removeBody(Body body) {
body.world = null;
final n = this.bodies.length - 1;
final bodies = this.bodies;
final idx = bodies.indexOf(body);
if (idx != -1) {
bodies.removeAt(idx);
// Recompute index
for (int i = 0; i != bodies.length; i++) {
bodies[i].index = i;
}
collisionMatrix.setNumObjects(n);
removeBodyEvent.target = body;
idToBodyMap.remove(body);//delete this.idToBodyMap[body.id];
dispatchEvent(removeBodyEvent);
}
}