Пример #1
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;
                }
            }
        }
Пример #2
0
 public void OnPairUpdated(BroadPhaseEntry other, NarrowPhasePair collisionPair)
 {
     if (InternalPairUpdated != null)
     {
         eventStoragePairUpdated.Enqueue(new EventStoragePairUpdated(other, collisionPair));
     }
     if (PairUpdating != null)
     {
         PairUpdating(owner, other, collisionPair);
     }
 }
Пример #3
0
 public void OnPairRemoved(BroadPhaseEntry other)
 {
     if (InternalPairRemoved != null)
     {
         eventStoragePairRemoved.Enqueue(new EventStoragePairRemoved(other));
     }
     if (RemovingPair != null)
     {
         RemovingPair(owner, other);
     }
 }
Пример #4
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.");
            }
        }
Пример #5
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);
 }
Пример #6
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
     });
 }