Fixed getSubSampledVoxel to get minimum of values, not max. This hides cracks between LOD levels.

Changed region side length from 16 to 32. This reduces number of regions and hence batch count.
This commit is contained in:
David Williams
2009-03-08 00:03:35 +00:00
parent 2ae98647f6
commit 34c41cd32e
2 changed files with 12 additions and 10 deletions

View File

@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "BlockVolume.h" #include "BlockVolume.h"
#include "Vector.h" #include "Vector.h"
#include "Region.h" #include "Region.h"
#include <limits>
#pragma endregion #pragma endregion
namespace PolyVox namespace PolyVox
@ -133,27 +135,27 @@ namespace PolyVox
else if(uLevel == 1) else if(uLevel == 1)
{ {
VoxelType tValue = getVoxel(); VoxelType tValue = getVoxel();
tValue = (std::max)(tValue, peekVoxel1px0py0pz()); tValue = (std::min)(tValue, peekVoxel1px0py0pz());
tValue = (std::max)(tValue, peekVoxel0px1py0pz()); tValue = (std::min)(tValue, peekVoxel0px1py0pz());
tValue = (std::max)(tValue, peekVoxel1px1py0pz()); tValue = (std::min)(tValue, peekVoxel1px1py0pz());
tValue = (std::max)(tValue, peekVoxel0px0py1pz()); tValue = (std::min)(tValue, peekVoxel0px0py1pz());
tValue = (std::max)(tValue, peekVoxel1px0py1pz()); tValue = (std::min)(tValue, peekVoxel1px0py1pz());
tValue = (std::max)(tValue, peekVoxel0px1py1pz()); tValue = (std::min)(tValue, peekVoxel0px1py1pz());
tValue = (std::max)(tValue, peekVoxel1px1py1pz()); tValue = (std::min)(tValue, peekVoxel1px1py1pz());
return tValue; return tValue;
} }
else else
{ {
const uint8 uSize = 1 << uLevel; const uint8 uSize = 1 << uLevel;
VoxelType tValue = 0; VoxelType tValue = std::numeric_limits<VoxelType>::max();
for(uint8 z = 0; z < uSize; ++z) for(uint8 z = 0; z < uSize; ++z)
{ {
for(uint8 y = 0; y < uSize; ++y) for(uint8 y = 0; y < uSize; ++y)
{ {
for(uint8 x = 0; x < uSize; ++x) for(uint8 x = 0; x < uSize; ++x)
{ {
tValue = (std::max)(tValue, mVolume.getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); tValue = (std::min)(tValue, mVolume.getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z));
} }
} }
} }

View File

@ -37,7 +37,7 @@ namespace PolyVox
//const uint32 POLYVOX_NO_OF_BLOCKS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS); //const uint32 POLYVOX_NO_OF_BLOCKS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS);
//const uint32 POLYVOX_NO_OF_VOXELS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH); //const uint32 POLYVOX_NO_OF_VOXELS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH);
const uint16 POLYVOX_REGION_SIDE_LENGTH_POWER = 4; const uint16 POLYVOX_REGION_SIDE_LENGTH_POWER = 5;
const uint16 POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER); const uint16 POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER);
const uint16 POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER); const uint16 POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER);
} }