Replaced LargeVolume and SimpleVolume with PagedVolume in tests and examples.

This commit is contained in:
David Williams
2014-09-21 17:57:42 +02:00
parent f95cc6bfca
commit db2e62d2a8
17 changed files with 50 additions and 52 deletions

View File

@ -24,7 +24,7 @@ freely, subject to the following restrictions:
#include "TestAmbientOcclusionGenerator.h"
#include "PolyVoxCore/AmbientOcclusionCalculator.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/PagedVolume.h"
#include <QtTest>
@ -49,7 +49,7 @@ void TestAmbientOcclusionGenerator::testExecute()
const int32_t g_uVolumeSideLength = 64;
//Create empty volume
SimpleVolume<uint8_t> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(g_uVolumeSideLength-1, g_uVolumeSideLength-1, g_uVolumeSideLength-1)));
PagedVolume<uint8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
//Create two solid walls at opposite sides of the volume
for (int32_t z = 0; z < g_uVolumeSideLength; z++)

View File

@ -27,7 +27,7 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/Material.h"
#include "PolyVoxCore/MaterialDensityPair.h"
#include "PolyVoxCore/RawVolume.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/PagedVolume.h"
#include "PolyVoxCore/CubicSurfaceExtractor.h"
#include <QtTest>
@ -128,26 +128,26 @@ VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
void TestCubicSurfaceExtractor::testBehaviour()
{
// Test with default mesh and contoller types.
auto uint8Vol = createAndFillVolumeWithNoise< SimpleVolume<uint8_t> >(32, 0, 2);
auto uint8Vol = createAndFillVolumeWithNoise< PagedVolume<uint8_t> >(32, 0, 2);
auto uint8Mesh = extractCubicMesh(uint8Vol, uint8Vol->getEnclosingRegion());
QCOMPARE(uint8Mesh.getNoOfVertices(), uint32_t(57687));
QCOMPARE(uint8Mesh.getNoOfIndices(), uint32_t(216234));
// Test with default mesh type but user-provided controller.
auto int8Vol = createAndFillVolumeWithNoise< SimpleVolume<int8_t> >(32, 0, 2);
auto int8Vol = createAndFillVolumeWithNoise< PagedVolume<int8_t> >(32, 0, 2);
auto int8Mesh = extractCubicMesh(int8Vol, int8Vol->getEnclosingRegion(), CustomIsQuadNeeded<int8_t>());
QCOMPARE(int8Mesh.getNoOfVertices(), uint32_t(29027));
QCOMPARE(int8Mesh.getNoOfIndices(), uint32_t(178356));
// Test with default controller but user-provided mesh.
auto uint32Vol = createAndFillVolumeWithNoise< SimpleVolume<uint32_t> >(32, 0, 2);
auto uint32Vol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(32, 0, 2);
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<int32_t> >(32, 0, 2);
auto int32Vol = createAndFillVolumeWithNoise< PagedVolume<int32_t> >(32, 0, 2);
Mesh< CubicVertex< int32_t >, uint16_t > int32Mesh;
extractCubicMeshCustom(int32Vol, int32Vol->getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded<int32_t>());
QCOMPARE(int32Mesh.getNoOfVertices(), uint16_t(29027));
@ -156,7 +156,7 @@ void TestCubicSurfaceExtractor::testBehaviour()
void TestCubicSurfaceExtractor::testEmptyVolumePerformance()
{
auto emptyVol = createAndFillVolumeWithNoise< SimpleVolume<uint32_t> >(128, 0, 0);
auto emptyVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 0);
Mesh< CubicVertex< uint32_t >, uint16_t > emptyMesh;
QBENCHMARK{ extractCubicMeshCustom(emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); }
QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0));
@ -164,7 +164,7 @@ void TestCubicSurfaceExtractor::testEmptyVolumePerformance()
void TestCubicSurfaceExtractor::testRealisticVolumePerformance()
{
auto realisticVol = createAndFillVolumeRealistic< SimpleVolume<uint32_t> >(128);
auto realisticVol = createAndFillVolumeRealistic< PagedVolume<uint32_t> >(128);
Mesh< CubicVertex< uint32_t >, uint16_t > realisticMesh;
QBENCHMARK{ extractCubicMeshCustom(realisticVol, Region(32, 32, 32, 63, 63, 63), &realisticMesh); }
QCOMPARE(realisticMesh.getNoOfVertices(), uint16_t(2176));
@ -172,7 +172,7 @@ void TestCubicSurfaceExtractor::testRealisticVolumePerformance()
void TestCubicSurfaceExtractor::testNoiseVolumePerformance()
{
auto noiseVol = createAndFillVolumeWithNoise< SimpleVolume<uint32_t> >(128, 0, 2);
auto noiseVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 2);
Mesh< CubicVertex< uint32_t >, uint16_t > noiseMesh;
QBENCHMARK{ extractCubicMeshCustom(noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); }
QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(57729));

