Exemplo n.º 1
0
        private static void UpdateFileFormat(string originalVoxFile)
        {
            var newFile = Path.ChangeExtension(originalVoxFile, MyVoxelConstants.FILE_EXTENSION);

            if (!File.Exists(originalVoxFile))
            {
                MySandboxGame.Log.WriteLine(string.Format("ERROR: Voxel file '{0}' does not exists!", originalVoxFile));
            }
            if (Path.GetExtension(originalVoxFile) != "vox")
            {
                MySandboxGame.Log.WriteLine(string.Format("ERROR: Unexpected voxel file extensions in path: '{0}'", originalVoxFile));
            }

            using (var decompressFile = new MyCompressionFileLoad(originalVoxFile))
                using (var file = MyFileSystem.OpenWrite(newFile))
                    using (var gzip = new GZipStream(file, CompressionMode.Compress))
                        using (var buffer = new BufferedStream(gzip))
                        {
                            buffer.WriteNoAlloc(m_attributesByType[typeof(MyCellStorage)].SerializedTypeName);

                            // File version. New format will store it in 7bit encoded int right after the name of storage.
                            buffer.Write7BitEncodedInt(decompressFile.GetInt32());

                            // All remaining data is unchanged. Just copy it to new file.
                            byte[] tmp       = new byte[0x4000];
                            int    bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                            while (bytesRead != 0)
                            {
                                buffer.Write(tmp, 0, bytesRead);
                                bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                            }
                        }
        }
Exemplo n.º 2
0
        private static void UpdateFileFormat(string originalVoxFile)
        {
            var newFile = Path.ChangeExtension(originalVoxFile, MyVoxelConstants.FILE_EXTENSION);

            if (!File.Exists(originalVoxFile))
            {
                MySandboxGame.Log.Error("Voxel file '{0}' does not exist!", originalVoxFile);
                return;
            }

            if (Path.GetExtension(originalVoxFile) != ".vox")
            {
                MySandboxGame.Log.Warning("Unexpected voxel file extensions in path: '{0}'", originalVoxFile);
            }

            try
            {
                using (var decompressFile = new MyCompressionFileLoad(originalVoxFile))
                    using (var file = MyFileSystem.OpenWrite(newFile))
                        using (var gzip = new GZipStream(file, CompressionMode.Compress))
                            using (var buffer = new BufferedStream(gzip))
                            {
                                buffer.WriteNoAlloc(STORAGE_TYPE_NAME_CELL);

                                // File version. New format will store it in 7bit encoded int right after the name of storage.
                                buffer.Write7BitEncodedInt(decompressFile.GetInt32());

                                // All remaining data is unchanged. Just copy it to new file.
                                byte[] tmp       = new byte[0x4000];
                                int    bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                                while (bytesRead != 0)
                                {
                                    buffer.Write(tmp, 0, bytesRead);
                                    bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                                }
                            }
            }
            catch (Exception e)
            {
                MySandboxGame.Log.Error("While updating voxel storage '{0}' to new format: {1}", originalVoxFile, e.Message);
            }
        }
Exemplo n.º 3
0
        //  Merges specified materials (from file) into our actual voxel map - overwriting materials only.
        //  We are using a regular voxel map to define areas where we want to set a specified material. Empty voxels are ignored and 
        //  only mixed/full voxels are used to tell us that that voxel will contain new material - 'materialToSet'.
        //  If we are seting indestructible material, voxel content values from merged voxel map will be used to define indestructible content.
        //  Parameter 'voxelPosition' - place where we will place merged voxel map withing actual voxel map. It's in voxel coords.
        //  IMPORTANT: THIS METHOD WILL WORK ONLY IF WE PLACE THE MAP THAT WE TRY TO MERGE FROM IN VOXEL COORDINATES THAT ARE MULTIPLY OF DATA CELL SIZE
        //  This method is used to load small material areas, overwriting actual material only if value from file is 1. Zeros are ignored (it's empty space).
        //  This method is quite fast, even on large maps - 512x512x512, so we can do more overwrites.
        //  Parameter 'materialToSet' tells us what material to set at places which are full in file. Empty are ignored - so stay as they were before this method was called.
        //  IMPORTANT: THIS MERGE MATERIAL CAN BE CALLED ONLY AFTER ALL VOXEL CONTENTS ARE LOADED. THAT'S BECAUSE WE NEED TO KNOW THEM FOR MIN CONTENT / INDESTRUCTIBLE CONTENT.
        //  Voxel map we are trying to merge into existing voxel map can be bigger or outside of area of existing voxel map. This method will just ignore those parts.
        public void MergeVoxelMaterials(MyMwcVoxelFilesEnum voxelFile, MyMwcVector3Short voxelPosition, MyMwcVoxelMaterialsEnum materialToSet)
        {
            MyMwcLog.WriteLine("MyVoxelMap.MergeVoxelMaterials() - Start");
            MyMwcLog.IncreaseIndent();

            MyCompressionFileLoad decompressFile = new MyCompressionFileLoad(MyVoxelFiles.Get(voxelFile).GetVoxFilePath());

            //  Version of a VOX file
            int fileVersion = decompressFile.GetInt32();

            //  Not supported VOX file version
            MyCommonDebugUtils.AssertRelease(fileVersion == MyVoxelConstants.VOXEL_FILE_ACTUAL_VERSION);

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            //  Size of data cell in voxels, doesn't have to be same as current size specified by our constants.
            int cellSizeX = decompressFile.GetInt32();
            int cellSizeY = decompressFile.GetInt32();
            int cellSizeZ = decompressFile.GetInt32();

            int cellsCountX = sizeX / cellSizeX;
            int cellsCountY = sizeY / cellSizeY;
            int cellsCountZ = sizeZ / cellSizeZ;

            //  This method will work only if we place the map that we try to merge from in voxel coordinates that are multiply of data cell size
            MyCommonDebugUtils.AssertRelease((voxelPosition.X & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyCommonDebugUtils.AssertRelease((voxelPosition.Y & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyCommonDebugUtils.AssertRelease((voxelPosition.Z & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyMwcVector3Int cellFullForVoxelPosition = GetDataCellCoordinate(ref voxelPosition);

            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                    {
                        MyVoxelCellType cellType = (MyVoxelCellType)decompressFile.GetByte();

                        //  We can do "continue" here, becase we need to read this file properly, even if we will ignore that data
                        bool isDataCellInVoxelMap = IsDataCellInVoxelMap(
                            new MyMwcVector3Int(
                                cellFullForVoxelPosition.X + cellCoord.X,
                                cellFullForVoxelPosition.Y + cellCoord.Y,
                                cellFullForVoxelPosition.Z + cellCoord.Z));

                        if (cellType == MyVoxelCellType.EMPTY)
                        {
                            //  If merged cell is empty, there is nothing to overwrite, so we can skip this cell
                            continue;
                        }
                        else if (cellType == MyVoxelCellType.FULL)
                        {
                            //  If merged cell is full, than we reset whole material cell to 'materialToSet'
                            if (isDataCellInVoxelMap)
                            {
                                m_voxelMaterialCells[cellFullForVoxelPosition.X + cellCoord.X][cellFullForVoxelPosition.Y +
                                    cellCoord.Y][cellFullForVoxelPosition.Z + cellCoord.Z].Reset(
                                    materialToSet, GetIndestructibleContentByMaterial(materialToSet));
                            }
                        }
                        else
                        {
                            MyMwcVector3Int cellCoordInVoxels = GetVoxelCoordinatesOfDataCell(ref cellCoord);

                            MyMwcVector3Int voxelCoordRelative;
                            voxelCoordRelative.X = voxelPosition.X + cellCoordInVoxels.X;
                            voxelCoordRelative.Y = voxelPosition.Y + cellCoordInVoxels.Y;
                            voxelCoordRelative.Z = voxelPosition.Z + cellCoordInVoxels.Z;

                            MyMwcVector3Int voxelCoordInCell;
                            for (voxelCoordInCell.X = 0; voxelCoordInCell.X < cellSizeX; voxelCoordInCell.X++)
                            {
                                for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < cellSizeY; voxelCoordInCell.Y++)
                                {
                                    for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < cellSizeZ; voxelCoordInCell.Z++)
                                    {
                                        byte voxelFromFile = decompressFile.GetByte();

                                        if (isDataCellInVoxelMap)
                                        {
                                            //  Ignore empty voxels, but use mixed/full for seting the material
                                            if (voxelFromFile > MyVoxelConstants.VOXEL_CONTENT_EMPTY)
                                            {
                                                MyMwcVector3Int voxelCoord = new MyMwcVector3Int(
                                                    voxelCoordRelative.X + voxelCoordInCell.X,
                                                    voxelCoordRelative.Y + voxelCoordInCell.Y,
                                                    voxelCoordRelative.Z + voxelCoordInCell.Z);

                                                //  Actual voxel content
                                                byte voxelContent = GetVoxelContent(ref voxelCoord);

                                                //  If this is indestructible material, here we will get 'min content' for this voxel
                                                byte indestructibleContent = GetIndestructibleContentsByMaterialAndContent(materialToSet, voxelFromFile);

                                                //  Indestructible content can be less than real voxel at this place. First I made this mistake.
                                                //  If forgoten, then during explosions we will in fact create matter from 'indestructible content' array.
                                                if (indestructibleContent > voxelContent)
                                                {
                                                    indestructibleContent = voxelContent;
                                                }

                                                SetVoxelMaterialAndIndestructibleContent(materialToSet, indestructibleContent, ref voxelCoord);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyVoxelMap.MergeVoxelMaterials() - End");
        }
Exemplo n.º 4
0
        // Not used
        //public void Reinitialize()
        //{
        //    if (m_isClosed)
        //    {
        //        Init(this.Name, this.PositionLeftBottomCorner, (MyMwcObjectBuilder_VoxelMap)this.GetObjectBuilderInternal());
        //        m_isClosed = false;
        //    }
        //}

        //  Merges a specified voxel map (from a file) into our actual voxel map at a specified position. 
        //  This merging is slower than loading voxel map through constructor (because we are setting voxels through SetVoxelContent) - so use it only 
        //  for merging-in small areas.
        //  Parameter 'voxelPosition' - where will be placed new merged voxel map withing actual voxel map. It's in voxel coords.
        //  Voxel map we are trying to merge into existing voxel map can be bigger or outside of area of existing voxel map. This method will just ignore those parts.
        //  Coordinate of 'voxelPosition' DOESN'T NEED to be aligned to data cell (multiplies of 8).
        public void MergeVoxelContents(MyMwcVoxelFilesEnum voxelFile, MyMwcVector3Short voxelPosition, MyMwcVoxelMapMergeTypeEnum mergeType)
        {
            MyCompressionFileLoad decompressFile = new MyCompressionFileLoad(MyVoxelFiles.Get(voxelFile).GetVoxFilePath());

            //  Version of a VOX file
            int fileVersion = decompressFile.GetInt32();

            //  Not supported VOX file version
            MyCommonDebugUtils.AssertRelease(fileVersion == MyVoxelConstants.VOXEL_FILE_ACTUAL_VERSION);

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            //  Size of data cell in voxels, doesn't have to be same as current size specified by our constants.
            int cellSizeX = decompressFile.GetInt32();
            int cellSizeY = decompressFile.GetInt32();
            int cellSizeZ = decompressFile.GetInt32();

            int cellsCountX = sizeX / cellSizeX;
            int cellsCountY = sizeY / cellSizeY;
            int cellsCountZ = sizeZ / cellSizeZ;

            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                    {
                        MyVoxelCellType cellType = (MyVoxelCellType)decompressFile.GetByte();

                        MyMwcVector3Int cellCoordInVoxels = GetVoxelCoordinatesOfDataCell(ref cellCoord);

                        //  Go through every voxel in a cell and change it's value. If cell is empty, set all voxels to empty. Otherwise set by value from file.
                        MyMwcVector3Int voxelCoordInCell;
                        for (voxelCoordInCell.X = 0; voxelCoordInCell.X < cellSizeX; voxelCoordInCell.X++)
                        {
                            for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < cellSizeY; voxelCoordInCell.Y++)
                            {
                                for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < cellSizeZ; voxelCoordInCell.Z++)
                                {
                                    byte newContent;
                                    if (cellType == MyVoxelCellType.EMPTY)
                                    {
                                        newContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY;
                                    }
                                    else if (cellType == MyVoxelCellType.FULL)
                                    {
                                        newContent = MyVoxelConstants.VOXEL_CONTENT_FULL;
                                    }
                                    else
                                    {
                                        newContent = decompressFile.GetByte();
                                    }

                                    MyMwcVector3Int voxelCoord;
                                    voxelCoord.X = voxelPosition.X + cellCoordInVoxels.X + voxelCoordInCell.X;
                                    voxelCoord.Y = voxelPosition.Y + cellCoordInVoxels.Y + voxelCoordInCell.Y;
                                    voxelCoord.Z = voxelPosition.Z + cellCoordInVoxels.Z + voxelCoordInCell.Z;

                                    if (IsVoxelInVoxelMap(ref voxelCoord) == true)
                                    {
                                        byte originalContent = GetVoxelContent(ref voxelCoord);

                                        if (mergeType == MyMwcVoxelMapMergeTypeEnum.ADD)
                                        {
                                            //  Set new content only if its value is higher than actual - so we only can add matter
                                            if (newContent > originalContent)
                                            {
                                                SetVoxelContent(newContent, ref voxelCoord);
                                            }
                                        }
                                        else if (mergeType == MyMwcVoxelMapMergeTypeEnum.INVERSE_AND_SUBTRACT)
                                        {
                                            //  Subtract new content from original, so if original voxel is full and new is full too, result will be empty voxel
                                            //  If new is empty, nothing will happen. If new is full but original is empty, nothing will happen either.
                                            SetVoxelContent((byte)MyMwcUtils.GetClampInt((int)originalContent - (int)newContent, MyVoxelConstants.VOXEL_CONTENT_EMPTY, MyVoxelConstants.VOXEL_CONTENT_FULL), ref voxelCoord);
                                        }
                                        else
                                        {
                                            throw new MyMwcExceptionApplicationShouldNotGetHere();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static bool IsNewAllowed(MyMwcVoxelFilesEnum voxelFileEnum, ref int totalDataCells)
        {
            bool allowed = false;

            MyVoxelFile voxelFile = MyVoxelFiles.Get(voxelFileEnum);
            MyCompressionFileLoad decompressFile = new MyCompressionFileLoad(voxelFile.GetVoxFilePath());

            int fileVersion = decompressFile.GetInt32();

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            int dataCellCountX = sizeX >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;
            int dataCellCountY = sizeY >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;
            int dataCellCountZ = sizeZ >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;

            int newVoxelCellCount = dataCellCountX * dataCellCountY * dataCellCountZ;

            totalDataCells = newVoxelCellCount + totalDataCells;
            if (totalDataCells < MyVoxelConstants.MAX_VOXEL_MAPS_DATA_CELL_COUNT)
            {
                allowed = true;
            }

            return allowed;
        }
Exemplo n.º 6
0
        private void LoadFile(Vector3 position, MyMwcObjectBuilder_VoxelMap objectBuilder)
        {
            MyCompressionFileLoad decompressFile = null;

            if (objectBuilder.VoxelData != null)
            {
                decompressFile = new MyCompressionFileLoad(objectBuilder.VoxelData);    
            }
            else
            {
                string voxelFilePath = MyVoxelFiles.Get(objectBuilder.VoxelFile).GetVoxFilePath();
                m_voxelFile = objectBuilder.VoxelFile;

                decompressFile = new MyCompressionFileLoad(voxelFilePath);
            }

            
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Decompress file header");

            //  Version of a VOX file
            int fileVersion = decompressFile.GetInt32();

            //  Not supported VOX file version
            MyCommonDebugUtils.AssertRelease(fileVersion == MyVoxelConstants.VOXEL_FILE_ACTUAL_VERSION);

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            //  Size of data cell in voxels. Has to be the same as current size specified by our constants.
            int cellSizeX = decompressFile.GetInt32();
            int cellSizeY = decompressFile.GetInt32();
            int cellSizeZ = decompressFile.GetInt32();
            MyCommonDebugUtils.AssertDebug(
                cellSizeX == MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS &&
                cellSizeY == MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS &&
                cellSizeZ == MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS);

            int cellsCountX = sizeX / cellSizeX;
            int cellsCountY = sizeY / cellSizeY;
            int cellsCountZ = sizeZ / cellSizeZ;

            //  Init ore deposit cells
            if (MyFakes.ENABLE_DISPLAYING_ORE_ON_HUD)
            {
                m_oreDepositCellsCountX = cellsCountX / MyVoxelConstants.VOXEL_MAP_ORE_DEPOSIT_CELL_IN_DATA_CELLS;
                m_oreDepositCellsCountY = cellsCountY / MyVoxelConstants.VOXEL_MAP_ORE_DEPOSIT_CELL_IN_DATA_CELLS;
                m_oreDepositCellsCountZ = cellsCountZ / MyVoxelConstants.VOXEL_MAP_ORE_DEPOSIT_CELL_IN_DATA_CELLS;

                m_oreDepositCells = new Dictionary<long, MyVoxelMapOreDepositCell>();
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitVoxelMap");

            //  Init this voxel map (arrays are allocated, sizes calculated). It must be called before we start reading and seting voxels.
            InitVoxelMap(position, new MyMwcVector3Int(sizeX, sizeY, sizeZ), objectBuilder.VoxelMaterial);
            
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Cells foreach");

            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                    {
                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("cell");

                        MyVoxelCellType cellType = (MyVoxelCellType)decompressFile.GetByte();

                        //  Cell's are FULL by default, therefore we don't need to change them
                        if (cellType != MyVoxelCellType.FULL)
                        {
                            MyVoxelContentCell newCell = AddCell(ref cellCoord);

                            //  If cell is empty we don't need to set all its voxels to empty. Just allocate cell and set its type to empty.
                            if (cellType == MyVoxelCellType.EMPTY)
                            {
                                newCell.SetToEmpty();
                            }
                            else if (cellType == MyVoxelCellType.MIXED)
                            {
                                decompressFile.GetBytes(cellSizeX * cellSizeY * cellSizeZ, buffer);
                                if (!MyFakes.MWCURIOSITY)
                                {
                                    newCell.SetAllVoxelContents(buffer);
                                }
                            }
                        }
                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                    }
                }
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Materials + indestructible");

            if (!decompressFile.EndOfFile())
            {
                // Read materials and indestructible
                for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
                {
                    for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                    {
                        for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                        {
                            //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("mat");
                            var matCell = m_voxelMaterialCells[cellCoord.X][cellCoord.Y][cellCoord.Z];

                            bool isSingleMaterial = decompressFile.GetByte() == 1;
                            MyMwcVoxelMaterialsEnum material = MyMwcVoxelMaterialsEnum.Indestructible_01;
                            byte indestructibleContent = 0;

                            MyMwcVector3Int oreDepositCellCoord = GetOreDepositCellCoordByDataCellCoord(ref cellCoord);

                            if (isSingleMaterial)
                            {
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("single material");
                                material = (MyMwcVoxelMaterialsEnum)decompressFile.GetByte();
                                indestructibleContent = MyVoxelMaterials.IsIndestructible(material) ? (byte)255 : (byte)0;
                                this.SetVoxelMaterialAndIndestructibleContentForWholeCell(material, indestructibleContent, ref cellCoord);
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            }
                            else
                            {
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("mixed material");                                

                                MyMwcVector3Int voxelCoordInCell;
                                for (voxelCoordInCell.X = 0; voxelCoordInCell.X < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.X++)
                                {
                                    for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Y++)
                                    {
                                        for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Z++)
                                        {
                                            material = (MyMwcVoxelMaterialsEnum)decompressFile.GetByte();
                                            indestructibleContent = decompressFile.GetByte();
                                            matCell.SetMaterialAndIndestructibleContent(material, indestructibleContent, ref voxelCoordInCell);
                                        }
                                    }
                                }
                                matCell.CalcAverageCellMaterial();
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            }
                            //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                        }
                    }
                }
            }

            // compute ore deposits
            if (MyFakes.ENABLE_DISPLAYING_ORE_ON_HUD)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Compute ore deposits");

                for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
                {
                    for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                    {
                        for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                        {
                            MyMwcVector3Int oreDepositCellCoord = GetOreDepositCellCoordByDataCellCoord(ref cellCoord);
                            var matCell = m_voxelMaterialCells[cellCoord.X][cellCoord.Y][cellCoord.Z];
                            var contentCell = m_voxelContentCells[cellCoord.X][cellCoord.Y][cellCoord.Z];

                            if (matCell.IsSingleMaterialForWholeCell())
                            {
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("single material");
                                var material = matCell.GetAverageCellMaterial();
                                if (MyVoxelMapOreMaterials.IsRareOre(material))
                                {
                                    int content = (contentCell == null) ? MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL : contentCell.GetVoxelContentSum();
                                    if (GetOreDepositCell(ref oreDepositCellCoord) == null)
                                    {
                                        AddOreDepositCell(ref oreDepositCellCoord).SetOreContent(material, content);
                                    }
                                }
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            }
                            else
                            {
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("more materials");
                                // buffer one rare material
                                MyMwcVoxelMaterialsEnum bufferedMaterial = MyMwcVoxelMaterialsEnum.Ice_01;  // IMPORTANT: the default value must be a rare material
                                int bufferedContent = 0;

                                MyMwcVector3Int voxelCoordInCell;
                                for (voxelCoordInCell.X = 0; voxelCoordInCell.X < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.X++)
                                {
                                    for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Y++)
                                    {
                                        for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Z++)
                                        {
                                            var material = matCell.GetMaterial(ref voxelCoordInCell);
                                            if (material == bufferedMaterial)  // do we buffer this material?
                                            {
                                                int content = (contentCell == null) ? MyVoxelConstants.VOXEL_CONTENT_FULL : contentCell.GetVoxelContent(ref voxelCoordInCell);
                                                bufferedContent += content;  // yes: just update the content
                                            }
                                            else
                                            {
                                                if (MyVoxelMapOreMaterials.IsRareOre(material))  // skip non-rare materials
                                                {
                                                    int content = (contentCell == null) ? MyVoxelConstants.VOXEL_CONTENT_FULL : contentCell.GetVoxelContent(ref voxelCoordInCell);
                                                    if (content > 0)  // skip empty cells
                                                    {
                                                        // new rare material: if there's any old buffered content, add it to the deposit
                                                        if (bufferedContent > 0 && GetOreDepositCell(ref oreDepositCellCoord) == null)
                                                        {
                                                            AddOreDepositCell(ref oreDepositCellCoord).SetOreContent(bufferedMaterial, bufferedContent);
                                                        }

                                                        bufferedMaterial = material;
                                                        bufferedContent = content;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if (bufferedContent > 0 && GetOreDepositCell(ref oreDepositCellCoord) == null)  // if there's any buffered content left, add it to the deposit
                                {
                                    AddOreDepositCell(ref oreDepositCellCoord).SetOreContent(bufferedMaterial, bufferedContent);
                                }
                                //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            }
                        }
                    }
                }
            }
        }