///<summary>
 /// Adds a constraint to the group.
 ///</summary>
 ///<param name="manifoldConstraint">Constraint to add.</param>
 public new void Add(EntitySolverUpdateable manifoldConstraint)
 {
     //This is a similar process to a normal solver group.
     //However, it does not attempt to change involved entities.
     //This is for two reasons:
     //-It is unnecessary; a contact manifold is always between the same two entities throughout its lifespan.
     //-It causes race conditions; this method is called in a multithreaded context and changing involved 
     // entities calls upon sequential-only methods.
     if (manifoldConstraint.solver == null)
     {
         if (manifoldConstraint.SolverGroup == null)
         {
             solverUpdateables.Add(manifoldConstraint);
             manifoldConstraint.SolverGroup = this;
             manifoldConstraint.Solver = solver;
         }
         else
         {
             throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a SolverGroup.");
         }
     }
     else
     {
         throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a solver.");
     }
 }
 protected void UpdateUpdateable(EntitySolverUpdateable item, float dt)
 {
     item.SolverSettings.currentIterations = 0;
     item.SolverSettings.iterationsAtZeroImpulse = 0;
     if (item.isActiveInSolver)
         item.Update(dt);
 }
Exemple #3
0
 protected void ExclusiveUpdateUpdateable(EntitySolverUpdateable item)
 {
     if (item.isActiveInSolver)
     {
         item.ExclusiveUpdate();
     }
 }
 ///<summary>
 /// Adds a constraint to the group.
 ///</summary>
 ///<param name="manifoldConstraint">Constraint to add.</param>
 public new void Add(EntitySolverUpdateable manifoldConstraint)
 {
     //This is a similar process to a normal solver group.
     //However, it does not attempt to change involved entities.
     //This is for two reasons:
     //-It is unnecessary; a contact manifold is always between the same two entities throughout its lifespan.
     //-It causes race conditions; this method is called in a multithreaded context and changing involved
     // entities calls upon sequential-only methods.
     if (manifoldConstraint.solver == null)
     {
         if (manifoldConstraint.SolverGroup == null)
         {
             solverUpdateables.Add(manifoldConstraint);
             manifoldConstraint.SolverGroup = this;
             manifoldConstraint.Solver      = solver;
         }
         else
         {
             throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a SolverGroup.");
         }
     }
     else
     {
         throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a solver.");
     }
 }
Exemple #5
0
        /// <summary>
        /// Solves a child updateable.  Some children may override the group's update method;
        /// this avoids code repeat.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="activeConstraints"> </param>
        protected void SolveUpdateable(EntitySolverUpdateable item, ref int activeConstraints)
        {
            if (item.isActiveInSolver)
            {
                SolverSettings subSolverSettings = item.solverSettings;

                subSolverSettings.currentIterations++;
                if (subSolverSettings.currentIterations <= solver.iterationLimit &&
                    subSolverSettings.currentIterations <= subSolverSettings.maximumIterations)
                {
                    if (item.SolveIteration() < subSolverSettings.minimumImpulse)
                    {
                        subSolverSettings.iterationsAtZeroImpulse++;
                        if (subSolverSettings.iterationsAtZeroImpulse > subSolverSettings.minimumIterations)
                        {
                            item.isActiveInSolver = false;
                        }
                        else
                        {
                            activeConstraints++;
                        }
                    }
                    else
                    {
                        subSolverSettings.iterationsAtZeroImpulse = 0;
                        activeConstraints++;
                    }
                }
                else
                {
                    item.isActiveInSolver = false;
                }
            }
        }
Exemple #6
0
 protected void UpdateUpdateable(EntitySolverUpdateable item, float dt)
 {
     item.SolverSettings.currentIterations       = 0;
     item.SolverSettings.iterationsAtZeroImpulse = 0;
     if (item.isActiveInSolver)
     {
         item.Update(dt);
     }
 }
