From 2bc8e8e201c2984fee0912a6de32b0f31ea9d9ac Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Fri, 14 Dec 2012 15:32:07 +0100 Subject: [PATCH] Tidying up marching cubes wrap mode support. --- .../DefaultMarchingCubesController.h | 25 +++++-------------- .../PolyVoxCore/include/PolyVoxCore/Density.h | 7 +++++- .../MarchingCubesSurfaceExtractor.inl | 2 +- .../include/PolyVoxCore/MaterialDensityPair.h | 7 +++++- tests/TestSurfaceExtractor.cpp | 6 +++-- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h index 59ca4345..2c958e91 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h +++ b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h @@ -83,19 +83,6 @@ namespace PolyVox { } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Constructor - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// 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; - }*/ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Converts the underlying voxel type into a density value. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -118,6 +105,11 @@ namespace PolyVox return 1; } + VoxelType getBorderValue(void) + { + return m_tBorder; + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Returns the density value which was passed to the constructor. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -135,11 +127,6 @@ namespace PolyVox return m_eWrapMode; } - VoxelType getBorderValue(void) - { - return m_tBorder; - } - void setThreshold(DensityType tThreshold) { m_tThreshold = tThreshold; @@ -151,7 +138,7 @@ namespace PolyVox m_tBorder = tBorder; } - public: + private: 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 1621a81e..a92d23b9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -174,6 +174,11 @@ namespace PolyVox return 1; } + Density getBorderValue(void) + { + return m_tBorder; + } + DensityType getThreshold(void) { return m_tThreshold; @@ -194,7 +199,7 @@ namespace PolyVox m_eWrapMode = eWrapMode; } - public: + private: 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 05bb2c64..23617603 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl @@ -36,7 +36,7 @@ namespace PolyVox m_regSizeInCells = m_regSizeInVoxels; m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1)); - m_sampVolume.setWrapMode(m_controller.getWrapMode(), m_controller.m_tBorder); + m_sampVolume.setWrapMode(m_controller.getWrapMode(), m_controller.getBorderValue()); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 3e40654c..d3df49b8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -138,6 +138,11 @@ namespace PolyVox return voxel.getMaterial(); } + MaterialDensityPair getBorderValue(void) + { + return m_tBorder; + } + DensityType getThreshold(void) { return m_tThreshold; @@ -158,7 +163,7 @@ namespace PolyVox m_eWrapMode = eWrapMode; } - public: + private: DensityType m_tThreshold; WrapMode m_eWrapMode; MaterialDensityPair m_tBorder; diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index d1b88ebc..4bc7fc15 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -65,7 +65,10 @@ public: return WrapModes::Border; } - float m_tBorder; + float getBorderValue(void) + { + return 0.0f; + } }; // These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types. @@ -153,7 +156,6 @@ void testCustomController(SurfaceMesh& result) } CustomMarchingCubesController controller; - controller.m_tBorder = 0.0f; //Temporary HACK! MarchingCubesSurfaceExtractor< SimpleVolume, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller); extractor.execute(); }