diff --git a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h index 3da41519..81d382e1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h +++ b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h @@ -24,6 +24,8 @@ freely, subject to the following restrictions: #ifndef __PolyVox_MarchingCubesController_H__ #define __PolyVox_MarchingCubesController_H__ +#include "PolyVoxCore/BaseVolume.h" + #include namespace PolyVox @@ -77,17 +79,21 @@ namespace PolyVox DefaultMarchingCubesController(void) { m_tThreshold = ((std::numeric_limits::min)() + (std::numeric_limits::max)()) / 2; + m_eWrapMode = WrapModes::Border; + m_tBorder = 0; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Constructor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// This version of the constructor allows you to set a custom threshold. + /// This version of the constructor allows you to set some custom parameters /// \param tThreshold The threshold to use. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DefaultMarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; + m_eWrapMode = WrapModes::Border; + m_tBorder = 0; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -124,8 +130,21 @@ namespace PolyVox return m_tThreshold; } - private: + WrapMode getWrapMode(void) + { + return m_eWrapMode; + } + + void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType(0)) + { + m_eWrapMode = eWrapMode; + m_tBorder = tBorder; + } + + public: DensityType m_tThreshold; + WrapMode m_eWrapMode; + VoxelType m_tBorder; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index 36e3f268..a08481d3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -155,11 +155,13 @@ namespace PolyVox { // Default to a threshold value halfway between the min and max possible values. m_tThreshold = (Density::getMinDensity() + Density::getMaxDensity()) / 2; + m_eWrapMode = WrapModes::Border; } DefaultMarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; + m_eWrapMode = WrapModes::Border; } DensityType convertToDensity(Density voxel) @@ -177,8 +179,20 @@ namespace PolyVox return m_tThreshold; } - private: + WrapMode getWrapMode(void) + { + return m_eWrapMode; + } + + void setWrapMode(WrapMode eWrapMode) + { + m_eWrapMode = eWrapMode; + } + + public: DensityType m_tThreshold; + WrapMode m_eWrapMode; + Density m_tBorder; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl index 0b591e6c..05bb2c64 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl @@ -35,6 +35,8 @@ namespace PolyVox //m_regSizeInVoxels.cropTo(m_volData->getEnclosingRegion()); m_regSizeInCells = m_regSizeInVoxels; m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1)); + + m_sampVolume.setWrapMode(m_controller.getWrapMode(), m_controller.m_tBorder); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 66baf66e..2b85c7e8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -119,11 +119,13 @@ namespace PolyVox { // Default to a threshold value halfway between the min and max possible values. m_tThreshold = (MaterialDensityPair::getMinDensity() + MaterialDensityPair::getMaxDensity()) / 2; + m_eWrapMode = WrapModes::Border; } DefaultMarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; + m_eWrapMode = WrapModes::Border; } DensityType convertToDensity(MaterialDensityPair voxel) @@ -139,10 +141,22 @@ namespace PolyVox DensityType getThreshold(void) { return m_tThreshold; - } + } - private: + WrapMode getWrapMode(void) + { + return m_eWrapMode; + } + + void setWrapMode(WrapMode eWrapMode) + { + m_eWrapMode = eWrapMode; + } + + public: DensityType m_tThreshold; + WrapMode m_eWrapMode; + MaterialDensityPair m_tBorder; }; typedef MaterialDensityPair MaterialDensityPair44; diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 4fad37bd..116894a9 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -59,6 +59,13 @@ public: { return 50.0f; } + + WrapMode getWrapMode(void) + { + return WrapModes::Border; + } + + float m_tBorder; }; // These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types. @@ -145,6 +152,7 @@ void testCustomController(SurfaceMesh& result) } CustomMarchingCubesController controller; + controller.m_tBorder = 0.0f; //Temporary HACK! MarchingCubesSurfaceExtractor< SimpleVolume, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller); extractor.execute(); }