Exemple #7
0
 /// <summary>
 /// Removes a solver updateable from the group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to remove.</param>
 /// <exception cref="InvalidOperationException">Thrown when the SolverUpdateable to remove from the SolverGroup doesn't actually belong to this SolverGroup.</exception>
 protected void Remove(EntitySolverUpdateable solverUpdateable)
 {
     if (solverUpdateable.SolverGroup == this)
     {
         solverUpdateables.Remove(solverUpdateable);
         solverUpdateable.SolverGroup = null;
         solverUpdateable.Solver      = null;
         OnInvolvedEntitiesChanged();
     }
     else
     {
         throw new InvalidOperationException("Cannot remove SolverUpdateable from SolverGroup; it doesn't belong to this SolverGroup.");
     }
 }
 void IPairHandlerParent.AddSolverUpdateable(EntitySolverUpdateable addedItem)
 {
     manifoldConstraintGroup.Add(addedItem);
     //If this is the first child solver item to be added, we need to add ourselves to our parent too.
     if (manifoldConstraintGroup.SolverUpdateables.Count == 1)
     {
         if (Parent != null)
         {
             Parent.AddSolverUpdateable(manifoldConstraintGroup);
         }
         else if (NarrowPhase != null)
         {
             NarrowPhase.NotifyUpdateableAdded(manifoldConstraintGroup);
         }
     }
 }
        void IPairHandlerParent.RemoveSolverUpdateable(EntitySolverUpdateable removedItem)
        {
            manifoldConstraintGroup.Remove(removedItem);

            //If this is the last child solver item, we need to remove ourselves from our parent too.
            if (manifoldConstraintGroup.SolverUpdateables.Count == 0)
            {
                if (Parent != null)
                {
                    Parent.RemoveSolverUpdateable(manifoldConstraintGroup);
                }
                else if (NarrowPhase != null)
                {
                    NarrowPhase.NotifyUpdateableRemoved(manifoldConstraintGroup);
                }
            }
        }
Exemple #10
0
 /// <summary>
 /// Adds a solver updateable to the group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to add.</param>
 /// <exception cref="InvalidOperationException">Thrown when the SolverUpdateable to add to the SolverGroup already belongs to another SolverGroup or to a Space.</exception>
 protected void Add(EntitySolverUpdateable solverUpdateable)
 {
     if (solverUpdateable.solver == null)
     {
         if (solverUpdateable.SolverGroup == null)
         {
             solverUpdateables.Add(solverUpdateable);
             solverUpdateable.SolverGroup = this;
             solverUpdateable.Solver      = solver;
             OnInvolvedEntitiesChanged();
         }
         else
         {
             throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a SolverGroup.");
         }
     }
     else
     {
         throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a solver.");
     }
 }
 /// <summary>
 /// Removes a solver updateable from the group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to remove.</param>
 /// <exception cref="InvalidOperationException">Thrown when the SolverUpdateable to remove from the SolverGroup doesn't actually belong to this SolverGroup.</exception>
 protected void Remove(EntitySolverUpdateable solverUpdateable)
 {
     if (solverUpdateable.SolverGroup == this)
     {
         solverUpdateables.Remove(solverUpdateable);
         solverUpdateable.SolverGroup = null;
         solverUpdateable.Solver = null;
         OnInvolvedEntitiesChanged();
     }
     else
     {
         throw new InvalidOperationException("Cannot remove SolverUpdateable from SolverGroup; it doesn't belong to this SolverGroup.");
     }
 }
        /// <summary>
        /// Solves a child updateable.  Some children may override the group's update method;
        /// this avoids code repeat.
        /// </summary>
        /// <param name="item"></param>
        protected void SolveUpdateable(EntitySolverUpdateable item, ref int activeConstraints)
        {
            if (item.isActiveInSolver)
            {
                SolverSettings subSolverSettings = item.solverSettings;

                subSolverSettings.currentIterations++;
                if (subSolverSettings.currentIterations <= solver.iterationLimit &&
                    subSolverSettings.currentIterations <= subSolverSettings.maximumIterations)
                {
                    if (item.SolveIteration() < subSolverSettings.minimumImpulse)
                    {
                        subSolverSettings.iterationsAtZeroImpulse++;
                        if (subSolverSettings.iterationsAtZeroImpulse > subSolverSettings.minimumIterations)
                            item.isActiveInSolver = false;
                        else
                        {
                            activeConstraints++;
                        }

                    }
                    else
                    {
                        subSolverSettings.iterationsAtZeroImpulse = 0;
                        activeConstraints++;
                    }
                }
                else
                {
                    item.isActiveInSolver = false;
                }

            }
        }
 /// <summary>
 /// Adds a solver updateable to the group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to add.</param>
 /// <exception cref="InvalidOperationException">Thrown when the SolverUpdateable to add to the SolverGroup already belongs to another SolverGroup or to a Space.</exception>
 protected void Add(EntitySolverUpdateable solverUpdateable)
 {
     if (solverUpdateable.solver == null)
     {
         if (solverUpdateable.SolverGroup == null)
         {
             solverUpdateables.Add(solverUpdateable);
             solverUpdateable.SolverGroup = this;
             solverUpdateable.Solver = solver;
             OnInvolvedEntitiesChanged();
         }
         else
         {
             throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a SolverGroup.");
         }
     }
     else
     {
         throw new InvalidOperationException("Cannot add SolverUpdateable to SolverGroup; it already belongs to a solver.");
     }
 }
