diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h index 45035247..b24ff159 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h @@ -53,6 +53,10 @@ namespace PolyVox DataType data; }; + // Convienient shorthand for declaring a mesh of 'cubic' vertices + template + using CubicMesh = Mesh< CubicVertex, IndexType >; + /// Decodes a position from a CubicVertex inline Vector3DFloat decodePosition(const Vector3DUint8& encodedPosition) { @@ -196,9 +200,9 @@ namespace PolyVox } template > - Mesh > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) + CubicMesh extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) { - Mesh< CubicVertex > result; + CubicMesh result; extractCubicMeshCustom(volData, region, &result, isQuadNeeded, eWrapMode, tBorderValue, bMergeQuads); return result; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h index 5faab2f3..9f722098 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h @@ -55,6 +55,10 @@ namespace PolyVox DataType data; }; + // Convienient shorthand for declaring a mesh of marching cubes vertices + template + using MarchingCubesMesh = Mesh< MarchingCubesVertex, IndexType >; + /// Decodes a position from a MarchingCubesVertex inline Vector3DFloat decodePosition(const Vector3DUint16& encodedPosition) { @@ -339,10 +343,10 @@ namespace PolyVox } template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController > - Mesh > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) + MarchingCubesMesh extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) { - Mesh > result; - extractMarchingCubesMeshCustom, DefaultIndexType > >(volData, region, &result, controller, eWrapMode, tBorderValue); + MarchingCubesMesh result; + extractMarchingCubesMeshCustom(volData, region, &result, controller, eWrapMode, tBorderValue); return result; } } diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index cbff3e62..4bafb89c 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -257,14 +257,14 @@ void TestCubicSurfaceExtractor::testExecute() // Test with default controller but user-provided mesh. auto uint32Vol = createAndFillVolumeWithNoise(0, 2); - Mesh< CubicVertex< uint32_t >, uint16_t > uint32Mesh; + CubicMesh< uint32_t, uint16_t > uint32Mesh; extractCubicMeshCustom(uint32Vol, uint32Vol->getEnclosingRegion(), &uint32Mesh); QCOMPARE(uint32Mesh.getNoOfVertices(), uint16_t(57687)); QCOMPARE(uint32Mesh.getNoOfIndices(), uint32_t(216234)); // Test with both mesh and controller being provided by the user. auto int32Vol = createAndFillVolumeWithNoise(0, 2); - Mesh< CubicVertex< int32_t >, uint16_t > int32Mesh; + CubicMesh< int32_t, uint16_t > int32Mesh; extractCubicMeshCustom(int32Vol, int32Vol->getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded()); QCOMPARE(int32Mesh.getNoOfVertices(), uint16_t(29027)); QCOMPARE(int32Mesh.getNoOfIndices(), uint32_t(178356)); diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 7c0e6ddb..8434be94 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -148,10 +148,9 @@ void TestSurfaceExtractor::testExecute() QCOMPARE(floatMesh.getIndex(100), uint32_t(26)); // Verifies that we have 32-bit indices QCOMPARE(floatMesh.getVertex(100).data, float(1.0f)); // Not really meaningful for a primative type - // This test makes use of a user provided mesh. It uses the default controller, but we have to explicitly provide this because C++ won't let us - // use a default for the second-to-last parameter but noot use a default for the last parameter. + // This test makes use of a user provided mesh, while stil using the default controller. auto intVol = createAndFillVolume(); - Mesh< MarchingCubesVertex< int8_t >, uint16_t > intMesh; + MarchingCubesMesh< int8_t, uint16_t > intMesh; extractMarchingCubesMeshCustom(intVol, intVol->getEnclosingRegion(), &intMesh); QCOMPARE(intMesh.getNoOfVertices(), uint16_t(11718)); // Verifies size of mesh and that we have 16-bit indices QCOMPARE(intMesh.getNoOfIndices(), uint32_t(34041)); // Verifies size of mesh @@ -161,7 +160,7 @@ void TestSurfaceExtractor::testExecute() // This test makes use of a user-provided mesh and also a custom controller. auto doubleVol = createAndFillVolume(); CustomMarchingCubesController doubleCustomController; - Mesh< MarchingCubesVertex< double >, uint16_t > doubleMesh; + MarchingCubesMesh< double, uint16_t > doubleMesh; extractMarchingCubesMeshCustom(doubleVol, doubleVol->getEnclosingRegion(), &doubleMesh, doubleCustomController); QCOMPARE(doubleMesh.getNoOfVertices(), uint16_t(16113)); // Verifies size of mesh and that we have 32-bit indices QCOMPARE(doubleMesh.getNoOfIndices(), uint32_t(22053)); // Verifies size of mesh