void Body::SetActive(bool flag) { assert(m_world->IsLocked() == false); if (flag == IsActive()) { return; } if (flag) { m_flags |= activeFlag; // Create all proxies. BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; for (Fixture* f = m_fixtureList; f; f = f->m_next) { f->CreateProxies(broadPhase, m_xf); } // Contacts are created the next time step. } else { m_flags &= ~activeFlag; // Destroy all proxies. BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; for (Fixture* f = m_fixtureList; f; f = f->m_next) { f->DestroyProxies(broadPhase); } // Destroy the attached contacts. ContactEdge* ce = m_contactList; while (ce) { ContactEdge* ce0 = ce; ce = ce->next; m_world->m_contactManager.Destroy(ce0->contact); } m_contactList = NULL; } }