Пример #1
0
        ///<summary>
        /// Removes an updateable from the updater.
        ///</summary>
        ///<param name="updateable">Item to remove.</param>
        ///<exception cref="Exception">Thrown if the updater does not own the updateable.</exception>
        public override void Remove(IPositionUpdateable updateable)
        {
            if (updateable.PositionUpdater == this)
            {
                updateable.PositionUpdater = null;
                var ccdUpdateable = updateable as ICCDPositionUpdateable;
                if (ccdUpdateable != null)
                {
                    switch (ccdUpdateable.PositionUpdateMode)
                    {
                    case PositionUpdateMode.Discrete:
                        discreteUpdateables.Remove(updateable);
                        break;

                    case PositionUpdateMode.Passive:
                        passiveUpdateables.Remove(ccdUpdateable);
                        break;

                    case PositionUpdateMode.Continuous:
                        continuousUpdateables.Remove(ccdUpdateable);
                        break;
                    }
                }
                else
                {
                    discreteUpdateables.Remove(updateable);
                }
            }
            else
            {
                throw new ArgumentException("Cannot remove object from this Integrator.  The object doesn't belong to it.");
            }
        }
 ///<summary>
 /// Adds an object to the position updater.
 ///</summary>
 ///<param name="updateable">Updateable to add.</param>
 ///<exception cref="Exception">Thrown if the updateable already belongs to a position updater.</exception>
 public override void Add(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == null)
     {
         updateable.PositionUpdater = this;
         var ccdUpdateable = updateable as ICCDPositionUpdateable;
         if (ccdUpdateable != null)
         {
             switch (ccdUpdateable.PositionUpdateMode)
             {
                 case PositionUpdateMode.Discrete:
                     discreteUpdateables.Add(updateable);
                     break;
                 case PositionUpdateMode.Passive:
                     passiveUpdateables.Add(ccdUpdateable);
                     break;
                 case PositionUpdateMode.Continuous:
                     continuousUpdateables.Add(ccdUpdateable);
                     break;
             }
         }
         else
             discreteUpdateables.Add(updateable);
     }
     else
     {
         throw new ArgumentException("Cannot add object to Integrator; it already belongs to one.");
     }
 }
Пример #3
0
        ///<summary>
        /// Adds an object to the position updater.
        ///</summary>
        ///<param name="updateable">Updateable to add.</param>
        ///<exception cref="Exception">Thrown if the updateable already belongs to a position updater.</exception>
        public override void Add(IPositionUpdateable updateable)
        {
            if (updateable.PositionUpdater == null)
            {
                updateable.PositionUpdater = this;
                var ccdUpdateable = updateable as ICCDPositionUpdateable;
                if (ccdUpdateable != null)
                {
                    switch (ccdUpdateable.PositionUpdateMode)
                    {
                    case PositionUpdateMode.Discrete:
                        discreteUpdateables.Add(updateable);
                        break;

                    case PositionUpdateMode.Passive:
                        passiveUpdateables.Add(ccdUpdateable);
                        break;

                    case PositionUpdateMode.Continuous:
                        continuousUpdateables.Add(ccdUpdateable);
                        break;
                    }
                }
                else
                {
                    discreteUpdateables.Add(updateable);
                }
            }
            else
            {
                throw new ArgumentException("Cannot add object to Integrator; it already belongs to one.");
            }
        }
Пример #4
0
 /// <summary>
 /// Removes an updateable from the updater.
 /// </summary>
 /// <param name="updateable">Updateable to remove.</param>
 public override void Remove(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == this)
     {
         updateable.PositionUpdater = null;
         integrables.Remove(updateable);
     }
     else
         throw new Exception("Cannot remove object from this position updater.  The object doesn't belong to it.");
 }
Пример #5
0
 /// <summary>
 /// Removes an updateable from the updater.
 /// </summary>
 /// <param name="updateable">Updateable to remove.</param>
 public override void Remove(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == this)
     {
         updateable.PositionUpdater = null;
         integrables.Remove(updateable);
     }
     else
     {
         throw new Exception("Cannot remove object from this position updater.  The object doesn't belong to it.");
     }
 }
Пример #6
0
 ///<summary>
 /// Adds an updateable to the updater.
 ///</summary>
 ///<param name="updateable">Item to add.</param>
 ///<exception cref="Exception">Thrown if the updateable already belongs to an updater.</exception>
 public override void Add(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == null)
     {
         updateable.PositionUpdater = this;
         integrables.Add(updateable);
     }
     else
     {
         throw new Exception("Cannot add object to position updater; it already belongs to one.");
     }
 }
Пример #7
0
 ///<summary>
 /// Adds an updateable to the updater.
 ///</summary>
 ///<param name="updateable">Item to add.</param>
 ///<exception cref="Exception">Thrown if the updateable already belongs to an updater.</exception>
 public override void Add(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == null)
     {
         updateable.PositionUpdater = this;
         integrables.Add(updateable);
     }
     else
     {
         throw new Exception("Cannot add object to position updater; it already belongs to one.");
     }
 }
Пример #8
0
        ///<summary>
        /// Removes a space object from the simulation.
        ///</summary>
        ///<param name="spaceObject">Space object to remove.</param>
        public void Remove(ISpaceObject spaceObject)
        {
            if (spaceObject.Space != this)
            {
                throw new ArgumentException("The object does not belong to this space; cannot remove it.");
            }

            SimulationIslandMember simulationIslandMember = spaceObject as SimulationIslandMember;

            if (simulationIslandMember != null)
            {
                DeactivationManager.Remove(simulationIslandMember);
            }

            ISimulationIslandMemberOwner simulationIslandMemberOwner = spaceObject as ISimulationIslandMemberOwner;

            if (simulationIslandMemberOwner != null)
            {
                DeactivationManager.Remove(simulationIslandMemberOwner.ActivityInformation);
            }

            //Go through each stage, removing the space object from it if necessary.
            IForceUpdateable velocityUpdateable = spaceObject as IForceUpdateable;

            if (velocityUpdateable != null)
            {
                ForceUpdater.Remove(velocityUpdateable);
            }

            MobileCollidable boundingBoxUpdateable = spaceObject as MobileCollidable;

            if (boundingBoxUpdateable != null)
            {
                BoundingBoxUpdater.Remove(boundingBoxUpdateable);
            }

            BroadPhaseEntry broadPhaseEntry = spaceObject as BroadPhaseEntry;

            if (broadPhaseEntry != null)
            {
                BroadPhase.Remove(broadPhaseEntry);
            }

            //Entites own collision proxies, but are not entries themselves.
            IBroadPhaseEntryOwner broadPhaseEntryOwner = spaceObject as IBroadPhaseEntryOwner;

            if (broadPhaseEntryOwner != null)
            {
                BroadPhase.Remove(broadPhaseEntryOwner.Entry);
                boundingBoxUpdateable = broadPhaseEntryOwner.Entry as MobileCollidable;
                if (boundingBoxUpdateable != null)
                {
                    BoundingBoxUpdater.Remove(boundingBoxUpdateable);
                }
            }

            SolverUpdateable solverUpdateable = spaceObject as SolverUpdateable;

            if (solverUpdateable != null)
            {
                Solver.Remove(solverUpdateable);
            }

            IPositionUpdateable integrable = spaceObject as IPositionUpdateable;

            if (integrable != null)
            {
                PositionUpdater.Remove(integrable);
            }

            Entity entity = spaceObject as Entity;

            if (entity != null)
            {
                BufferedStates.Remove(entity);
            }

            IDeferredEventCreator deferredEventCreator = spaceObject as IDeferredEventCreator;

            if (deferredEventCreator != null)
            {
                DeferredEventDispatcher.RemoveEventCreator(deferredEventCreator);
            }

            IDeferredEventCreatorOwner deferredEventCreatorOwner = spaceObject as IDeferredEventCreatorOwner;

            if (deferredEventCreatorOwner != null)
            {
                DeferredEventDispatcher.RemoveEventCreator(deferredEventCreatorOwner.EventCreator);
            }

            //Updateable stages.
            IDuringForcesUpdateable duringForcesUpdateable = spaceObject as IDuringForcesUpdateable;

            if (duringForcesUpdateable != null)
            {
                DuringForcesUpdateables.Remove(duringForcesUpdateable);
            }

            IBeforeNarrowPhaseUpdateable beforeNarrowPhaseUpdateable = spaceObject as IBeforeNarrowPhaseUpdateable;

            if (beforeNarrowPhaseUpdateable != null)
            {
                BeforeNarrowPhaseUpdateables.Remove(beforeNarrowPhaseUpdateable);
            }

            IBeforeSolverUpdateable beforeSolverUpdateable = spaceObject as IBeforeSolverUpdateable;

            if (beforeSolverUpdateable != null)
            {
                BeforeSolverUpdateables.Remove(beforeSolverUpdateable);
            }


            IBeforePositionUpdateUpdateable beforePositionUpdateUpdateable = spaceObject as IBeforePositionUpdateUpdateable;

            if (beforePositionUpdateUpdateable != null)
            {
                BeforePositionUpdateUpdateables.Remove(beforePositionUpdateUpdateable);
            }

            IEndOfTimeStepUpdateable endOfStepUpdateable = spaceObject as IEndOfTimeStepUpdateable;

            if (endOfStepUpdateable != null)
            {
                EndOfTimeStepUpdateables.Remove(endOfStepUpdateable);
            }

            IEndOfFrameUpdateable endOfFrameUpdateable = spaceObject as IEndOfFrameUpdateable;

            if (endOfFrameUpdateable != null)
            {
                EndOfFrameUpdateables.Remove(endOfFrameUpdateable);
            }

            spaceObject.Space = null;
            spaceObject.OnRemovalFromSpace(this);
        }
