예제 #1
0
        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:
                fixtureA?.RaiseOnSeparation(fixtureA, fixtureB);

                //Reverse the order of the reported fixtures. The first fixture is always the one that the
                //user subscribed to.
                fixtureB?.RaiseOnSeparation(fixtureB, fixtureA);

                if (EndContact != null)
                {
                    EndContact(contact);
                }
            }

            // Remove from the world.
            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;
            }

#if USE_ACTIVE_CONTACT_SET
            if (ActiveContacts.Contains(contact))
            {
                ActiveContacts.Remove(contact);
            }
#endif
            contact.Destroy();
        }