From 349009c67eec8047461ba5f3e8d3c469d65b76ae Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 19 Aug 2014 21:02:06 +0200 Subject: [PATCH] Removed template aliases as they push GCC version up to 4.7, and we don't really *need* them. --- .../include/PolyVoxCore/CubicSurfaceExtractor.h | 9 +++++---- .../PolyVoxCore/MarchingCubesSurfaceExtractor.h | 11 ++++++----- tests/TestCubicSurfaceExtractor.cpp | 8 ++++---- tests/TestSurfaceExtractor.cpp | 11 ++++++----- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h index ee100097..409ed096 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h @@ -54,8 +54,9 @@ namespace PolyVox }; // Convienient shorthand for declaring a mesh of 'cubic' vertices - template - using CubicMesh = Mesh< CubicVertex, IndexType >; + // Currently disabled because it requires GCC 4.7 + //template + //using CubicMesh = Mesh< CubicVertex, IndexType >; /// Decodes a position from a CubicVertex inline Vector3DFloat decodePosition(const Vector3DUint8& encodedPosition) @@ -214,9 +215,9 @@ namespace PolyVox /// Another scenario which sometimes results in confusion is when you wish to extract a region which corresponds to the whole volume, partcularly when solid voxels extend right to the edge of the volume. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template > - CubicMesh extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) + Mesh > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) { - CubicMesh result; + Mesh< CubicVertex > 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 0612a33f..cf42800e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h @@ -56,8 +56,9 @@ namespace PolyVox }; // Convienient shorthand for declaring a mesh of marching cubes vertices - template - using MarchingCubesMesh = Mesh< MarchingCubesVertex, IndexType >; + // Currently disabled because it requires GCC 4.7 + //template + //using MarchingCubesMesh = Mesh< MarchingCubesVertex, IndexType >; /// Decodes a position from a MarchingCubesVertex inline Vector3DFloat decodePosition(const Vector3DUint16& encodedPosition) @@ -344,10 +345,10 @@ namespace PolyVox } template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController > - MarchingCubesMesh extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) + Mesh > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) { - MarchingCubesMesh result; - extractMarchingCubesMeshCustom(volData, region, &result, controller, eWrapMode, tBorderValue); + Mesh > result; + extractMarchingCubesMeshCustom, DefaultIndexType > >(volData, region, &result, controller, eWrapMode, tBorderValue); return result; } } diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index fe4da9e1..ac7ac1b3 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -107,14 +107,14 @@ void TestCubicSurfaceExtractor::testBehaviour() // Test with default controller but user-provided mesh. auto uint32Vol = createAndFillVolumeWithNoise< SimpleVolume >(32, 0, 2); - CubicMesh< uint32_t, uint16_t > uint32Mesh; + Mesh< CubicVertex< 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< SimpleVolume >(32, 0, 2); - CubicMesh< int32_t, uint16_t > int32Mesh; + Mesh< CubicVertex< int32_t >, uint16_t > int32Mesh; extractCubicMeshCustom(int32Vol, int32Vol->getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded()); QCOMPARE(int32Mesh.getNoOfVertices(), uint16_t(29027)); QCOMPARE(int32Mesh.getNoOfIndices(), uint32_t(178356)); @@ -123,7 +123,7 @@ void TestCubicSurfaceExtractor::testBehaviour() void TestCubicSurfaceExtractor::testEmptyVolumePerformance() { auto emptyVol = createAndFillVolumeWithNoise< SimpleVolume >(128, 0, 0); - CubicMesh< uint32_t, uint16_t > emptyMesh; + Mesh< CubicVertex< uint32_t >, uint16_t > emptyMesh; QBENCHMARK{ extractCubicMeshCustom(emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); } QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0)); } @@ -131,7 +131,7 @@ void TestCubicSurfaceExtractor::testEmptyVolumePerformance() void TestCubicSurfaceExtractor::testNoiseVolumePerformance() { auto noiseVol = createAndFillVolumeWithNoise< SimpleVolume >(128, 0, 2); - CubicMesh< uint32_t, uint16_t > noiseMesh; + Mesh< CubicVertex< uint32_t >, uint16_t > noiseMesh; QBENCHMARK{ extractCubicMeshCustom(noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); } QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(57729)); } diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index f1005ae5..95ebb299 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -182,9 +182,10 @@ void TestSurfaceExtractor::testBehaviour() 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, while stil using the default controller. + // 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. auto intVol = createAndFillVolume(); - MarchingCubesMesh< int8_t, uint16_t > intMesh; + Mesh< MarchingCubesVertex< 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 @@ -194,7 +195,7 @@ void TestSurfaceExtractor::testBehaviour() // This test makes use of a user-provided mesh and also a custom controller. auto doubleVol = createAndFillVolume(); CustomMarchingCubesController doubleCustomController; - MarchingCubesMesh< double, uint16_t > doubleMesh; + Mesh< MarchingCubesVertex< 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 @@ -213,7 +214,7 @@ void TestSurfaceExtractor::testBehaviour() void TestSurfaceExtractor::testEmptyVolumePerformance() { auto emptyVol = createAndFillVolumeWithNoise< SimpleVolume >(128, -2.0f, -1.0f); - MarchingCubesMesh< float, uint16_t > emptyMesh; + Mesh< MarchingCubesVertex< float >, uint16_t > emptyMesh; QBENCHMARK{ extractMarchingCubesMeshCustom(emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); } QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0)); } @@ -221,7 +222,7 @@ void TestSurfaceExtractor::testEmptyVolumePerformance() void TestSurfaceExtractor::testNoiseVolumePerformance() { auto noiseVol = createAndFillVolumeWithNoise< SimpleVolume >(128, -1.0f, 1.0f); - MarchingCubesMesh< float, uint16_t > noiseMesh; + Mesh< MarchingCubesVertex< float >, uint16_t > noiseMesh; QBENCHMARK{ extractMarchingCubesMeshCustom(noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); } QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(48967)); }