diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h index a225a3b5..443a2984 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h @@ -157,6 +157,28 @@ namespace PolyVox WrapMode m_eWrapMode; typename VolumeType::VoxelType m_tBorderValue; }; + + template + SurfaceMesh extractCubicSurface(VolumeType* volData, Region region, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) + { + SurfaceMesh result; + CubicSurfaceExtractor extractor(volData, region, &result, eWrapMode, tBorderValue, bMergeQuads, isQuadNeeded); + extractor.execute(); + return result; + } + + template + // This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template + // Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC? +#if defined(_MSC_VER) + SurfaceMesh extractCubicSurface(VolumeType* volData, Region region, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true) +#else + SurfaceMesh extractCubicSurface(VolumeType* volData, Region region, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) +#endif + { + DefaultIsQuadNeeded isQuadNeeded; + return extractCubicSurface >(volData, region, eWrapMode, tBorderValue, bMergeQuads, isQuadNeeded); + } } #include "PolyVoxCore/CubicSurfaceExtractor.inl" diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index 45919e85..319816d9 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -106,10 +106,9 @@ uint32_t testForType(void) { for (int32_t x = 0; x < uVolumeSideLength; x += uRegionSideLength) { - SurfaceMesh result; Region regionToExtract(x, y, z, x + uRegionSideLength - 1, y + uRegionSideLength - 1, z + uRegionSideLength - 1); - CubicSurfaceExtractor< SimpleVolume > extractor(&volData, regionToExtract, &result); - extractor.execute(); + + auto result = extractCubicSurface(&volData, regionToExtract); uTotalVertices += result.getNoOfVertices(); uTotalIndices += result.getNoOfIndices();