setType method
Set the type of this body. This may alter the mass and velocity.
Implementation
void setType(BodyType type) {
assert(!world.isLocked);
if (_bodyType == type) {
return;
}
_bodyType = type;
resetMassData();
if (_bodyType == BodyType.static) {
linearVelocity.setZero();
_angularVelocity = 0.0;
sweep.a0 = sweep.a;
sweep.c0.setFrom(sweep.c);
synchronizeFixtures();
}
setAwake(true);
force.setZero();
_torque = 0.0;
// Delete the attached contacts.
while (contacts.isNotEmpty) {
world.contactManager.destroy(contacts.first);
}
contacts.clear();
// Touch the proxies so that new contacts will be created (when appropriate)
final broadPhase = world.contactManager.broadPhase;
for (final f in fixtures) {
final proxyCount = f.proxyCount;
for (var i = 0; i < proxyCount; ++i) {
broadPhase.touchProxy(f.proxies[i].proxyId);
}
}
}