///<summary>
        /// Removes a contact from the constraint.
        ///</summary>
        ///<param name="contact">Contact to remove.</param>
        public override void RemoveContact(Contact contact)
        {
            ContactPenetrationConstraint penetrationConstraint = null;

            for (int i = 0; i < penetrationConstraints.Count; i++)
            {
                if ((penetrationConstraint = penetrationConstraints.Elements[i]).contact == contact)
                {
                    penetrationConstraint.CleanUp();
                    penetrationConstraints.RemoveAt(i);
                    penetrationConstraintPool.Push(penetrationConstraint);
                    break;
                }
            }
            for (int i = frictionConstraints.Count - 1; i >= 0; i--)
            {
                ContactFrictionConstraint frictionConstraint = frictionConstraints[i];
                if (frictionConstraint.PenetrationConstraint == penetrationConstraint)
                {
                    frictionConstraint.CleanUp();
                    frictionConstraints.RemoveAt(i);
                    frictionConstraintPool.Push(frictionConstraint);
                    break;
                }
            }
        }
        ///<summary>
        /// Constructs a new nonconvex manifold constraint.
        ///</summary>
        public NonConvexContactManifoldConstraint(CollidablePairHandler pairHandler)
            : base(pairHandler)
        {
            //All of the constraints are always in the solver group.  Some of them are just deactivated sometimes.
            //This reduces some bookkeeping complications.

            penetrationConstraints = new RawList <ContactPenetrationConstraint>(4);
            frictionConstraints    = new RawList <ContactFrictionConstraint>(4);

            for (int i = 0; i < 4; i++)
            {
                var penetrationConstraint = new ContactPenetrationConstraint();
                penetrationConstraintPool.Push(penetrationConstraint);
                Add(penetrationConstraint);

                var frictionConstraint = new ContactFrictionConstraint();
                frictionConstraintPool.Push(frictionConstraint);
                Add(frictionConstraint);
            }
        }