diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 95091e97..04631482 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -42,8 +42,6 @@ SET(IMPL_SRC_FILES ) SET(IMPL_INC_FILES - include/PolyVoxImpl/Block.h - include/PolyVoxImpl/Block.inl include/PolyVoxImpl/BlockData.h include/PolyVoxImpl/BlockData.inl include/PolyVoxImpl/CPlusPlusZeroXSupport.h diff --git a/library/PolyVoxCore/include/PolyVoxImpl/Block.h b/library/PolyVoxCore/include/PolyVoxImpl/Block.h deleted file mode 100644 index d6ee0821..00000000 --- a/library/PolyVoxCore/include/PolyVoxImpl/Block.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma region License -/****************************************************************************** -This file is part of the PolyVox library -Copyright (C) 2006 David Williams - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -******************************************************************************/ -#pragma endregion - -#ifndef __PolyVox_Block_H__ -#define __PolyVox_Block_H__ - -#pragma region Headers -#include "BlockData.h" -#include "CPlusPlusZeroXSupport.h" -#pragma endregion - -namespace PolyVox -{ - template - class Block - { - public: - POLYVOX_SHARED_PTR< BlockData > m_pBlockData; - }; -} - -#include "Block.inl" - -#endif diff --git a/library/PolyVoxCore/include/PolyVoxImpl/Block.inl b/library/PolyVoxCore/include/PolyVoxImpl/Block.inl deleted file mode 100644 index e69de29b..00000000 diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index fc35dd96..8c142db0 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define __PolyVox_Volume_H__ #pragma region Headers -#include "PolyVoxImpl/Block.h" +#include "PolyVoxImpl/BlockData.h" #include "PolyVoxForwardDeclarations.h" #include "PolyVoxImpl/CPlusPlusZeroXSupport.h" @@ -63,7 +63,7 @@ namespace PolyVox private: POLYVOX_SHARED_PTR< BlockData > getHomogenousBlockData(VoxelType tHomogenousValue) const; - std::vector< Block > m_pBlocks; + std::vector< POLYVOX_SHARED_PTR< BlockData > > 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 diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index 3a028f85..652ba6bc 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -78,7 +78,7 @@ namespace PolyVox m_vecBlockIsPotentiallyHomogenous.resize(m_uNoOfBlocksInVolume); for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { - m_pBlocks[i].m_pBlockData = getHomogenousBlockData(0); + m_pBlocks[i] = getHomogenousBlockData(0); m_vecBlockIsPotentiallyHomogenous[i] = false; } } @@ -131,14 +131,14 @@ namespace PolyVox const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - const Block& block = m_pBlocks + const POLYVOX_SHARED_PTR< BlockData< VoxelType > >& block = m_pBlocks [ blockX + blockY * m_uSideLengthInBlocks + blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks ]; - return block.m_pBlockData->getVoxelAt(xOffset,yOffset,zOffset); + return block->getVoxelAt(xOffset,yOffset,zOffset); } template @@ -169,26 +169,26 @@ namespace PolyVox blockY * m_uSideLengthInBlocks + blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks; - Block& block = m_pBlocks[uBlockIndex]; + POLYVOX_SHARED_PTR< BlockData >& 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 //because it lets us avoid unsharing blocks unnecessarily. - if(block.m_pBlockData->getVoxelAt(xOffset, yOffset, zOffset) != tValue) + if(block->getVoxelAt(xOffset, yOffset, zOffset) != tValue) { - if(block.m_pBlockData.unique()) + if(block.unique()) { - block.m_pBlockData->setVoxelAt(xOffset,yOffset,zOffset, tValue); + block->setVoxelAt(xOffset,yOffset,zOffset, tValue); //There is a chance that setting this voxel makes the block homogenous and therefore shareable. //But checking this will take some time, so for now just set a flag. m_vecBlockIsPotentiallyHomogenous[uBlockIndex] = true; } else { - POLYVOX_SHARED_PTR< BlockData > pNewBlockData(new BlockData(*(block.m_pBlockData))); - block.m_pBlockData = pNewBlockData; + POLYVOX_SHARED_PTR< BlockData > pNewBlockData(new BlockData(*(block))); + block = pNewBlockData; m_vecBlockIsPotentiallyHomogenous[uBlockIndex] = false; - block.m_pBlockData->setVoxelAt(xOffset,yOffset,zOffset, tValue); + block->setVoxelAt(xOffset,yOffset,zOffset, tValue); } } } @@ -221,11 +221,11 @@ namespace PolyVox if(m_vecBlockIsPotentiallyHomogenous[m_uCurrentBlockForTidying]) { //Check if it's really homogeneous (this can be slow). - if(m_pBlocks[m_uCurrentBlockForTidying].m_pBlockData->isHomogeneous()) + if(m_pBlocks[m_uCurrentBlockForTidying]->isHomogeneous()) { //If so, replace is with a block from out homogeneous collection. - VoxelType homogeneousValue = m_pBlocks[m_uCurrentBlockForTidying].m_pBlockData->getVoxelAt(0,0,0); - m_pBlocks[m_uCurrentBlockForTidying].m_pBlockData = getHomogenousBlockData(homogeneousValue); + VoxelType homogeneousValue = m_pBlocks[m_uCurrentBlockForTidying]->getVoxelAt(0,0,0); + m_pBlocks[m_uCurrentBlockForTidying] = getHomogenousBlockData(homogeneousValue); } //Either way, we have now determined whether the block was sharable. So it's not *potentially* sharable. @@ -285,13 +285,13 @@ namespace PolyVox typename std::map > >::iterator iterResult = m_pHomogenousBlockData.find(tHomogenousValue); if(iterResult == m_pHomogenousBlockData.end()) { - Block block; - POLYVOX_SHARED_PTR< BlockData > temp(new BlockData(m_uBlockSideLength)); - block.m_pBlockData = temp; + //Block block; + POLYVOX_SHARED_PTR< BlockData > pHomogeneousBlock(new BlockData(m_uBlockSideLength)); + //block.m_pBlockData = temp; //block.m_uReferenceCount++; - block.m_pBlockData->fill(tHomogenousValue); - m_pHomogenousBlockData.insert(std::make_pair(tHomogenousValue, temp)); - return block.m_pBlockData; + pHomogeneousBlock->fill(tHomogenousValue); + m_pHomogenousBlockData.insert(std::make_pair(tHomogenousValue, pHomogeneousBlock)); + return pHomogeneousBlock; } else { diff --git a/library/PolyVoxCore/include/VolumeIterator.inl b/library/PolyVoxCore/include/VolumeIterator.inl index 55453d84..08a2aa3d 100644 --- a/library/PolyVoxCore/include/VolumeIterator.inl +++ b/library/PolyVoxCore/include/VolumeIterator.inl @@ -201,7 +201,7 @@ namespace PolyVox mBlockIndexInVolume = mXBlock + mYBlock * mVolume.m_uSideLengthInBlocks + mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks; - boost::shared_ptr< BlockData > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume].m_pBlockData; + POLYVOX_SHARED_PTR< BlockData > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength +