示例#1
0
 ///<summary>
 /// Enqueues a change to an entity's position.
 ///</summary>
 ///<param name="entity">Entity to target.</param>
 ///<param name="newPosition">New position of the entity.</param>
 public void EnqueuePosition(Entity entity, ref Vector3 newPosition)
 {
     stateChanges.Enqueue(new EntityStateChange
     {
         target = entity, vector = newPosition, targetField = TargetField.Position
     });
 }
示例#2
0
 ///<summary>
 /// Enqueues a solver updateable created by some pair for flushing into the solver later.
 ///</summary>
 ///<param name="addedItem">Updateable to add.</param>
 public void NotifyUpdateableAdded(SolverUpdateable addedItem)
 {
     if (ApplySolverUpdateableChangesDirectly)
     {
         Solver.Add(addedItem);
     }
     else
     {
         solverUpdateableChanges.Enqueue(new SolverUpdateableChange(true, addedItem));
     }
 }
示例#3
0
        void UpdateBroadPhaseOverlap(int i)
        {
            BroadPhaseOverlap overlap = broadPhaseOverlaps.Elements[i];

            if (overlap.collisionRule < CollisionRule.NoNarrowPhasePair)
            {
                NarrowPhasePair pair;
                //see if the overlap is already present in the narrow phase.
                if (!overlapMapping.TryGetValue(overlap, out pair))
                {
                    //Create/enqueue based on collision table
                    pair = NarrowPhaseHelper.GetPairHandler(ref overlap);
                    if (pair != null)
                    {
                        pair.NarrowPhase = this;
                        //Add the new object to the 'todo' list.
                        //Technically, this doesn't need to be thread-safe when this is called from the sequential context.
                        //It's just bunched together for maintainability despite the slight performance hit.
                        newNarrowPhasePairs.Enqueue(pair);
                    }
                }
                if (pair != null)
                {
                    //Update the collision rule.
                    pair.CollisionRule = overlap.collisionRule;
                    if (pair.BroadPhaseOverlap.collisionRule < CollisionRule.NoNarrowPhaseUpdate)
                    {
                        pair.UpdateCollision(TimeStepSettings.TimeStepDuration);
                    }
                    pair.NeedsUpdate = false;
                }
            }
        }
 public void OnCollisionEnded(Collidable other, CollidablePairHandler collisionPair)
 {
     if (InternalCollisionEnded != null)
     {
         eventStorageCollisionEnded.Enqueue(new EventStorageCollisionEnded(other, collisionPair));
     }
     if (CollisionEnding != null)
     {
         CollisionEnding(owner, other, collisionPair);
     }
 }
 public void OnInitialCollisionDetected(Collidable other, CollidablePairHandler collisionPair)
 {
     if (InternalInitialCollisionDetected != null)
     {
         eventStorageInitialCollisionDetected.Enqueue(new EventStorageInitialCollisionDetected(other, collisionPair));
     }
     if (DetectingInitialCollision != null)
     {
         DetectingInitialCollision(owner, other, collisionPair);
     }
 }
 public void OnPairTouching(Collidable other, CollidablePairHandler collisionPair)
 {
     if (InternalPairTouched != null)
     {
         eventStoragePairTouched.Enqueue(new EventStoragePairTouched(other, collisionPair));
     }
     if (PairTouching != null)
     {
         PairTouching(owner, other, collisionPair);
     }
 }
 public void OnPairRemoved(BroadPhaseEntry other)
 {
     if (InternalPairRemoved != null)
     {
         eventStoragePairRemoved.Enqueue(new EventStoragePairRemoved(other));
     }
     if (RemovingPair != null)
     {
         RemovingPair(owner, other);
     }
 }
 public void OnPairUpdated(BroadPhaseEntry other, NarrowPhasePair collisionPair)
 {
     if (InternalPairUpdated != null)
     {
         eventStoragePairUpdated.Enqueue(new EventStoragePairUpdated(other, collisionPair));
     }
     if (PairUpdating != null)
     {
         PairUpdating(owner, other, collisionPair);
     }
 }
 public void OnContactRemoved(Collidable other, CollidablePairHandler collisionPair, Contact contact)
 {
     if (InternalContactRemoved != null)
     {
         ContactData contactData;
         contactData.Position         = contact.Position;
         contactData.Normal           = contact.Normal;
         contactData.PenetrationDepth = contact.PenetrationDepth;
         contactData.Id = contact.Id;
         eventStorageContactRemoved.Enqueue(new EventStorageContactRemoved(other, collisionPair, ref contactData));
     }
     if (RemovingContact != null)
     {
         RemovingContact(owner, other, collisionPair, contact);
     }
 }
示例#10
0
        ///<summary>
        /// Removes a simulation island connection from the manager.
        ///</summary>
        ///<param name="connection">Connection to remove from the manager.</param>
        ///<exception cref="ArgumentException">Thrown if the connection does not belong to this manager.</exception>
        public void Remove(SimulationIslandConnection connection)
        {
            if (connection.DeactivationManager == this)
            {
                connection.DeactivationManager = null;

                connection.SlatedForRemoval = true;

                //Don't immediately do simulation island management.
                //Defer the splits!
                splitAttempts.Enqueue(connection);
            }
            else
            {
                throw new ArgumentException("Cannot remove connection from activity manager; it is owned by a different or no activity manager.");
            }
        }
示例#11
0
 /// <summary>
 /// Gives an item back to the resource pool.
 /// </summary>
 /// <param name="item">Item to return.</param>
 public override void GiveBack(T item)
 {
     stack.Enqueue(item);
 }
示例#12
0
 ///<summary>
 /// Enqueues a change to an entity's angular velocity.
 ///</summary>
 ///<param name="entity">Entity to target.</param>
 ///<param name="newAngularVelocity">New angular velocity of the entity.</param>
 public void EnqueueAngularVelocity(Entity entity, ref Vector3 newAngularVelocity)
 {
     stateChanges.Enqueue(new EntityStateChange { target = entity, vector = newAngularVelocity, targetField = TargetField.AngularVelocity });
 }
示例#13
0
 ///<summary>
 /// Adds a space object to the buffer.
 /// It will be added to the space the next time the buffer is flushed.
 ///</summary>
 ///<param name="spaceObject">Space object to add.</param>
 public void Add(ISpaceObject spaceObject)
 {
     objectsToChange.Enqueue(new SpaceObjectChange(spaceObject, true));
 }
示例#14
0
 ///<summary>
 /// Enqueues a solver updateable created by some pair for flushing into the solver later.
 ///</summary>
 ///<param name="addedItem">Updateable to add.</param>
 public void NotifyUpdateableAdded(SolverUpdateable addedItem)
 {
     solverUpdateableChanges.Enqueue(new SolverUpdateableChange(true, addedItem));
 }