diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h index 8c3b68bd..8bc6c5fd 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h @@ -37,17 +37,6 @@ namespace PolyVox template class Block { - template - struct RunlengthEntry - { - LengthType length; - VoxelType value; - - //We can parametise the length on anything up to uint32_t. - //This lets us experiment with the optimal size in the future. - static uint32_t maxRunlength(void) {return (std::numeric_limits::max)();} - }; - public: Block(uint16_t uSideLength = 0); diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl index c2f38883..edba9045 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl @@ -45,10 +45,25 @@ namespace PolyVox ,m_bIsCompressed(false) ,m_bIsUncompressedDataModified(true) { - if(uSideLength != 0) + if(uSideLength == 0) { - initialise(uSideLength); + POLYVOX_THROW(std::invalid_argument, "Block side cannot be zero."); } + + if(!isPowerOf2(uSideLength)) + { + POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two."); + } + + //Compute the side length + m_uSideLength = uSideLength; + m_uSideLengthPower = logBase2(uSideLength); + + //Create the block data + const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; + m_tUncompressedData = new VoxelType[uNoOfVoxels]; + std::fill(m_tUncompressedData, m_tUncompressedData + uNoOfVoxels, VoxelType()); + m_bIsUncompressedDataModified = true; } template @@ -145,28 +160,6 @@ namespace PolyVox setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); } - template - void Block::initialise(uint16_t uSideLength) - { - //Release mode validation - if(!isPowerOf2(uSideLength)) - { - POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two."); - } - - //Compute the side length - m_uSideLength = uSideLength; - m_uSideLengthPower = logBase2(uSideLength); - - //Create the block data - m_tUncompressedData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength]; - - //Clear it (should we bother?) - const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; - std::fill(m_tUncompressedData, m_tUncompressedData + uNoOfVoxels, VoxelType()); - m_bIsUncompressedDataModified = true; - } - template uint32_t Block::calculateSizeInBytes(void) {