void CheckObjectInVoxel() { if (m_checkObjectInsideVoxel >= m_synchronizedFloatingObjects.Count) { m_checkObjectInsideVoxel = 0; } if (m_synchronizedFloatingObjects.Count > 0) { var floatingObjectToCheck = m_synchronizedFloatingObjects[m_checkObjectInsideVoxel]; var localAabb = (BoundingBoxD)floatingObjectToCheck.PositionComp.LocalAABB; var worldMatrix = floatingObjectToCheck.PositionComp.WorldMatrix; var worldAabb = floatingObjectToCheck.PositionComp.WorldAABB; using (m_tmpResultList.GetClearToken()) { MyGamePruningStructure.GetAllVoxelMapsInBox(ref worldAabb, m_tmpResultList); //Debug.Assert(m_tmpResultList.Count == 1, "Voxel map AABBs shouldn't overlap!"); foreach (var voxelMap in m_tmpResultList) { if (voxelMap != null && !voxelMap.MarkedForClose && !(voxelMap is MyVoxelPhysics)) { if (voxelMap.AreAllAabbCornersInside(ref worldMatrix, localAabb)) { floatingObjectToCheck.NumberOfFramesInsideVoxel++; if (floatingObjectToCheck.NumberOfFramesInsideVoxel > MyFloatingObject.NUMBER_OF_FRAMES_INSIDE_VOXEL_TO_REMOVE) { //MyLog.Default.WriteLine("Floating object " + (floatingObjectToCheck.DisplayName != null ? floatingObjectToCheck.DisplayName : floatingObjectToCheck.ToString()) + " was removed because it was inside voxel."); if (Sync.IsServer) { RemoveFloatingObject(floatingObjectToCheck); } } } else { floatingObjectToCheck.NumberOfFramesInsideVoxel = 0; } } } } } m_checkObjectInsideVoxel++; }
private void CheckObjectInVoxel() { if (m_checkObjectInsideVoxel >= m_synchronizedFloatingObjects.Count) { m_checkObjectInsideVoxel = 0; } if (m_synchronizedFloatingObjects.Count > 0) { MyFloatingObject obj2 = m_synchronizedFloatingObjects[m_checkObjectInsideVoxel]; BoundingBoxD localAABB = obj2.PositionComp.LocalAABB; MatrixD worldMatrix = obj2.PositionComp.WorldMatrix; BoundingBoxD worldAABB = obj2.PositionComp.WorldAABB; using (m_tmpResultList.GetClearToken <MyVoxelBase>()) { MyGamePruningStructure.GetAllVoxelMapsInBox(ref worldAABB, m_tmpResultList); foreach (MyVoxelBase base2 in m_tmpResultList) { if (base2 == null) { continue; } if (!base2.MarkedForClose && !(base2 is MyVoxelPhysics)) { if (!base2.AreAllAabbCornersInside(ref worldMatrix, localAABB)) { obj2.NumberOfFramesInsideVoxel = 0; continue; } obj2.NumberOfFramesInsideVoxel++; if ((obj2.NumberOfFramesInsideVoxel > 5) && Sync.IsServer) { RemoveFloatingObject(obj2); } } } } } m_checkObjectInsideVoxel++; }