Пример #1
0
 private void AllocateContents()
 {
     m_dataCellsCount = Size >> MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS_BITS;
     var cellsSize = m_dataCellsCount.Size();
     m_contentCells = new MyVoxelContentCell[cellsSize];
     m_materialCells = new MaterialCell[cellsSize];
     var defaultMaterial = MyDefinitionManager.Static.GetDefaultVoxelMaterialDefinition();
     for (int i = 0; i < cellsSize; ++i)
     {
         m_materialCells[i] = new MaterialCell(defaultMaterial);
     }
 }
Пример #2
0
 private void ReadRange(
     MyStorageDataCache target,
     MaterialCell cell,
     ref Vector3I startInCell,
     ref Vector3I endInCell,
     ref Vector3I writeOffset)
 {
     Vector3I coordInCell;
     Vector3I writeCoord;
     Vector3I offset = writeOffset + startInCell;
     if (cell == null)
     {
         byte material = MyDefinitionManager.Static.GetDefaultVoxelMaterialDefinition().Index;
         for (coordInCell.Z = startInCell.Z, writeCoord.Z = offset.Z; coordInCell.Z <= endInCell.Z; ++coordInCell.Z, ++writeCoord.Z)
         {
             for (coordInCell.Y = startInCell.Y, writeCoord.Y = offset.Y; coordInCell.Y <= endInCell.Y; ++coordInCell.Y, ++writeCoord.Y)
             {
                 for (coordInCell.X = startInCell.X, writeCoord.X = offset.X; coordInCell.X <= endInCell.X; ++coordInCell.X, ++writeCoord.X)
                 {
                     target.Material(ref writeCoord, material);
                 }
             }
         }
     }
     else
     {
         for (coordInCell.Z = startInCell.Z, writeCoord.Z = offset.Z; coordInCell.Z <= endInCell.Z; ++coordInCell.Z, ++writeCoord.Z)
         {
             for (coordInCell.Y = startInCell.Y, writeCoord.Y = offset.Y; coordInCell.Y <= endInCell.Y; ++coordInCell.Y, ++writeCoord.Y)
             {
                 for (coordInCell.X = startInCell.X, writeCoord.X = offset.X; coordInCell.X <= endInCell.X; ++coordInCell.X, ++writeCoord.X)
                 {
                     target.Material(ref writeCoord, cell.GetMaterialIdx(ref coordInCell));
                 }
             }
         }
     }
 }