void processRemovedBodies()
{
if( _bodyRemoveList.Count > 0 )
{
foreach( Body body in _bodyRemoveList )
{
Debug.Assert( bodyList.Count > 0 );
// You tried to remove a body that is not contained in the BodyList.
// Are you removing the body more than once?
Debug.Assert( bodyList.Contains( body ) );
#if USE_AWAKE_BODY_SET
Debug.Assert(!AwakeBodySet.Contains(body));
#endif
// Delete the attached joints.
JointEdge je = body.jointList;
while( je != null )
{
JointEdge je0 = je;
je = je.next;
removeJoint( je0.joint, false );
}
body.jointList = null;
// Delete the attached contacts.
ContactEdge ce = body.contactList;
while( ce != null )
{
ContactEdge ce0 = ce;
ce = ce.next;
contactManager.destroy( ce0.contact );
}
body.contactList = null;
// Delete the attached fixtures. This destroys broad-phase proxies.
for( int i = 0; i < body.fixtureList.Count; i++ )
{
body.fixtureList[i].destroyProxies( contactManager.broadPhase );
body.fixtureList[i].destroy();
}
body.fixtureList = null;
// Remove world body list.
bodyList.Remove( body );
if( onBodyRemoved != null )
onBodyRemoved( body );
#if USE_AWAKE_BODY_SET
Debug.Assert(!AwakeBodySet.Contains(body));
#endif
}
_bodyRemoveList.Clear();
}
}