From b7ea308897ec6d28f0bf918ffdeca51c21acf4ba Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 26 Apr 2009 21:09:01 +0000 Subject: [PATCH] Renamed BlockData to Block --- library/PolyVoxCore/include/Block.h | 10 +++--- library/PolyVoxCore/include/Block.inl | 24 +++++++------- .../include/PolyVoxForwardDeclarations.h | 2 +- library/PolyVoxCore/include/Volume.h | 8 ++--- library/PolyVoxCore/include/Volume.inl | 32 +++++++++---------- .../PolyVoxCore/include/VolumeIterator.inl | 8 ++--- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/library/PolyVoxCore/include/Block.h b/library/PolyVoxCore/include/Block.h index 27df1afa..3cdfdb67 100644 --- a/library/PolyVoxCore/include/Block.h +++ b/library/PolyVoxCore/include/Block.h @@ -31,16 +31,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { template - class BlockData + class Block { //Make VolumeIterator a friend friend class VolumeIterator; public: - BlockData(uint16_t uSideLength); - BlockData(const BlockData& rhs); - ~BlockData(); + Block(uint16_t uSideLength); + Block(const Block& rhs); + ~Block(); - BlockData& operator=(const BlockData& rhs); + Block& operator=(const Block& rhs); uint16_t getSideLength(void) const; VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; diff --git a/library/PolyVoxCore/include/Block.inl b/library/PolyVoxCore/include/Block.inl index 0872cae1..5a241323 100644 --- a/library/PolyVoxCore/include/Block.inl +++ b/library/PolyVoxCore/include/Block.inl @@ -33,7 +33,7 @@ namespace PolyVox { #pragma region Constructors/Destructors template - BlockData::BlockData(uint16_t uSideLength) + Block::Block(uint16_t uSideLength) :m_tData(0) { //Debug mode validation @@ -42,7 +42,7 @@ namespace PolyVox //Release mode validation if(!isPowerOf2(uSideLength)) { - throw std::invalid_argument("BlockData side length must be a power of two."); + throw std::invalid_argument("Block side length must be a power of two."); } //Compute the side length @@ -55,13 +55,13 @@ namespace PolyVox } template - BlockData::BlockData(const BlockData& rhs) + Block::Block(const Block& rhs) { *this = rhs; } template - BlockData::~BlockData() + Block::~Block() { delete[] m_tData; m_tData = 0; @@ -70,7 +70,7 @@ namespace PolyVox #pragma region Operators template - BlockData& BlockData::operator=(const BlockData& rhs) + Block& Block::operator=(const Block& rhs) { if (this == &rhs) { @@ -92,13 +92,13 @@ namespace PolyVox #pragma region Getters template - uint16_t BlockData::getSideLength(void) const + uint16_t Block::getSideLength(void) const { return m_uSideLength; } template - VoxelType BlockData::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const + VoxelType Block::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); @@ -113,7 +113,7 @@ namespace PolyVox } template - VoxelType BlockData::getVoxelAt(const Vector3DUint16& v3dPos) const + VoxelType Block::getVoxelAt(const Vector3DUint16& v3dPos) const { return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } @@ -121,7 +121,7 @@ namespace PolyVox #pragma region Setters template - void BlockData::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) + void Block::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); @@ -136,7 +136,7 @@ namespace PolyVox } template - void BlockData::setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue) + void Block::setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue) { setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); } @@ -144,13 +144,13 @@ namespace PolyVox #pragma region Other template - void BlockData::fill(VoxelType tValue) + void Block::fill(VoxelType tValue) { memset(m_tData, (int)tValue, m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType)); } template - bool BlockData::isHomogeneous(void) + bool Block::isHomogeneous(void) { const VoxelType tFirstVoxel = m_tData[0]; const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; diff --git a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h index ecfe6a24..045ba129 100644 --- a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - template class BlockData; + template class Block; //---------- Volume ---------- template class Volume; diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index b5d3fd34..7f323d89 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -66,9 +66,9 @@ namespace PolyVox bool isRegionHomogenous(const Region& region); private: - POLYVOX_SHARED_PTR< BlockData > getHomogenousBlockData(VoxelType tHomogenousValue) const; + POLYVOX_SHARED_PTR< Block > getHomogenousBlock(VoxelType tHomogenousValue) const; - std::vector< POLYVOX_SHARED_PTR< BlockData > > m_pBlocks; + std::vector< POLYVOX_SHARED_PTR< Block > > m_pBlocks; std::vector m_vecBlockIsPotentiallyHomogenous; //Note: We were once storing weak_ptr's in this map, so that the blocks would be deleted once they @@ -76,7 +76,7 @@ namespace PolyVox //shared. A call to shared_ptr::unique() from within setVoxel was not sufficient as weak_ptr's did //not contribute to the reference count. Instead we store shared_ptr's here, and check if they //are used by anyone else (i.e are non-unique) when we tidy the volume. - static std::map > > m_pHomogenousBlockData; + static std::map > > m_pHomogenousBlock; uint32_t m_uNoOfBlocksInVolume; @@ -105,7 +105,7 @@ namespace PolyVox }; //Required for the static member - template std::map > > Volume::m_pHomogenousBlockData; + template std::map > > Volume::m_pHomogenousBlock; //Some handy typedefs diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index 7cefe893..9441a939 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -109,7 +109,7 @@ namespace PolyVox m_vecBlockIsPotentiallyHomogenous.resize(m_uNoOfBlocksInVolume); for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { - m_pBlocks[i] = getHomogenousBlockData(0); + m_pBlocks[i] = getHomogenousBlock(0); m_vecBlockIsPotentiallyHomogenous[i] = false; } @@ -197,7 +197,7 @@ namespace PolyVox const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - const POLYVOX_SHARED_PTR< BlockData< VoxelType > >& block = m_pBlocks + const POLYVOX_SHARED_PTR< Block< VoxelType > >& block = m_pBlocks [ blockX + blockY * m_uWidthInBlocks + @@ -235,7 +235,7 @@ namespace PolyVox blockY * m_uWidthInBlocks + blockZ * m_uWidthInBlocks * m_uHeightInBlocks; - POLYVOX_SHARED_PTR< BlockData >& block = m_pBlocks[uBlockIndex]; + POLYVOX_SHARED_PTR< Block >& block = m_pBlocks[uBlockIndex]; //It's quite possible that the user might attempt to set a voxel to it's current value. //We test for this case firstly because it could help performance, but more importantly @@ -251,8 +251,8 @@ namespace PolyVox } else { - POLYVOX_SHARED_PTR< BlockData > pNewBlockData(new BlockData(*(block))); - block = pNewBlockData; + POLYVOX_SHARED_PTR< Block > pNewBlock(new Block(*(block))); + block = pNewBlock; m_vecBlockIsPotentiallyHomogenous[uBlockIndex] = false; block->setVoxelAt(xOffset,yOffset,zOffset, tValue); } @@ -291,7 +291,7 @@ namespace PolyVox { //If so, replace is with a block from out homogeneous collection. VoxelType homogeneousValue = m_pBlocks[m_uCurrentBlockForTidying]->getVoxelAt(0,0,0); - m_pBlocks[m_uCurrentBlockForTidying] = getHomogenousBlockData(homogeneousValue); + m_pBlocks[m_uCurrentBlockForTidying] = getHomogenousBlock(homogeneousValue); } //Either way, we have now determined whether the block was sharable. So it's not *potentially* sharable. @@ -307,12 +307,12 @@ namespace PolyVox } //Identify and remove any homogeneous blocks which are not actually in use. - typename std::map > >::iterator iter = m_pHomogenousBlockData.begin(); - while(iter != m_pHomogenousBlockData.end()) + typename std::map > >::iterator iter = m_pHomogenousBlock.begin(); + while(iter != m_pHomogenousBlock.end()) { if(iter->second.unique()) { - m_pHomogenousBlockData.erase(iter++); //Increments the iterator and returns the previous position to be erased. + m_pHomogenousBlock.erase(iter++); //Increments the iterator and returns the previous position to be erased. } else { @@ -346,23 +346,23 @@ namespace PolyVox #pragma region Private Implementation template - POLYVOX_SHARED_PTR< BlockData > Volume::getHomogenousBlockData(VoxelType tHomogenousValue) const + POLYVOX_SHARED_PTR< Block > Volume::getHomogenousBlock(VoxelType tHomogenousValue) const { - typename std::map > >::iterator iterResult = m_pHomogenousBlockData.find(tHomogenousValue); - if(iterResult == m_pHomogenousBlockData.end()) + typename std::map > >::iterator iterResult = m_pHomogenousBlock.find(tHomogenousValue); + if(iterResult == m_pHomogenousBlock.end()) { //Block block; - POLYVOX_SHARED_PTR< BlockData > pHomogeneousBlock(new BlockData(m_uBlockSideLength)); - //block.m_pBlockData = temp; + POLYVOX_SHARED_PTR< Block > pHomogeneousBlock(new Block(m_uBlockSideLength)); + //block.m_pBlock = temp; //block.m_uReferenceCount++; pHomogeneousBlock->fill(tHomogenousValue); - m_pHomogenousBlockData.insert(std::make_pair(tHomogenousValue, pHomogeneousBlock)); + m_pHomogenousBlock.insert(std::make_pair(tHomogenousValue, pHomogeneousBlock)); return pHomogeneousBlock; } else { //iterResult->second.m_uReferenceCount++; - //POLYVOX_SHARED_PTR< BlockData > result(iterResult->second); + //POLYVOX_SHARED_PTR< Block > result(iterResult->second); return iterResult->second; } } diff --git a/library/PolyVoxCore/include/VolumeIterator.inl b/library/PolyVoxCore/include/VolumeIterator.inl index 46f2e4f8..9df139a0 100644 --- a/library/PolyVoxCore/include/VolumeIterator.inl +++ b/library/PolyVoxCore/include/VolumeIterator.inl @@ -201,7 +201,7 @@ namespace PolyVox mBlockIndexInVolume = mXBlock + mYBlock * mVolume.m_uWidthInBlocks + mZBlock * mVolume.m_uWidthInBlocks * mVolume.m_uHeightInBlocks; - POLYVOX_SHARED_PTR< BlockData > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; + POLYVOX_SHARED_PTR< Block > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + @@ -257,7 +257,7 @@ namespace PolyVox mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength; - boost::shared_ptr< BlockData > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; + boost::shared_ptr< Block > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock; mYPosInBlock++; @@ -270,7 +270,7 @@ namespace PolyVox mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength; - BlockData* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; + Block* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock; mZPosInBlock++; @@ -309,7 +309,7 @@ namespace PolyVox } } - BlockData* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; + Block* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; //mCurrentBlock = mVolume->m_pBlocks[mBlockIndexInVolume]; mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength));