| 129 | } |
| 130 | |
| 131 | void b2World::DestroyBody(b2Body* b) |
| 132 | { |
| 133 | b2Assert(m_bodyCount > 0); |
| 134 | b2Assert(IsLocked() == false); |
| 135 | if (IsLocked()) |
| 136 | { |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | // Delete the attached joints. |
| 141 | b2JointEdge* je = b->m_jointList; |
| 142 | while (je) |
| 143 | { |
| 144 | b2JointEdge* je0 = je; |
| 145 | je = je->next; |
| 146 | |
| 147 | if (m_destructionListener) |
| 148 | { |
| 149 | m_destructionListener->SayGoodbye(je0->joint); |
| 150 | } |
| 151 | |
| 152 | DestroyJoint(je0->joint); |
| 153 | |
| 154 | b->m_jointList = je; |
| 155 | } |
| 156 | b->m_jointList = NULL; |
| 157 | |
| 158 | // Delete the attached contacts. |
| 159 | b2ContactEdge* ce = b->m_contactList; |
| 160 | while (ce) |
| 161 | { |
| 162 | b2ContactEdge* ce0 = ce; |
| 163 | ce = ce->next; |
| 164 | m_contactManager.Destroy(ce0->contact); |
| 165 | } |
| 166 | b->m_contactList = NULL; |
| 167 | |
| 168 | // Delete the attached fixtures. This destroys broad-phase proxies. |
| 169 | b2Fixture* f = b->m_fixtureList; |
| 170 | while (f) |
| 171 | { |
| 172 | b2Fixture* f0 = f; |
| 173 | f = f->m_next; |
| 174 | |
| 175 | if (m_destructionListener) |
| 176 | { |
| 177 | m_destructionListener->SayGoodbye(f0); |
| 178 | } |
| 179 | |
| 180 | f0->DestroyProxies(&m_contactManager.m_broadPhase); |
| 181 | f0->Destroy(&m_blockAllocator); |
| 182 | f0->~b2Fixture(); |
| 183 | m_blockAllocator.Free(f0, sizeof(b2Fixture)); |
| 184 | |
| 185 | b->m_fixtureList = f; |
| 186 | b->m_fixtureCount -= 1; |
| 187 | } |
| 188 | b->m_fixtureList = NULL; |
no test coverage detected