Merge branch 'develop' into feature/vertex-refactor

Conflicts:
	examples/Basic/main.cpp
	examples/Paging/main.cpp
	examples/SmoothLOD/main.cpp
	library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h
	tests/TestCubicSurfaceExtractor.cpp
	tests/TestSurfaceExtractor.cpp
	tests/TestVolumeSubclass.cpp
This commit is contained in:
David Williams
2014-05-12 23:04:19 +02:00
8 changed files with 106 additions and 86 deletions

View File

@ -102,7 +102,7 @@ void writeMaterialValueToVoxel(int valueToWrite, MaterialDensityPair88& voxel)
// Runs the surface extractor for a given type.
template <typename VoxelType>
void testForType(SurfaceMesh<MarchingCubesVertex<VoxelType> >& result)
SurfaceMesh<MarchingCubesVertex<VoxelType> > testForType(void) //I think we could avoid specifying this return type by using auto/decltype?
{
const int32_t uVolumeSideLength = 32;
@ -127,8 +127,10 @@ void testForType(SurfaceMesh<MarchingCubesVertex<VoxelType> >& result)
DefaultMarchingCubesController<VoxelType> controller;
controller.setThreshold(50);
MarchingCubesSurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, WrapModes::Border, VoxelType(), controller);
extractor.execute();
auto result = extractMarchingCubesSurface(&volData, volData.getEnclosingRegion(), WrapModes::Border, VoxelType(), controller);
return result;
}
void testCustomController(SurfaceMesh<MarchingCubesVertex<float> >& result)
@ -163,74 +165,65 @@ void TestSurfaceExtractor::testExecute()
const static float fExpectedMaterial = 42.0f;
const static float fNoMaterial = 1.0f;
SurfaceMesh<MarchingCubesVertex<int8_t> > int8Mesh;
SurfaceMesh<MarchingCubesVertex<int8_t> > mesh;
//Run the test for various voxel types.
QBENCHMARK {
testForType<int8_t>(int8Mesh);
mesh = testForType<int8_t>();
}
QCOMPARE(int8Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(int8Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(int8Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int8_t>(fNoMaterial));
QCOMPARE(mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int8_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<uint8_t> > uint8Mesh;
testForType<uint8_t>(uint8Mesh);
QCOMPARE(uint8Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(uint8Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(uint8Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint8_t>(fNoMaterial));
auto mesh1 = testForType<uint8_t>();
QCOMPARE(mesh1.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh1.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh1.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint8_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<int16_t> > int16Mesh;
testForType<int16_t>(int16Mesh);
QCOMPARE(int16Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(int16Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(int16Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int16_t>(fNoMaterial));
auto mesh2 = testForType<int16_t>();
QCOMPARE(mesh2.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh2.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh2.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int16_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<uint16_t> > uint16Mesh;
testForType<uint16_t>(uint16Mesh);
QCOMPARE(uint16Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(uint16Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(uint16Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint16_t>(fNoMaterial));
auto mesh3 = testForType<uint16_t>();
QCOMPARE(mesh3.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh3.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh3.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint16_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<int32_t> > int32Mesh;
testForType<int32_t>(int32Mesh);
QCOMPARE(int32Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(int32Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(int32Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int32_t>(fNoMaterial));
auto mesh4 = testForType<int32_t>();
QCOMPARE(mesh4.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh4.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh4.getVertices()[uMaterialToCheck].getMaterial(), static_cast<int32_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<uint32_t> > uint32Mesh;
testForType<uint32_t>(uint32Mesh);
QCOMPARE(uint32Mesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(uint32Mesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(uint32Mesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint32_t>(fNoMaterial));
auto mesh5 = testForType<uint32_t>();
QCOMPARE(mesh5.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh5.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh5.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint32_t>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<float> > floatMesh;
testForType<float>(floatMesh);
QCOMPARE(floatMesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(floatMesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(floatMesh.getVertices()[uMaterialToCheck].getMaterial(), fNoMaterial);
auto mesh6 = testForType<float>();
QCOMPARE(mesh6.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh6.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh6.getVertices()[uMaterialToCheck].getMaterial(), static_cast<float>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<double> > doubleMesh;
testForType<double>(doubleMesh);
QCOMPARE(doubleMesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(doubleMesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(doubleMesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<double>(fNoMaterial));
auto mesh7 = testForType<double>();
QCOMPARE(mesh7.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh7.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh7.getVertices()[uMaterialToCheck].getMaterial(), static_cast<double>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<Density8> > densityMesh;
testForType<Density8>(densityMesh);
QCOMPARE(densityMesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(densityMesh.getNoOfIndices(), uExpectedIndices);
//QCOMPARE(densityMesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint8_t>(fNoMaterial));
auto mesh8 = testForType<Density8>();
QCOMPARE(mesh8.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh8.getNoOfIndices(), uExpectedIndices);
QCOMPARE(mesh8.getVertices()[uMaterialToCheck].getMaterial(), static_cast<Density8>(fNoMaterial));
SurfaceMesh<MarchingCubesVertex<MaterialDensityPair88> > materialDensityMesh;
testForType<MaterialDensityPair88>(materialDensityMesh);
QCOMPARE(materialDensityMesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(materialDensityMesh.getNoOfIndices(), uExpectedIndices);
//QCOMPARE(materialDensityMesh.getVertices()[uMaterialToCheck].getMaterial(), static_cast<uint8_t>(fNoMaterial));
auto mesh9 = testForType<MaterialDensityPair88>();
QCOMPARE(mesh9.getNoOfVertices(), uExpectedVertices);
QCOMPARE(mesh9.getNoOfIndices(), uExpectedIndices);
//QCOMPARE(mesh9.getVertices()[uMaterialToCheck].getMaterial(), fExpectedMaterial);
//Test whether the CustomSurfaceExtractor works.
testCustomController(floatMesh);
/*testCustomController(floatMesh);
QCOMPARE(floatMesh.getNoOfVertices(), uExpectedVertices);
QCOMPARE(floatMesh.getNoOfIndices(), uExpectedIndices);
QCOMPARE(floatMesh.getVertices()[uMaterialToCheck].getMaterial(), fNoMaterial);
QCOMPARE(floatMesh.getVertices()[uMaterialToCheck].getMaterial(), fNoMaterial);*/
}
QTEST_MAIN(TestSurfaceExtractor)