diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index 2cc544c9..0f243852 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -16,7 +16,6 @@ SET(CMAKE_DEBUG_POSTFIX "_d") SOURCE_GROUP("Sources" FILES ${SRC_FILES}) #SOURCE_GROUP("Headers" FILES ${INC_FILES}) -FIND_PACKAGE(Boost REQUIRED) FIND_PACKAGE(OpenGL REQUIRED) IF (WIN32) diff --git a/library/include/PolyVoxCore/BlockVolume.h b/library/include/PolyVoxCore/BlockVolume.h index 2229a20d..3d599920 100644 --- a/library/include/PolyVoxCore/BlockVolume.h +++ b/library/include/PolyVoxCore/BlockVolume.h @@ -54,6 +54,7 @@ namespace PolyVox bool containsPoint(const Vector3DInt32& pos, uint16 boundary) const; BlockVolumeIterator firstVoxel(void); void idle(uint32 uAmount); + bool isRegionHomogenous(const Region& region); BlockVolumeIterator lastVoxel(void); private: diff --git a/library/include/PolyVoxCore/BlockVolume.inl b/library/include/PolyVoxCore/BlockVolume.inl index edc389aa..f075e5a1 100644 --- a/library/include/PolyVoxCore/BlockVolume.inl +++ b/library/include/PolyVoxCore/BlockVolume.inl @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma region Headers #include "Block.h" +#include "BlockVolumeIterator.h" #include "Region.h" #include "Vector.h" @@ -204,6 +205,28 @@ namespace PolyVox { } + template + bool BlockVolume::isRegionHomogenous(const Region& region) + { + BlockVolumeIterator iter(*this); + iter.setValidRegion(region); + iter.setPosition(static_cast(region.getLowerCorner())); + + VoxelType tFirst = iter.getVoxel(); + iter.moveForwardInRegionXYZ(); + + do + { + VoxelType tCurrent = iter.getVoxel(); + if(tCurrent != tFirst) + { + return false; + } + }while(iter.moveForwardInRegionXYZ()); + + return true; + } + template BlockVolumeIterator BlockVolume::lastVoxel(void) { diff --git a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp index 587d6fed..a239330b 100644 --- a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp +++ b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp @@ -56,8 +56,8 @@ namespace PolyVox volRegionUpToDate = new LinearVolume(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS)); } - + //Return changed regions - cropped to volume void VolumeChangeTracker::getChangedRegions(std::list& listToFill) const { //Clear the list @@ -82,7 +82,10 @@ namespace PolyVox const uint16 lastY = firstY + POLYVOX_REGION_SIDE_LENGTH; const uint16 lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH; - listToFill.push_back(Region(Vector3DInt32(firstX, firstY, firstZ), Vector3DInt32(lastX, lastY, lastZ))); + Region region(Vector3DInt32(firstX, firstY, firstZ), Vector3DInt32(lastX, lastY, lastZ)); + region.cropTo(volumeData->getEnclosingRegion()); + + listToFill.push_back(region); } } }