From a00574351ffa94225dd7272618e2d7d8a6a4d885 Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 11 Jul 2013 16:38:28 +0200 Subject: [PATCH] Renamed Block to CompressedBlock --- examples/Paging/main.cpp | 4 +-- .../include/PolyVoxCore/FilePager.h | 4 +-- .../include/PolyVoxCore/Impl/Block.h | 4 +-- .../include/PolyVoxCore/Impl/Block.inl | 12 ++++----- .../include/PolyVoxCore/LargeVolume.h | 6 ++--- .../include/PolyVoxCore/LargeVolume.inl | 26 +++++++++---------- .../PolyVoxCore/include/PolyVoxCore/Pager.h | 4 +-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/Paging/main.cpp b/examples/Paging/main.cpp index c497a255..07877405 100644 --- a/examples/Paging/main.cpp +++ b/examples/Paging/main.cpp @@ -91,7 +91,7 @@ public: /// Destructor virtual ~PerlinNoisePager() {}; - virtual void pageIn(const PolyVox::Region& region, Block* pBlockData) + virtual void pageIn(const PolyVox::Region& region, CompressedBlock* pBlockData) { /*pBlockData->createUncompressedData(); @@ -137,7 +137,7 @@ public: }*/ } - virtual void pageOut(const PolyVox::Region& region, Block* /*pBlockData*/) + virtual void pageOut(const PolyVox::Region& region, CompressedBlock* /*pBlockData*/) { std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h index 7fb79f1c..80c4f05a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h @@ -52,7 +52,7 @@ namespace PolyVox /// Destructor virtual ~FilePager() {}; - virtual void pageIn(const Region& region, Block* pBlockData) + virtual void pageIn(const Region& region, CompressedBlock* pBlockData) { POLYVOX_ASSERT(pBlockData, "Attempting to page in NULL block"); //POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data"); @@ -93,7 +93,7 @@ namespace PolyVox } } - virtual void pageOut(const Region& region, Block* pBlockData) + virtual void pageOut(const Region& region, CompressedBlock* pBlockData) { POLYVOX_ASSERT(pBlockData, "Attempting to page out NULL block"); //POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data"); diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h index 86d6d08b..f9ce6f3c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.h @@ -35,10 +35,10 @@ freely, subject to the following restrictions: namespace PolyVox { template - class Block + class CompressedBlock { public: - Block(uint16_t uSideLength, Compressor* pCompressor); + CompressedBlock(uint16_t uSideLength, Compressor* pCompressor); const uint8_t* getCompressedData(void) const; uint32_t getCompressedDataLength(void) const; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl index 3f311e0d..8f54c9a3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl @@ -36,7 +36,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - Block::Block(uint16_t uSideLength, Compressor* pCompressor) + CompressedBlock::CompressedBlock(uint16_t uSideLength, Compressor* pCompressor) :m_pCompressedData(0) ,m_uCompressedDataLength(0) { @@ -58,21 +58,21 @@ namespace PolyVox } template - const uint8_t* Block::getCompressedData(void) const + const uint8_t* CompressedBlock::getCompressedData(void) const { POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL"); return m_pCompressedData; } template - uint32_t Block::getCompressedDataLength(void) const + uint32_t CompressedBlock::getCompressedDataLength(void) const { POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL"); return m_uCompressedDataLength; } template - void Block::setCompressedData(const uint8_t* const data, uint32_t dataLength) + void CompressedBlock::setCompressedData(const uint8_t* const data, uint32_t dataLength) { //POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL"); POLYVOX_ASSERT(m_pCompressedData != data, "Attempting to copy data onto itself"); @@ -85,11 +85,11 @@ namespace PolyVox } template - uint32_t Block::calculateSizeInBytes(void) + uint32_t CompressedBlock::calculateSizeInBytes(void) { // Returns the size of this class plus the size of the compressed data. It // doesn't include the uncompressed data cache as that is owned by the volume. - uint32_t uSizeInBytes = sizeof(Block) + m_uCompressedDataLength; + uint32_t uSizeInBytes = sizeof(CompressedBlock) + m_uCompressedDataLength; return uSizeInBytes; } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 86e36381..c4d3c777 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -329,13 +329,13 @@ namespace PolyVox VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType, VoxelType tBorder) const; VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType, VoxelType tBorder) const; - Block* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; + CompressedBlock* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; VoxelType* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; - void eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const; + void eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const; // The block data mutable std::map m_pUncompressedBlockCache; - mutable std::map, BlockPositionCompare> m_pBlocks; + mutable std::map, BlockPositionCompare> m_pBlocks; mutable uint32_t m_uTimestamper; mutable Vector3DInt32 m_v3dLastAccessedBlockPos; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 46b89c36..ff72cde0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -421,7 +421,7 @@ namespace PolyVox for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) { Vector3DInt32 pos(x,y,z); - typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); + typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); if(itBlock != m_pBlocks.end()) { @@ -452,7 +452,7 @@ namespace PolyVox template void LargeVolume::flushAll() { - typename std::map, BlockPositionCompare>::iterator i; + typename std::map, BlockPositionCompare>::iterator i; //Replaced the for loop here as the call to //eraseBlock was invalidating the iterator. while(m_pBlocks.size() > 0) @@ -486,7 +486,7 @@ namespace PolyVox for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) { Vector3DInt32 pos(x,y,z); - typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); + typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); if(itBlock == m_pBlocks.end()) { // not loaded, not unloading @@ -564,7 +564,7 @@ namespace PolyVox } template - void LargeVolume::eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const + void LargeVolume::eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const { POLYVOX_ASSERT(false, "This function has not been implemented properly"); @@ -603,16 +603,16 @@ namespace PolyVox } template - Block* LargeVolume::getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const + CompressedBlock* LargeVolume::getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const { Vector3DInt32 v3dBlockPos(uBlockX, uBlockY, uBlockZ); - typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos); + typename std::map, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos); // check whether the block is already loaded if(itBlock == m_pBlocks.end()) { //The block is not in the map, so we will have to create a new block and add it. - Block newBlock(m_uBlockSideLength, m_pCompressor); + CompressedBlock newBlock(m_uBlockSideLength, m_pCompressor); itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first; // Now use the pager to fill the block with it's initial data. @@ -626,7 +626,7 @@ namespace PolyVox } //Get the block and mark that we accessed it - Block& block = itBlock->second; + CompressedBlock& block = itBlock->second; block.timestamp = ++m_uTimestamper; //m_v3dLastAccessedBlockPos = v3dBlockPos; @@ -648,7 +648,7 @@ namespace PolyVox } //Get the block and mark that we accessed it - Block* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ); + CompressedBlock* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ); typename std::map::iterator itUncompressedBlock = m_pUncompressedBlockCache.find(v3dBlockPos); @@ -697,7 +697,7 @@ namespace PolyVox uint32_t uSizeInBytes = sizeof(LargeVolume); //Memory used by the blocks - typename std::map, BlockPositionCompare>::iterator i; + typename std::map, BlockPositionCompare>::iterator i; for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) { //Inaccurate - account for rest of loaded block. @@ -716,7 +716,7 @@ namespace PolyVox { uint32_t uMemoryUsage = 0; - typename std::map, BlockPositionCompare>::iterator i; + typename std::map, BlockPositionCompare>::iterator i; for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) { //Inaccurate - account for rest of loaded block. @@ -736,8 +736,8 @@ namespace PolyVox while(calculateBlockMemoryUsage() > m_uCompressedBlockMemoryLimitInBytes) //FIXME - This calculation of size is slow and should be outside the loop. { // find the least recently used block - typename std::map, BlockPositionCompare>::iterator i; - typename std::map, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin(); + typename std::map, BlockPositionCompare>::iterator i; + typename std::map, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin(); for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) { if(i->second.timestamp < itUnloadBlock->second.timestamp) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Pager.h b/library/PolyVoxCore/include/PolyVoxCore/Pager.h index 4cb95adc..af1e3387 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Pager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Pager.h @@ -41,8 +41,8 @@ namespace PolyVox /// Destructor virtual ~Pager() {}; - virtual void pageIn(const Region& region, Block* pBlockData) = 0; - virtual void pageOut(const Region& region, Block* pBlockData) = 0; + virtual void pageIn(const Region& region, CompressedBlock* pBlockData) = 0; + virtual void pageOut(const Region& region, CompressedBlock* pBlockData) = 0; }; }