Exemple #14
0
 internal MotorSettingsOrientation(EntitySolverUpdateable motor)
     : base(motor)
 {
     servo         = new ServoSettingsOrientation(this);
     velocityMotor = new VelocityMotorSettings3D(this);
 }
Exemple #15
0
 internal MotorSettings(EntitySolverUpdateable motor)
 {
     this.motor = motor;
 }
Exemple #16
0
        void IPairHandlerParent.RemoveSolverUpdateable(EntitySolverUpdateable removedItem)
        {

            manifoldConstraintGroup.Remove(removedItem);

            //If this is the last child solver item, we need to remove ourselves from our parent too.
            if (manifoldConstraintGroup.SolverUpdateables.Count == 0)
            {
                if (Parent != null)
                    Parent.RemoveSolverUpdateable(manifoldConstraintGroup);
                else if (NarrowPhase != null)
                    NarrowPhase.NotifyUpdateableRemoved(manifoldConstraintGroup);
            }


        }
Exemple #17
0
        void IPairHandlerParent.AddSolverUpdateable(EntitySolverUpdateable addedItem)
        {

            manifoldConstraintGroup.Add(addedItem);
            //If this is the first child solver item to be added, we need to add ourselves to our parent too.
            if (manifoldConstraintGroup.SolverUpdateables.Count == 1)
            {
                if (Parent != null)
                    Parent.AddSolverUpdateable(manifoldConstraintGroup);
                else if (NarrowPhase != null)
                    NarrowPhase.NotifyUpdateableAdded(manifoldConstraintGroup);
            }

        }
 /// <summary>
 /// Adds a new solver updateable to the solver group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to add.</param>
 public new void Add(EntitySolverUpdateable solverUpdateable)
 {
     base.Add(solverUpdateable);
 }
 /// <summary>
 /// Removes a solver updateable from the solver group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to remove.</param>
 public new void Remove(EntitySolverUpdateable solverUpdateable)
 {
     base.Remove(solverUpdateable);
 }
 /// <summary>
 /// Removes a solver updateable from the solver group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to remove.</param>
 public new void Remove(EntitySolverUpdateable solverUpdateable)
 {
     base.Remove(solverUpdateable);
 }
Exemple #21
0
 internal MotorSettingsOrientation(EntitySolverUpdateable motor)
     : base(motor)
 {
     servo = new ServoSettingsOrientation(this);
     velocityMotor = new VelocityMotorSettings3D(this);
 }
Exemple #22
0
 internal MotorSettings(EntitySolverUpdateable motor)
 {
     this.motor = motor;
 }
 protected void ExclusiveUpdateUpdateable(EntitySolverUpdateable item)
 {
     if (item.isActiveInSolver)
         item.ExclusiveUpdate();
 }
 /// <summary>
 /// Adds a new solver updateable to the solver group.
 /// </summary>
 /// <param name="solverUpdateable">Solver updateable to add.</param>
 public new void Add(EntitySolverUpdateable solverUpdateable)
 {
     base.Add(solverUpdateable);
 }