Removed Block class.
This commit is contained in:
parent
5418be6313
commit
6e1ddaeb97
@ -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
|
||||
|
@ -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 <typename VoxelType>
|
||||
class Block
|
||||
{
|
||||
public:
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > m_pBlockData;
|
||||
};
|
||||
}
|
||||
|
||||
#include "Block.inl"
|
||||
|
||||
#endif
|
@ -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<VoxelType> > getHomogenousBlockData(VoxelType tHomogenousValue) const;
|
||||
|
||||
std::vector< Block<VoxelType> > m_pBlocks;
|
||||
std::vector< POLYVOX_SHARED_PTR< BlockData<VoxelType> > > m_pBlocks;
|
||||
std::vector<bool> m_vecBlockIsPotentiallyHomogenous;
|
||||
|
||||
//Note: We were once storing weak_ptr's in this map, so that the blocks would be deleted once they
|
||||
|
@ -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<VoxelType>& 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 <typename VoxelType>
|
||||
@ -169,26 +169,26 @@ namespace PolyVox
|
||||
blockY * m_uSideLengthInBlocks +
|
||||
blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks;
|
||||
|
||||
Block<VoxelType>& block = m_pBlocks[uBlockIndex];
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> >& 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<VoxelType> > pNewBlockData(new BlockData<VoxelType>(*(block.m_pBlockData)));
|
||||
block.m_pBlockData = pNewBlockData;
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > pNewBlockData(new BlockData<VoxelType>(*(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<VoxelType, POLYVOX_SHARED_PTR< BlockData<VoxelType> > >::iterator iterResult = m_pHomogenousBlockData.find(tHomogenousValue);
|
||||
if(iterResult == m_pHomogenousBlockData.end())
|
||||
{
|
||||
Block<VoxelType> block;
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > temp(new BlockData<VoxelType>(m_uBlockSideLength));
|
||||
block.m_pBlockData = temp;
|
||||
//Block<VoxelType> block;
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > pHomogeneousBlock(new BlockData<VoxelType>(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
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ namespace PolyVox
|
||||
mBlockIndexInVolume = mXBlock +
|
||||
mYBlock * mVolume.m_uSideLengthInBlocks +
|
||||
mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks;
|
||||
boost::shared_ptr< BlockData<VoxelType> > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume].m_pBlockData;
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume];
|
||||
|
||||
mVoxelIndexInBlock = mXPosInBlock +
|
||||
mYPosInBlock * mVolume.m_uBlockSideLength +
|
||||
|
Loading…
x
Reference in New Issue
Block a user