protected internal void UnsafeSolveIteration(SolverUpdateable updateable) { if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations++; if (solverSettings.currentIterations <= iterationLimit && solverSettings.currentIterations <= solverSettings.maximumIterationCount) { if (updateable.SolveIteration() < solverSettings.minimumImpulse) { solverSettings.iterationsAtZeroImpulse++; if (solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterationCount) { updateable.isActiveInSolver = false; } } else { solverSettings.iterationsAtZeroImpulse = 0; } } else { updateable.isActiveInSolver = false; } } }
///<summary> /// Removes a solver updateable from the solver. ///</summary> ///<param name="item">Updateable to remove.</param> ///<exception cref="ArgumentException">Thrown when the item does not belong to the solver.</exception> public void Remove(SolverUpdateable item) { if (item.Solver == this) { item.Solver = null; solverUpdateables.Count--; if (item.solverIndex < solverUpdateables.Count) { //The solver updateable isn't the last element, so put the last element in its place. solverUpdateables.Elements[item.solverIndex] = solverUpdateables.Elements[solverUpdateables.Count]; //Update the replacement's solver index to its new location. solverUpdateables.Elements[item.solverIndex].solverIndex = item.solverIndex; } solverUpdateables.Elements[solverUpdateables.Count] = null; DeactivationManager.Remove(item.simulationIslandConnection); item.OnRemovalFromSolver(this); } else { throw new ArgumentException("Solver updateable doesn't belong to this solver; it can't be removed.", "item"); } }
protected internal void UnsafePrestep(SolverUpdateable updateable) { updateable.UpdateSolverActivity(); if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations = 0; solverSettings.iterationsAtZeroImpulse = 0; updateable.Update(timeStepSettings.TimeStepDuration); updateable.ExclusiveUpdate(); } }
///<summary> /// Adds a solver updateable to the solver. ///</summary> ///<param name="item">Updateable to add.</param> ///<exception cref="ArgumentException">Thrown when the item already belongs to a solver.</exception> public void Add(SolverUpdateable item) { if (item.Solver == null) { item.Solver = this; item.solverIndex = solverUpdateables.Count; solverUpdateables.Add(item); DeactivationManager.Add(item.simulationIslandConnection); item.OnAdditionToSolver(this); } else throw new ArgumentException("Solver updateable already belongs to something; it can't be added.", "item"); }
///<summary> /// Adds a solver updateable to the solver. ///</summary> ///<param name="item">Updateable to add.</param> ///<exception cref="ArgumentException">Thrown when the item already belongs to a solver.</exception> public void Add(SolverUpdateable item) { if (item.Solver == null) { item.Solver = this; item.solverIndex = solverUpdateables.count; solverUpdateables.Add(item); DeactivationManager.Add(item.simulationIslandConnection); item.OnAdditionToSolver(this); } else { throw new ArgumentException("Solver updateable already belongs to something; it can't be added.", "item"); } }
protected internal void UnsafeSolveIteration(SolverUpdateable updateable) { if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations++; if (solverSettings.currentIterations <= iterationLimit && solverSettings.currentIterations <= solverSettings.maximumIterations) { if (updateable.SolveIteration() < solverSettings.minimumImpulse) { solverSettings.iterationsAtZeroImpulse++; if (solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterations) { updateable.isActiveInSolver = false; } } else { solverSettings.iterationsAtZeroImpulse = 0; } } else { updateable.isActiveInSolver = false; } //if (++solverSettings.currentIterations > iterationLimit || // solverSettings.currentIterations > solverSettings.maximumIterations || // (updateable.SolveIteration() < solverSettings.minimumImpulse && // ++solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterations)) //{ // updateable.isActiveInSolver = false; //} //else //If it's greater than the minimum impulse, reset the count. // solverSettings.iterationsAtZeroImpulse = 0; } }
public void Add(SolverUpdateable joint) { _joints.Add(joint); }
protected internal void UnsafeSolveIteration(SolverUpdateable updateable) { if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations++; if (solverSettings.currentIterations <= iterationLimit && solverSettings.currentIterations <= solverSettings.maximumIterations) { if (updateable.SolveIteration() < solverSettings.minimumImpulse) { solverSettings.iterationsAtZeroImpulse++; if (solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterations) updateable.isActiveInSolver = false; } else { solverSettings.iterationsAtZeroImpulse = 0; } } else { updateable.isActiveInSolver = false; } //if (++solverSettings.currentIterations > iterationLimit || // solverSettings.currentIterations > solverSettings.maximumIterations || // (updateable.SolveIteration() < solverSettings.minimumImpulse && // ++solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterations)) //{ // updateable.isActiveInSolver = false; //} //else //If it's greater than the minimum impulse, reset the count. // solverSettings.iterationsAtZeroImpulse = 0; } }
protected internal void UnsafePrestep(SolverUpdateable updateable) { updateable.UpdateSolverActivity(); if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations = 0; solverSettings.iterationsAtZeroImpulse = 0; updateable.Update(timeStepSettings.TimeStepDuration); updateable.ExclusiveUpdate(); } }
///<summary> /// Removes a solver updateable from the solver. ///</summary> ///<param name="item">Updateable to remove.</param> ///<exception cref="ArgumentException">Thrown when the item does not belong to the solver.</exception> public void Remove(SolverUpdateable item) { if (item.Solver == this) { item.Solver = null; solverUpdateables.Count--; if (item.solverIndex < solverUpdateables.Count) { //The solver updateable isn't the last element, so put the last element in its place. solverUpdateables.Elements[item.solverIndex] = solverUpdateables.Elements[solverUpdateables.Count]; //Update the replacement's solver index to its new location. solverUpdateables.Elements[item.solverIndex].solverIndex = item.solverIndex; } solverUpdateables.Elements[solverUpdateables.Count] = null; DeactivationManager.Remove(item.simulationIslandConnection); item.OnRemovalFromSolver(this); } else throw new ArgumentException("Solver updateable doesn't belong to this solver; it can't be removed.", "item"); }
protected internal void UnsafeSolveIteration(SolverUpdateable updateable) { if (updateable.isActiveInSolver) { SolverSettings solverSettings = updateable.solverSettings; solverSettings.currentIterations++; if (solverSettings.currentIterations <= iterationLimit && solverSettings.currentIterations <= solverSettings.maximumIterationCount) { if (updateable.SolveIteration() < solverSettings.minimumImpulse) { solverSettings.iterationsAtZeroImpulse++; if (solverSettings.iterationsAtZeroImpulse > solverSettings.minimumIterationCount) updateable.isActiveInSolver = false; } else { solverSettings.iterationsAtZeroImpulse = 0; } } else { updateable.isActiveInSolver = false; } } }
//-------------------------------------------------------------------------- #region Joints static public void RemoveJoint(SolverUpdateable joint) { World.Remove(joint); }