Beispiel #1
0
        private void AabbPhantom_CollidableAdded(ref HkpCollidableAddedEvent eventData)
        {
            HkRigidBody rigidBody = eventData.RigidBody;

            if (rigidBody != null)
            {
                List <IMyEntity> allEntities = rigidBody.GetAllEntities();
                if (rigidBody.IsFixedOrKeyframed)
                {
                    allEntities.Clear();
                }
                else
                {
                    if (!this.m_bodiesInitialized)
                    {
                        this.CreateRigidBodies();
                    }
                    foreach (IMyEntity entity in allEntities)
                    {
                        this.AddNearbyEntity(entity);
                    }
                    allEntities.Clear();
                }
            }
        }
Beispiel #2
0
        private void AabbPhantom_CollidableAdded(ref HkpCollidableAddedEvent eventData)
        {
            var rb = eventData.RigidBody;

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

            var entities = rb.GetAllEntities();

            if (rb.IsFixedOrKeyframed)
            {
                entities.Clear();
                return;
            }

            if (!m_bodiesInitialized)
            {
                CreateRigidBodies();
            }

            foreach (var entity in entities)
            {
                var grid      = entity.Physics as MyGridPhysics;
                var character = entity.Physics as MyPhysicsBody;
                // I get both rigid bodies reported but they don't match, I will only track RB 1
                //if (IsDynamicGrid(rb, grid) ||
                //    IsCharacter(rb, character))
                if (!rb.IsFixedOrKeyframed && rb.Layer != MyPhysics.CollisionLayers.DebrisCollisionLayer)
                {
                    using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                    {
                        //unreliable
                        //Debug.Assert(!m_nearbyEntities.Contains(entity), "Entity added twice");
                        m_nearbyEntities.Add(entity);
                    }
                }
            }
            entities.Clear();
        }
        private void AabbPhantom_CollidableAdded(ref HkpCollidableAddedEvent eventData)
        {
            var rb = eventData.RigidBody;
            if (rb == null) // ignore phantoms
                return;

            var entities = rb.GetAllEntities();

            if (rb.IsFixedOrKeyframed)
            {
                entities.Clear();
                return;
            }

            if (!m_bodiesInitialized) CreateRigidBodies();

            foreach (var entity in entities)
            {
                var grid = entity.Physics as MyGridPhysics;
                var character = entity.Physics as MyPhysicsBody;
                // I get both rigid bodies reported but they don't match, I will only track RB 1
                //if (IsDynamicGrid(rb, grid) ||
                //    IsCharacter(rb, character))
                if(!rb.IsFixedOrKeyframed && rb.Layer != MyPhysics.CollisionLayers.DebrisCollisionLayer)
                {
                    using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                    {
                        //unreliable
                        //Debug.Assert(!m_nearbyEntities.Contains(entity), "Entity added twice");
                        m_nearbyEntities.Add(entity);
                    }
                }
            }
            entities.Clear();
        }