コード例 #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:
                if (fixtureA != null && fixtureA.OnSeparation != null)
                {
                    fixtureA.OnSeparation(fixtureA, fixtureB);
                }

                //Reverse the order of the reported fixtures. The first fixture is always the one that the
                //user subscribed to.
                if (fixtureB != null && fixtureB.OnSeparation != null)
                {
                    fixtureB.OnSeparation(fixtureB, fixtureA);
                }

                if (OnEndContact != null)
                {
                    OnEndContact(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();
        }
コード例 #2
0
ファイル: ContactManager.cs プロジェクト: GDxU/GoalRush
        internal void Destroy(Contact contact)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body    bodyA    = fixtureA.Body;
            Body    bodyB    = fixtureB.Body;

            if (EndContact != null && contact.IsTouching())
            {
                EndContact(contact);
            }

            if (contact.IsTouching())
            {
                //Report the separation to both participants:
                if (fixtureA != null && fixtureA.OnSeparation != null)
                {
                    fixtureA.OnSeparation(fixtureA, fixtureB);
                }

                if (fixtureB != null && fixtureB.OnSeparation != null)
                {
                    fixtureB.OnSeparation(fixtureB, fixtureA);
                }
            }

            // 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;
            }

            contact.Destroy();
        }