//TODO: PROBLEM IS that the add contact/remove contact, when they go from 0 -> !0 or !0 -> 0, the whole constraint is added/removed from the solver.
        //The Added/Removed contact methods here will run ambiguously before or after they are removed from the solver.
        //That ambiguous order doesn't really matter though, since everything that these add/remove methods do is local to this solver object and its children.
        //It doesn't go out and modify any external values on referenced entities.  That only happens when it's added or removed from the solver by whatever owns this object!

        //To avoid ANY ambiguity, some third party is now responsible for adding and removing contacts from this.

        ///<summary>
        /// Adds a contact to be managed by the constraint.
        ///</summary>
        ///<param name="contact">Contact to add.</param>
        public override void AddContact(Contact contact)
        {
            contact.Validate();
            var penetrationConstraint = penetrationConstraintPool.Pop();

            penetrationConstraint.Setup(this, contact);
            penetrationConstraints.Add(penetrationConstraint);

            var frictionConstraint = frictionConstraintPool.Pop();

            frictionConstraint.Setup(this, penetrationConstraint);
            frictionConstraints.Add(frictionConstraint);
        }
Exemple #2
0
 protected virtual void OnContactAdded(Contact contact)
 {
     contact.Validate();
     //Children manage the addition of the contact to the constraint, if any.
     if (!suppressEvents)
     {
         CollidableA.EventTriggerer.OnContactCreated(CollidableB, this, contact);
         CollidableB.EventTriggerer.OnContactCreated(CollidableA, this, contact);
     }
     if (Parent != null)
     {
         Parent.OnContactAdded(contact);
     }
 }
        ///<summary>
        /// Adds a contact to be managed by the constraint.
        ///</summary>
        ///<param name="contact">Contact to add.</param>
        public override void AddContact(Contact contact)
        {
            contact.Validate();
            var penetrationConstraint = penetrationConstraintPool.Pop();

            penetrationConstraint.Setup(this, contact);
            penetrationConstraints.Add(penetrationConstraint);
            if (!twistFriction.isActive)
            {
                //This is the first real contact.  All constraints need to become active.
                twistFriction.Setup(this);
                slidingFriction.Setup(this);
            }
        }