private void AabbPhantom_CollidableRemoved(ref 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; // RK: IsDynamicGrid(rb, grid) commented out because body can be changed to static after added to m_nearbyEntities, see method MyGridShape.UpdateShape, // before CreateConnectionToWorld(destructionBody) it can be static = false but after true! if ((grid != null && grid.RigidBody == rb) /*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(); }
private void AabbPhantom_CollidableRemoved(ref HkpCollidableRemovedEvent eventData) { if (this.m_mesher != null) { HkRigidBody rigidBody = eventData.RigidBody; if (rigidBody != null) { List <IMyEntity> allEntities = rigidBody.GetAllEntities(); foreach (IMyEntity entity in allEntities) { MyGridPhysics physics = entity.Physics as MyGridPhysics; MyPhysicsBody body2 = entity.Physics as MyPhysicsBody; if ((physics != null) && (physics.RigidBody == rigidBody)) { using (this.m_nearbyEntitiesLock.AcquireExclusiveUsing()) { MyPhysicsBody body1 = body2; this.m_nearbyEntities.Remove(entity); } } } allEntities.Clear(); } } }
private void AabbPhantom_CollidableRemoved(ref 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; // RK: IsDynamicGrid(rb, grid) commented out because body can be changed to static after added to m_nearbyEntities, see method MyGridShape.UpdateShape, // before CreateConnectionToWorld(destructionBody) it can be static = false but after true! if ((grid != null && grid.RigidBody == rb)/*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(); }