From 4ed8d4303bee54996b559216f8130e22480e0646 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 4 Dec 2012 22:41:45 +0100 Subject: [PATCH] LargeVolume now uses the version of border handling which is in the BaseVolume. --- .../include/PolyVoxCore/LargeVolume.h | 10 ------ .../include/PolyVoxCore/LargeVolume.inl | 34 ------------------- .../PolyVoxCore/LargeVolumeSampler.inl | 11 ++---- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 7794f914..3755dae0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -267,8 +267,6 @@ namespace PolyVox /// Destructor ~LargeVolume(); - /// Gets the value used for voxels which are outside the volume - VoxelType getBorderValue(void) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector @@ -280,8 +278,6 @@ namespace PolyVox void setMaxNumberOfUncompressedBlocks(uint32_t uMaxNumberOfUncompressedBlocks); /// Sets the number of blocks which can be in memory before the paging system starts unloading them void setMaxNumberOfBlocksInMemory(uint32_t uMaxNumberOfBlocksInMemory); - /// Sets the value used for voxels which are outside the volume - void setBorderValue(const VoxelType& tBorder); /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); /// Sets the voxel at the position given by a 3D vector @@ -339,12 +335,6 @@ namespace PolyVox uint32_t m_uMaxNumberOfUncompressedBlocks; uint32_t m_uMaxNumberOfBlocksInMemory; - //We don't store an actual Block for the border, just the uncompressed data. This is partly because the border - //block does not have a position (so can't be passed to getUncompressedBlock()) and partly because there's a - //good chance we'll often hit it anyway. It's a chunk of homogenous data (rather than a single value) so that - //the VolumeIterator can do it's usual pointer arithmetic without needing to know it's gone outside the volume. - VoxelType* m_pUncompressedBorderData; - //The size of the volume Region m_regValidRegionInBlocks; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 54df09c5..45465445 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -95,7 +95,6 @@ namespace PolyVox LargeVolume::~LargeVolume() { flushAll(); - delete[] m_pUncompressedBorderData; } //////////////////////////////////////////////////////////////////////////////// @@ -111,17 +110,6 @@ namespace PolyVox assert(false); // See function comment above. } - //////////////////////////////////////////////////////////////////////////////// - /// The border value is returned whenever an atempt is made to read a voxel which - /// is outside the extents of the volume. - /// \return The value used for voxels outside of the volume - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType LargeVolume::getBorderValue(void) const - { - return *m_pUncompressedBorderData; - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos The \c x position of the voxel /// \param uYPos The \c y position of the voxel @@ -213,17 +201,6 @@ namespace PolyVox m_uMaxNumberOfBlocksInMemory = uMaxNumberOfBlocksInMemory; } - //////////////////////////////////////////////////////////////////////////////// - /// \param tBorder The value to use for voxels outside the volume. - //////////////////////////////////////////////////////////////////////////////// - template - void LargeVolume::setBorderValue(const VoxelType& tBorder) - { - /*Block* pUncompressedBorderBlock = getUncompressedBlock(&m_pBorderBlock); - return pUncompressedBorderBlock->fill(tBorder);*/ - std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, tBorder); - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos the \c x position of the voxel /// \param uYPos the \c y position of the voxel @@ -414,7 +391,6 @@ namespace PolyVox m_uTimestamper = 0; m_uMaxNumberOfUncompressedBlocks = 16; m_uBlockSideLength = uBlockSideLength; - m_pUncompressedBorderData = 0; m_uMaxNumberOfBlocksInMemory = 1024; m_v3dLastAccessedBlockPos = Vector3DInt32(0,0,0); //There are no invalid positions, but initially the m_pLastAccessedBlock pointer will be null; m_pLastAccessedBlock = 0; @@ -437,10 +413,6 @@ namespace PolyVox //Clear the previous data m_pBlocks.clear(); - //Create the border block - m_pUncompressedBorderData = new VoxelType[m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength]; - std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); - //Other properties we might find useful later this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth()); this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth()); @@ -647,12 +619,6 @@ namespace PolyVox uSizeInBytes += m_vecUncompressedBlockCache.capacity() * sizeof(LoadedBlock); uSizeInBytes += m_vecUncompressedBlockCache.size() * m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType); - //Memory used by border data. - if(m_pUncompressedBorderData) - { - uSizeInBytes += m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType); - } - return uSizeInBytes; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 63b1270c..e61e2a71 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -130,16 +130,9 @@ namespace PolyVox uYPosInBlock * this->mVolume->m_uBlockSideLength + uZPosInBlock * this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; - if(this->mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) - { - Block* pUncompressedCurrentBlock = this->mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); + Block* pUncompressedCurrentBlock = this->mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); - mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock; - } - else - { - mCurrentVoxel = this->mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock; - } + mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock; } template