Removed homogeneous value from Block class.
This commit is contained in:
parent
2c2f99a8e2
commit
3a9c42576c
@ -34,7 +34,6 @@ namespace PolyVox
|
||||
{
|
||||
public:
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > m_pBlockData;
|
||||
VoxelType m_pHomogenousValue;
|
||||
bool m_bIsShared;
|
||||
bool m_bIsPotentiallySharable;
|
||||
};
|
||||
|
@ -77,9 +77,14 @@ namespace PolyVox
|
||||
return *this;
|
||||
}
|
||||
|
||||
//If this fails an exception will be thrown. Memory is not
|
||||
//allocated and there is nothing else in this class to clean up
|
||||
m_tData = new VoxelType[rhs.m_uSideLength * rhs.m_uSideLength * rhs.m_uSideLength];
|
||||
|
||||
//Copy the data
|
||||
m_uSideLength = rhs.m_uSideLength;
|
||||
m_uSideLengthPower = rhs.m_uSideLengthPower;
|
||||
memcpy(m_tData, rhs.m_tData, m_uSideLength * m_uSideLength * m_uSideLength);
|
||||
m_uSideLengthPower = rhs.m_uSideLengthPower;
|
||||
memcpy(m_tData, rhs.m_tData, m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ namespace PolyVox
|
||||
m_pBlocks[i].m_pBlockData = getHomogenousBlockData(0);
|
||||
m_pBlocks[i].m_bIsShared = true;
|
||||
m_pBlocks[i].m_bIsPotentiallySharable = false;
|
||||
m_pBlocks[i].m_pHomogenousValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,26 +170,27 @@ namespace PolyVox
|
||||
blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks
|
||||
];
|
||||
|
||||
if(block.m_bIsShared)
|
||||
//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)
|
||||
{
|
||||
const VoxelType tHomogenousValue = block.m_pHomogenousValue;
|
||||
if(tHomogenousValue != tValue)
|
||||
if(block.m_bIsShared)
|
||||
{
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > pNewBlockData(new BlockData<VoxelType>(m_uBlockSideLength));
|
||||
POLYVOX_SHARED_PTR< BlockData<VoxelType> > pNewBlockData(new BlockData<VoxelType>(*(block.m_pBlockData)));
|
||||
block.m_pBlockData = pNewBlockData;
|
||||
block.m_bIsShared = false;
|
||||
block.m_bIsPotentiallySharable = false;
|
||||
block.m_pBlockData->fill(tHomogenousValue);
|
||||
block.m_pBlockData->setVoxelAt(xOffset,yOffset,zOffset, tValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.m_pBlockData->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.
|
||||
block.m_bIsPotentiallySharable = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
block.m_pBlockData->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.
|
||||
block.m_bIsPotentiallySharable = true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -221,7 +221,6 @@ namespace PolyVox
|
||||
delete block.m_pBlockData;
|
||||
|
||||
block.m_pBlockData = getHomogenousBlockData(homogeneousValue);
|
||||
block.m_pHomogenousValue = homogeneousValue;
|
||||
block.m_bIsShared = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user