Exemplo n.º 1
0
        public void SetToEmpty()
        {
            CellType          = MyVoxelCellType.EMPTY;
            m_voxelContentSum = 0;

            CheckCellType();
        }
Exemplo n.º 2
0
        public void SetToFull()
        {
            CellType          = MyVoxelCellType.FULL;
            m_voxelContentSum = MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL;

            CheckCellType();
        }
Exemplo n.º 3
0
        public MyVoxelContentCell()
        {
            //  Default cell is FULL
            CellType = MyVoxelCellType.FULL;

            //  Sums all voxel values. Default is summ of all full voxel in cell, so be subtracting we can switch cell from MIXED to EMPTY.
            m_voxelContentSum = MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL;
        }
Exemplo n.º 4
0
        public MyVoxelContentCell()
        {
            //  Default cell is FULL
            CellType = MyVoxelCellType.FULL;         

            //  Sums all voxel values. Default is summ of all full voxel in cell, so be subtracting we can switch cell from MIXED to EMPTY.
            m_voxelContentSum = MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL;
        }
Exemplo n.º 5
0
        // Set voxel content for the whole cell.
        public void SetAllVoxelContents(byte[] buffer)
        {
            // quantize the buffer and compute sum
            m_voxelContentSum = 0;
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i]          = MyVoxelContentCellContent.QuantizedValue(buffer[i]);
                m_voxelContentSum += buffer[i];
            }

            // mixed-->empty/full: deallocate
            // empty/full-->mixed: allocate
            // mixed: fill with values from buffer
            if (m_voxelContentSum == 0)
            {
                if (CellType == MyVoxelCellType.MIXED)
                {
                    Deallocate();
                }
                CellType = MyVoxelCellType.EMPTY;
            }
            else if (m_voxelContentSum == MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL)
            {
                if (CellType == MyVoxelCellType.MIXED)
                {
                    Deallocate();
                }
                CellType = MyVoxelCellType.FULL;
            }
            else
            {
                if (CellType == MyVoxelCellType.FULL || CellType == MyVoxelCellType.EMPTY)
                {
                    m_cellContent = MyVoxelContentCellContents.Allocate();
                }
                if (m_cellContent != null)
                {
                    m_cellContent.Value.SetAddVoxelContents(buffer);
                }
                CellType = MyVoxelCellType.MIXED;
            }
        }
Exemplo n.º 6
0
        //  This method helps us to maintain correct cell type even after removing or adding voxels from cell
        //  If all voxels were removed from this cell, we change its type to from MIXED to EMPTY.
        //  If voxels were added, we change its type to from EMPTY to MIXED.
        //  If voxels were added to full, we change its type to FULL.
        void CheckCellType()
        {
            //  Voxel cell content sum isn't in allowed range. Probably increased or descreased too much.
            System.Diagnostics.Debug.Assert((m_voxelContentSum >= 0) && (m_voxelContentSum <= MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL));

            if (m_voxelContentSum == 0)
            {
                CellType = MyVoxelCellType.EMPTY;
            }
            else if (m_voxelContentSum == MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL)
            {
                CellType = MyVoxelCellType.FULL;
            }
            else
            {
                CellType = MyVoxelCellType.MIXED;
            }

            //  If cell changed from MIXED to EMPTY or FULL, we will release it's cell content because it's not needed any more
            if ((CellType == MyVoxelCellType.EMPTY) || (CellType == MyVoxelCellType.FULL))
            {
                Deallocate();
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Check the given cell type against a possible cell contents state (full, empty, mixed)
 /// </summary>
 /// <param name="cell">MyVoxelContentCell object to check</param>
 /// <param name="type">A cell state to check against (MyVoxelCellType enum)</param>
 /// <returns>whether the cell has the given type or not.</returns>
 private bool CheckCellType(ref MyVoxelContentCell cell, MyVoxelCellType type)
 {
     if (cell == null)
         return type == MyVoxelCellType.FULL;
     return cell.CellType == type;
 }
Exemplo n.º 8
0
        public void SetToFull()
        {
            CellType = MyVoxelCellType.FULL;
            m_voxelContentSum = MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL;

            CheckCellType();
        }
Exemplo n.º 9
0
        public void SetToEmpty()
        {
            CellType = MyVoxelCellType.EMPTY;
            m_voxelContentSum = 0;

            CheckCellType();
        }
Exemplo n.º 10
0
        //  This method helps us to maintain correct cell type even after removing or adding voxels from cell
        //  If all voxels were removed from this cell, we change its type to from MIXED to EMPTY.
        //  If voxels were added, we change its type to from EMPTY to MIXED.
        //  If voxels were added to full, we change its type to FULL.
        void CheckCellType()
        {
            //  Voxel cell content sum isn't in allowed range. Probably increased or descreased too much.
            System.Diagnostics.Debug.Assert((m_voxelContentSum >= 0) && (m_voxelContentSum <= MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL));

            if (m_voxelContentSum == 0)
            {
                CellType = MyVoxelCellType.EMPTY;
            }
            else if (m_voxelContentSum == MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL)
            {
                CellType = MyVoxelCellType.FULL;
            }
            else
            {
                CellType = MyVoxelCellType.MIXED;
            }

            //  If cell changed from MIXED to EMPTY or FULL, we will release it's cell content because it's not needed any more
            if ((CellType == MyVoxelCellType.EMPTY) || (CellType == MyVoxelCellType.FULL))
            {
                Deallocate();
            }
        }
Exemplo n.º 11
0
        // Set voxel content for the whole cell.
        public void SetAllVoxelContents(byte[] buffer)
        {
            // quantize the buffer and compute sum
            m_voxelContentSum = 0;
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] = MyVoxelContentCellContent.QuantizedValue(buffer[i]);
                m_voxelContentSum += buffer[i];
            }

            // mixed-->empty/full: deallocate
            // empty/full-->mixed: allocate
            // mixed: fill with values from buffer
            if (m_voxelContentSum == 0)
            {
                if (CellType == MyVoxelCellType.MIXED) Deallocate();
                CellType = MyVoxelCellType.EMPTY;
            }
            else if (m_voxelContentSum == MyVoxelConstants.VOXEL_CELL_CONTENT_SUM_TOTAL)
            {
                if (CellType == MyVoxelCellType.MIXED) Deallocate();
                CellType = MyVoxelCellType.FULL;
            }
            else
            {
                if (CellType == MyVoxelCellType.FULL || CellType == MyVoxelCellType.EMPTY) m_cellContent = MyVoxelContentCellContents.Allocate();
                if (m_cellContent != null)
                {
                    m_cellContent.Value.SetAddVoxelContents(buffer);
                }
                CellType = MyVoxelCellType.MIXED;
            }
        }