diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h index cc6253b6..ed9ca146 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h @@ -52,13 +52,12 @@ namespace PolyVox void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue); - void initialise(uint16_t uSideLength); + void createUncompressedData(void); + void destroyUncompressedData(void); + uint32_t calculateSizeInBytes(void); public: - void compress(); - void uncompress(); - Compressor* m_pCompressor; uint8_t* m_pCompressedData; uint32_t m_uCompressedDataLength; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl index 39bddb3a..cf103eaa 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl @@ -161,15 +161,7 @@ namespace PolyVox } template - uint32_t Block::calculateSizeInBytes(void) - { - //FIXME - This function is incomplete. - uint32_t uSizeInBytes = sizeof(Block); - return uSizeInBytes; - } - - template - void Block::compress() + void Block::destroyUncompressedData() { if(!hasUncompressedData()) { @@ -244,7 +236,7 @@ namespace PolyVox } template - void Block::uncompress() + void Block::createUncompressedData() { if(hasUncompressedData()) { @@ -270,4 +262,12 @@ namespace PolyVox m_bIsUncompressedDataModified = false; } + + template + uint32_t Block::calculateSizeInBytes(void) + { + //FIXME - This function is incomplete. + uint32_t uSizeInBytes = sizeof(Block); + return uSizeInBytes; + } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 47746f4d..b49ce49f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -471,7 +471,7 @@ namespace PolyVox { for(uint32_t ct = 0; ct < m_vecUncompressedBlockCache.size(); ct++) { - m_vecUncompressedBlockCache[ct]->block.compress(); + m_vecUncompressedBlockCache[ct]->block.destroyUncompressedData(); } m_vecUncompressedBlockCache.clear(); } @@ -552,7 +552,7 @@ namespace PolyVox if(m_vecUncompressedBlockCache[ct] == &(itBlock->second)) { // TODO: compression is unneccessary? or will not compressing this cause a memleak? - itBlock->second.block.compress(); + itBlock->second.block.destroyUncompressedData(); // put last object in cache here m_vecUncompressedBlockCache[ct] = m_vecUncompressedBlockCache.back(); // decrease cache size by one since last element is now in here twice @@ -635,7 +635,7 @@ namespace PolyVox // Blocks start out compressed - should we change this? // Or maybe we should just 'seed' them with compressed data, // rather than creating an empty block and then compressing? - newBlock.block.compress(); + newBlock.block.destroyUncompressedData(); itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first; @@ -688,7 +688,7 @@ namespace PolyVox } //Compress the least recently used block. - m_vecUncompressedBlockCache[leastRecentlyUsedBlockIndex]->block.compress(); + m_vecUncompressedBlockCache[leastRecentlyUsedBlockIndex]->block.destroyUncompressedData(); //We don't actually remove any elements from this vector, we //simply change the pointer to point at the new uncompressed bloack. @@ -699,7 +699,7 @@ namespace PolyVox m_vecUncompressedBlockCache.push_back(&loadedBlock); } - loadedBlock.block.uncompress(); + loadedBlock.block.createUncompressedData(); m_pLastAccessedBlock = &(loadedBlock.block); POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data");