Beispiel #1
0
        ///<summary>
        /// Cleans up the pair handler.
        ///</summary>
        public override void CleanUp()
        {
            //Deal with the remaining contacts.
            for (int i = ContactManifold.contacts.count - 1; i >= 0; i--)
            {
                OnContactRemoved(ContactManifold.contacts[i]);
            }

            //If the constraint is still in the solver, then request to have it removed.
            if (ContactConstraint.solver != null)
            {
                ContactConstraint.pair = null; //Setting the pair to null tells the constraint that it's going to be orphaned.  It will be cleaned up on removal.
                if (Parent != null)
                {
                    Parent.RemoveSolverUpdateable(ContactConstraint);
                }
                else if (NarrowPhase != null)
                {
                    NarrowPhase.NotifyUpdateableRemoved(ContactConstraint);
                }
            }
            else
            {
                ContactConstraint.CleanUpReferences();//The constraint isn't in the solver, so we can safely clean it up directly.
                //Even though it's not in the solver, we still may need to notify the parent to remove it.
                if (Parent != null && ContactConstraint.SolverGroup != null)
                {
                    Parent.RemoveSolverUpdateable(ContactConstraint);
                }
            }

            ContactConstraint.CleanUp();


            base.CleanUp();

            ContactManifold.CleanUp();


            //Child cleanup is responsible for cleaning up direct references to the involved collidables.
        }
Beispiel #2
0
        ///<summary>
        /// Cleans up the pair handler.
        ///</summary>
        public override void CleanUp()
        {
            //Deal with the remaining contacts.
            for (int i = ContactManifold.contacts.Count - 1; i >= 0; i--)
            {
                OnContactRemoved(ContactManifold.contacts[i]);
            }

            //If the constraint is still in the solver, then request to have it removed.
            if (ContactConstraint.solver != null)
            {
                if (Parent != null)
                {
                    Parent.RemoveSolverUpdateable(ContactConstraint);
                }
                else if (NarrowPhase != null)
                {
                    NarrowPhase.NotifyUpdateableRemoved(ContactConstraint);
                }
            }
            else
            {
                //Even though it's not in the solver, we still may need to notify the parent to remove it.
                if (Parent != null && ContactConstraint.SolverGroup != null)
                {
                    Parent.RemoveSolverUpdateable(ContactConstraint);
                }
            }

            //Contact constraint cleanup changes the involved entities, which is acceptable because it's no longer in the solver.
            ContactConstraint.CleanUp();


            base.CleanUp();

            ContactManifold.CleanUp();


            //Child cleanup is responsible for cleaning up direct references to the involved collidables.
        }