View File

@ -24,7 +24,7 @@ freely, subject to the following restrictions:
#include "TestPicking.h"
#include "PolyVoxCore/Picking.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/PagedVolume.h"
#include <QtTest>
@ -34,7 +34,7 @@ void TestPicking::testExecute()
{
const int32_t uVolumeSideLength = 32;
SimpleVolume<int8_t> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(uVolumeSideLength-1, uVolumeSideLength-1, uVolumeSideLength-1)));
PagedVolume<int8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)));
for (int32_t z = 0; z < uVolumeSideLength; z++)
{
for (int32_t y = 0; y < uVolumeSideLength; y++)

View File

@ -25,7 +25,7 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/Density.h"
#include "PolyVoxCore/Raycast.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/PagedVolume.h"
#include "PolyVoxCore/Impl/RandomUnitVectors.h"
@ -47,7 +47,7 @@ public:
{
}
bool operator()(const SimpleVolume<int8_t>::Sampler& sampler)
bool operator()(const PagedVolume<int8_t>::Sampler& sampler)
{
m_uVoxelsTouched++;
@ -73,7 +73,7 @@ void TestRaycast::testExecute()
const int32_t uVolumeSideLength = 32;
//Create a hollow volume, with solid sides on x and y but with open ends in z.
SimpleVolume<int8_t> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(uVolumeSideLength-1, uVolumeSideLength-1, uVolumeSideLength-1)));
PagedVolume<int8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)));
for (int32_t z = 0; z < uVolumeSideLength; z++)
{
for (int32_t y = 0; y < uVolumeSideLength; y++)

View File

@ -27,8 +27,7 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/FilePager.h"
#include "PolyVoxCore/MaterialDensityPair.h"
#include "PolyVoxCore/RawVolume.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/LargeVolume.h"
#include "PolyVoxCore/PagedVolume.h"
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
#include <QtTest>
@ -173,7 +172,7 @@ void TestSurfaceExtractor::testBehaviour()
// Of course, the use of a custom controller will also make a significant diference, but this probably does need investigating further in the future.
// This basic test just uses the default controller and automatically generates a mesh of the appropriate type.
auto uintVol = createAndFillVolume< LargeVolume<uint8_t> >();
auto uintVol = createAndFillVolume< PagedVolume<uint8_t> >();
auto uintMesh = extractMarchingCubesMesh(uintVol, uintVol->getEnclosingRegion());
QCOMPARE(uintMesh.getNoOfVertices(), uint32_t(12096)); // Verifies size of mesh and that we have 32-bit indices
QCOMPARE(uintMesh.getNoOfIndices(), uint32_t(35157)); // Verifies size of mesh
@ -181,7 +180,7 @@ void TestSurfaceExtractor::testBehaviour()
QCOMPARE(uintMesh.getVertex(100).data, uint8_t(1)); // Not really meaningful for a primative type
// This test makes use of a custom controller
auto floatVol = createAndFillVolume< LargeVolume<float> >();
auto floatVol = createAndFillVolume< PagedVolume<float> >();
CustomMarchingCubesController floatCustomController;
auto floatMesh = extractMarchingCubesMesh(floatVol, floatVol->getEnclosingRegion(), floatCustomController);
QCOMPARE(floatMesh.getNoOfVertices(), uint32_t(16113)); // Verifies size of mesh and that we have 32-bit indices
@ -191,7 +190,7 @@ void TestSurfaceExtractor::testBehaviour()
// 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< LargeVolume<int8_t> >();
auto intVol = createAndFillVolume< PagedVolume<int8_t> >();
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
@ -200,7 +199,7 @@ void TestSurfaceExtractor::testBehaviour()
QCOMPARE(intMesh.getVertex(100).data, int8_t(1)); // Not really meaningful for a primative type
// This test makes use of a user-provided mesh and also a custom controller.
auto doubleVol = createAndFillVolume< LargeVolume<double> >();
auto doubleVol = createAndFillVolume< PagedVolume<double> >();
CustomMarchingCubesController doubleCustomController;
Mesh< MarchingCubesVertex< double >, uint16_t > doubleMesh;
extractMarchingCubesMeshCustom(doubleVol, doubleVol->getEnclosingRegion(), &doubleMesh, doubleCustomController);
@ -210,7 +209,7 @@ void TestSurfaceExtractor::testBehaviour()
QCOMPARE(doubleMesh.getVertex(100).data, double(1.0f)); // Not really meaningful for a primative type
// This test ensures the extractor works on a non-primitive voxel type.
auto materialVol = createAndFillVolume< LargeVolume<MaterialDensityPair88> >();
auto materialVol = createAndFillVolume< PagedVolume<MaterialDensityPair88> >();
auto materialMesh = extractMarchingCubesMesh(materialVol, materialVol->getEnclosingRegion());
QCOMPARE(materialMesh.getNoOfVertices(), uint32_t(12096)); // Verifies size of mesh and that we have 32-bit indices
QCOMPARE(materialMesh.getNoOfIndices(), uint32_t(35157)); // Verifies size of mesh
@ -220,7 +219,7 @@ void TestSurfaceExtractor::testBehaviour()
void TestSurfaceExtractor::testEmptyVolumePerformance()
{
auto emptyVol = createAndFillVolumeWithNoise< LargeVolume<float> >(128, -2.0f, -1.0f);
auto emptyVol = createAndFillVolumeWithNoise< PagedVolume<float> >(128, -2.0f, -1.0f);
Mesh< MarchingCubesVertex< float >, uint16_t > emptyMesh;
QBENCHMARK{ extractMarchingCubesMeshCustom(emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); }
QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0));
@ -228,7 +227,7 @@ void TestSurfaceExtractor::testEmptyVolumePerformance()
void TestSurfaceExtractor::testNoiseVolumePerformance()
{
auto noiseVol = createAndFillVolumeWithNoise< LargeVolume<float> >(128, -1.0f, 1.0f);
auto noiseVol = createAndFillVolumeWithNoise< PagedVolume<float> >(128, -1.0f, 1.0f);
Mesh< MarchingCubesVertex< float >, uint16_t > noiseMesh;
QBENCHMARK{ extractMarchingCubesMeshCustom(noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); }
QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(48967));

