Exemple #1
0
        private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData)
        {
            var rb = eventData.RigidBody;

            if (rb == null) // ignore phantoms
            {
                return;
            }
            var entities = rb.GetAllEntities();

            foreach (var entity in entities)
            {
                var grid      = entity.Physics as MyGridPhysics;
                var character = entity.Physics as MyPhysicsBody;
                if (IsDynamicGrid(rb, grid) ||
                    IsCharacter(rb, character))
                {
                    using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                    {
                        if (character != null)
                        {
                            MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId));
                        }
                        //unreliable
                        //Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added");
                        m_nearbyEntities.Remove(entity);
                    }
                }
            }
            entities.Clear();
        }
Exemple #2
0
        private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData)
        {
            var rb = eventData.RigidBody;

            if (rb == null) // ignore phantoms
            {
                return;
            }

            var grid      = rb.UserObject as MyGridPhysics;
            var character = rb.UserObject as MyPhysicsBody;

            if (IsDynamicGrid(rb, grid) ||
                IsCharacter(rb, character))
            {
                using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                {
                    if (character != null)
                    {
                        MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId));
                    }
                    IMyEntity entity = grid == null ? character.Entity : grid.Entity;
                    Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added");
                    m_nearbyEntities.Remove(entity);
                }
            }
        }