From 34c41cd32efa66c380762a8e208326f4889d016a Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 8 Mar 2009 00:03:35 +0000 Subject: [PATCH] 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. --- .../PolyVoxCore/BlockVolumeIterator.inl | 20 ++++++++++--------- library/include/PolyVoxCore/Constants.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/library/include/PolyVoxCore/BlockVolumeIterator.inl b/library/include/PolyVoxCore/BlockVolumeIterator.inl index b1c6d04b..f08750ab 100644 --- a/library/include/PolyVoxCore/BlockVolumeIterator.inl +++ b/library/include/PolyVoxCore/BlockVolumeIterator.inl @@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "BlockVolume.h" #include "Vector.h" #include "Region.h" + +#include #pragma endregion namespace PolyVox @@ -133,27 +135,27 @@ namespace PolyVox else if(uLevel == 1) { VoxelType tValue = getVoxel(); - tValue = (std::max)(tValue, peekVoxel1px0py0pz()); - tValue = (std::max)(tValue, peekVoxel0px1py0pz()); - tValue = (std::max)(tValue, peekVoxel1px1py0pz()); - tValue = (std::max)(tValue, peekVoxel0px0py1pz()); - tValue = (std::max)(tValue, peekVoxel1px0py1pz()); - tValue = (std::max)(tValue, peekVoxel0px1py1pz()); - tValue = (std::max)(tValue, peekVoxel1px1py1pz()); + tValue = (std::min)(tValue, peekVoxel1px0py0pz()); + tValue = (std::min)(tValue, peekVoxel0px1py0pz()); + tValue = (std::min)(tValue, peekVoxel1px1py0pz()); + tValue = (std::min)(tValue, peekVoxel0px0py1pz()); + tValue = (std::min)(tValue, peekVoxel1px0py1pz()); + tValue = (std::min)(tValue, peekVoxel0px1py1pz()); + tValue = (std::min)(tValue, peekVoxel1px1py1pz()); return tValue; } else { const uint8 uSize = 1 << uLevel; - VoxelType tValue = 0; + VoxelType tValue = std::numeric_limits::max(); for(uint8 z = 0; z < uSize; ++z) { for(uint8 y = 0; y < uSize; ++y) { 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)); } } } diff --git a/library/include/PolyVoxCore/Constants.h b/library/include/PolyVoxCore/Constants.h index 6bfe2e23..3edeea58 100644 --- a/library/include/PolyVoxCore/Constants.h +++ b/library/include/PolyVoxCore/Constants.h @@ -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_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_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER); }