Decimation now handles level 0 and level 1. Crashes on level 2...

This commit is contained in:
David Williams
2008-06-12 21:16:50 +00:00
parent e019c92dc2
commit eed6d56cb6
5 changed files with 170 additions and 166 deletions

View File

@ -137,13 +137,13 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType BlockVolumeIterator<VoxelType>::getMaxedVoxel(boost::uint8_t level) const
VoxelType BlockVolumeIterator<VoxelType>::getMaxedVoxel(boost::uint8_t uLevel) const
{
if(level == 0)
if(uLevel == 0)
{
return getVoxel();
}
else if(level == 1)
else if(uLevel == 1)
{
VoxelType tValue = getVoxel();
tValue = (std::max)(tValue, peekVoxel1px0py0pz());
@ -155,8 +155,23 @@ namespace PolyVox
tValue = (std::max)(tValue, peekVoxel1px1py1pz());
return tValue;
}
assert(false);
return 0;
else
{
const boost::uint8_t uSize = 1 << uLevel;
VoxelType tValue = 0;
for(boost::uint8_t z = 0; z < uSize; ++z)
{
for(boost::uint8_t y = 0; y < uSize; ++y)
{
for(boost::uint8_t x = 0; x < uSize; ++x)
{
tValue = (std::max)(tValue, mVolume.getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z));
}
}
}
return tValue;
}
}
template <typename VoxelType>