View File

@ -110,7 +110,7 @@ int32_t testSamplersWithWrappingForwards(VolumeType* volume, int lowXOffset, int
xSampler = ySampler;
for(int x = volume->getEnclosingRegion().getLowerX() + lowXOffset; x <= volume->getEnclosingRegion().getUpperX() + highXOffset; x++)
{
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the LargeVolume.
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the PagedVolume.
result = cantorTupleFunction(result, xSampler.peekVoxel1nx1ny1nz());
result = cantorTupleFunction(result, xSampler.peekVoxel0px1ny1nz());
@ -223,7 +223,7 @@ int32_t testSamplersWithWrappingBackwards(VolumeType* volume, int lowXOffset, in
xSampler = ySampler;
for(int x = volume->getEnclosingRegion().getUpperX() + highXOffset; x >= volume->getEnclosingRegion().getLowerX() + lowXOffset; x--)
{
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the LargeVolume.
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the PagedVolume.
result = cantorTupleFunction(result, xSampler.peekVoxel1nx1ny1nz());
result = cantorTupleFunction(result, xSampler.peekVoxel0px1ny1nz());
@ -273,7 +273,7 @@ TestVolume::TestVolume()
//Create the volumes
m_pRawVolume = new RawVolume<int32_t>(region);
m_pPagedVolume = new LargeVolume<int32_t>(region, m_pFilePager, 32);
m_pPagedVolume = new PagedVolume<int32_t>(region, m_pFilePager, 32);
m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024);