internal void Destroy(Contact contact) { Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; Body bodyA = fixtureA.Body; Body bodyB = fixtureB.Body; if (contact.IsTouching()) { //Report the separation to both participants: if (bodyA != null) { bodyA.OnSeparation(fixtureA, fixtureB); } //Reverse the order of the reported fixtures. The first fixture is always the one that the //user subscribed to. if (bodyB != null) { bodyB.OnSeparation(fixtureB, fixtureA); } if (this.EndContact != null) { this.EndContact(contact); } } // Remove from the world. this.ContactList.Remove(contact); // Remove from body 1 if (contact.NodeA.Prev != null) { contact.NodeA.Prev.Next = contact.NodeA.Next; } if (contact.NodeA.Next != null) { contact.NodeA.Next.Prev = contact.NodeA.Prev; } if (contact.NodeA == bodyA.ContactList) { bodyA.ContactList = contact.NodeA.Next; } // Remove from body 2 if (contact.NodeB.Prev != null) { contact.NodeB.Prev.Next = contact.NodeB.Next; } if (contact.NodeB.Next != null) { contact.NodeB.Next.Prev = contact.NodeB.Prev; } if (contact.NodeB == bodyB.ContactList) { bodyB.ContactList = contact.NodeB.Next; } contact.Destroy(); }