in Box2D/Dynamics/b2Body.cpp [113:164]
void b2Body::SetType(b2BodyType type)
{
b2Assert(m_world->IsLocked() == false);
if (m_world->IsLocked() == true)
{
return;
}
if (m_type == type)
{
return;
}
m_type = type;
ResetMassData();
if (m_type == b2_staticBody)
{
m_linearVelocity.SetZero();
m_angularVelocity = 0.0f;
m_sweep.a0 = m_sweep.a;
m_sweep.c0 = m_sweep.c;
SynchronizeFixtures();
}
SetAwake(true);
m_force.SetZero();
m_torque = 0.0f;
// Delete the attached contacts.
b2ContactEdge* ce = m_contactList;
while (ce)
{
b2ContactEdge* ce0 = ce;
ce = ce->next;
m_world->m_contactManager.Destroy(ce0->contact);
}
m_contactList = NULL;
// Touch the proxies so that new contacts will be created (when appropriate)
b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
{
int32 proxyCount = f->m_proxyCount;
for (int32 i = 0; i < proxyCount; ++i)
{
broadPhase->TouchProxy(f->m_proxies[i].proxyId);
}
}
}