Пример #9
0
 ///<summary>
 /// Removes an updateable from the updater.
 ///</summary>
 ///<param name="updateable">Item to remove.</param>
 ///<exception cref="Exception">Thrown if the updater does not own the updateable.</exception>
 public abstract void Remove(IPositionUpdateable updateable);
Пример #10
0
 ///<summary>
 /// Adds an object to the position updater.
 ///</summary>
 ///<param name="updateable">Updateable to add.</param>
 ///<exception cref="Exception">Thrown if the updateable already belongs to a position updater.</exception>
 public abstract void Add(IPositionUpdateable updateable);
 ///<summary>
 /// Removes an updateable from the updater.
 ///</summary>
 ///<param name="updateable">Item to remove.</param>
 ///<exception cref="Exception">Thrown if the updater does not own the updateable.</exception>
 public abstract void Remove(IPositionUpdateable updateable);
 ///<summary>
 /// Adds an object to the position updater.
 ///</summary>
 ///<param name="updateable">Updateable to add.</param>
 ///<exception cref="Exception">Thrown if the updateable already belongs to a position updater.</exception>
 public abstract void Add(IPositionUpdateable updateable);
 ///<summary>
 /// Removes an updateable from the updater.
 ///</summary>
 ///<param name="updateable">Item to remove.</param>
 ///<exception cref="Exception">Thrown if the updater does not own the updateable.</exception>
 public override void Remove(IPositionUpdateable updateable)
 {
     if (updateable.PositionUpdater == this)
     {
         updateable.PositionUpdater = null;
         var ccdUpdateable = updateable as ICCDPositionUpdateable;
         if (ccdUpdateable != null)
         {
             switch (ccdUpdateable.PositionUpdateMode)
             {
                 case PositionUpdateMode.Discrete:
                     discreteUpdateables.Remove(updateable);
                     break;
                 case PositionUpdateMode.Passive:
                     passiveUpdateables.Remove(ccdUpdateable);
                     break;
                 case PositionUpdateMode.Continuous:
                     continuousUpdateables.Remove(ccdUpdateable);
                     break;
             }
         }
         else
             discreteUpdateables.Remove(updateable);
     }
     else
         throw new ArgumentException("Cannot remove object from this Integrator.  The object doesn't belong to it.");
 }