Merge branch 'feature/remove-wrap-modes' into develop
This commit is contained in:
@ -40,7 +40,7 @@ bool testVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos)
|
||||
return false;
|
||||
}
|
||||
|
||||
typename VolumeType::VoxelType voxel = volData->getVoxel(v3dPos, WrapModes::Validate); // FIXME use templatised version of getVoxel(), but watch out for Linux compile issues.
|
||||
typename VolumeType::VoxelType voxel = volData->getVoxel(v3dPos);
|
||||
if(voxel != 0)
|
||||
{
|
||||
return false;
|
||||
@ -92,7 +92,7 @@ void TestAStarPathfinder::testExecute()
|
||||
for(int x = 0; x < uVolumeSideLength; x++)
|
||||
{
|
||||
uint8_t solidVoxel(0);
|
||||
volData.setVoxelAt(x,y,z,solidVoxel);
|
||||
volData.setVoxel(x,y,z,solidVoxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ void TestAStarPathfinder::testExecute()
|
||||
for(int x = 4; x < 12; x++)
|
||||
{
|
||||
uint8_t solidVoxel(1);
|
||||
volData.setVoxelAt(x,y,z,solidVoxel);
|
||||
volData.setVoxel(x,y,z,solidVoxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
||||
#include "TestAmbientOcclusionGenerator.h"
|
||||
|
||||
#include "PolyVox/AmbientOcclusionCalculator.h"
|
||||
#include "PolyVox/PagedVolume.h"
|
||||
#include "PolyVox/RawVolume.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
@ -49,7 +49,7 @@ void TestAmbientOcclusionGenerator::testExecute()
|
||||
const int32_t g_uVolumeSideLength = 64;
|
||||
|
||||
//Create empty volume
|
||||
PagedVolume<uint8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
|
||||
RawVolume<uint8_t> volData(Region(0, 0, 0, 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++)
|
||||
@ -60,7 +60,7 @@ void TestAmbientOcclusionGenerator::testExecute()
|
||||
{
|
||||
for (int32_t x = 0; x < g_uVolumeSideLength; x++)
|
||||
{
|
||||
volData.setVoxelAt(x, y, z, 1);
|
||||
volData.setVoxel(x, y, z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ freely, subject to the following restrictions:
|
||||
#include "TestCubicSurfaceExtractor.h"
|
||||
|
||||
#include "PolyVox/Density.h"
|
||||
#include "PolyVox/FilePager.h"
|
||||
#include "PolyVox/Material.h"
|
||||
#include "PolyVox/MaterialDensityPair.h"
|
||||
#include "PolyVox/RawVolume.h"
|
||||
@ -60,11 +61,8 @@ public:
|
||||
|
||||
// Runs the surface extractor for a given type.
|
||||
template <typename VolumeType>
|
||||
VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename VolumeType::VoxelType minValue, typename VolumeType::VoxelType maxValue)
|
||||
void createAndFillVolumeWithNoise(VolumeType& volData, int32_t iVolumeSideLength, typename VolumeType::VoxelType minValue, typename VolumeType::VoxelType maxValue)
|
||||
{
|
||||
//Create empty volume
|
||||
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)));
|
||||
|
||||
// Set up a random number generator
|
||||
std::mt19937 rng;
|
||||
|
||||
@ -78,7 +76,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol
|
||||
if (minValue == maxValue)
|
||||
{
|
||||
// In this case we are filling the whole volume with a single value.
|
||||
volData->setVoxelAt(x, y, z, minValue);
|
||||
volData.setVoxel(x, y, z, minValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,13 +84,11 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol
|
||||
// We can't use std distributions because they vary between platforms (breaking tests).
|
||||
int voxelValue = (rng() % (maxValue - minValue + 1)) + minValue; // +1 for inclusive bounds
|
||||
|
||||
volData->setVoxelAt(x, y, z, static_cast<typename VolumeType::VoxelType>(voxelValue));
|
||||
volData.setVoxel(x, y, z, static_cast<typename VolumeType::VoxelType>(voxelValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return volData;
|
||||
}
|
||||
|
||||
// Runs the surface extractor for a given type.
|
||||
@ -100,7 +96,8 @@ template <typename VolumeType>
|
||||
VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
||||
{
|
||||
//Create empty volume
|
||||
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)));
|
||||
FilePager<uint32_t>* filePager = new FilePager<uint32_t>();
|
||||
VolumeType* volData = new VolumeType(filePager);
|
||||
|
||||
//Fill the volume with data
|
||||
for (int32_t z = 0; z < iVolumeSideLength; z++)
|
||||
@ -113,11 +110,11 @@ VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
||||
// that it's not empty/random data, and should allow significant decimation to be performed.
|
||||
if ((x ^ y) & 0x01)
|
||||
{
|
||||
volData->setVoxelAt(x, y, z, 0);
|
||||
volData->setVoxel(x, y, z, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
volData->setVoxelAt(x, y, z, 1);
|
||||
volData->setVoxel(x, y, z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,38 +125,46 @@ VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
||||
|
||||
void TestCubicSurfaceExtractor::testBehaviour()
|
||||
{
|
||||
int32_t iVolumeSideLength = 32;
|
||||
|
||||
// Test with default mesh and contoller types.
|
||||
auto uint8Vol = createAndFillVolumeWithNoise< PagedVolume<uint8_t> >(32, 0, 2);
|
||||
auto uint8Mesh = extractCubicMesh(uint8Vol, uint8Vol->getEnclosingRegion());
|
||||
RawVolume<uint8_t> uint8Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||
createAndFillVolumeWithNoise(uint8Vol, 32, 0, 2);
|
||||
auto uint8Mesh = extractCubicMesh(&uint8Vol, uint8Vol.getEnclosingRegion());
|
||||
QCOMPARE(uint8Mesh.getNoOfVertices(), uint32_t(57544));
|
||||
QCOMPARE(uint8Mesh.getNoOfIndices(), uint32_t(215304));
|
||||
|
||||
// Test with default mesh type but user-provided controller.
|
||||
auto int8Vol = createAndFillVolumeWithNoise< PagedVolume<int8_t> >(32, 0, 2);
|
||||
auto int8Mesh = extractCubicMesh(int8Vol, int8Vol->getEnclosingRegion(), CustomIsQuadNeeded<int8_t>());
|
||||
RawVolume<int8_t> int8Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||
createAndFillVolumeWithNoise(int8Vol, 32, 0, 2);
|
||||
auto int8Mesh = extractCubicMesh(&int8Vol, int8Vol.getEnclosingRegion(), CustomIsQuadNeeded<int8_t>());
|
||||
QCOMPARE(int8Mesh.getNoOfVertices(), uint32_t(29106));
|
||||
QCOMPARE(int8Mesh.getNoOfIndices(), uint32_t(178566));
|
||||
|
||||
// Test with default controller but user-provided mesh.
|
||||
auto uint32Vol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(32, 0, 2);
|
||||
RawVolume<uint32_t> uint32Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||
createAndFillVolumeWithNoise(uint32Vol, 32, 0, 2);
|
||||
Mesh< CubicVertex< uint32_t >, uint16_t > uint32Mesh;
|
||||
extractCubicMeshCustom(uint32Vol, uint32Vol->getEnclosingRegion(), &uint32Mesh);
|
||||
extractCubicMeshCustom(&uint32Vol, uint32Vol.getEnclosingRegion(), &uint32Mesh);
|
||||
QCOMPARE(uint32Mesh.getNoOfVertices(), uint16_t(57544));
|
||||
QCOMPARE(uint32Mesh.getNoOfIndices(), uint32_t(215304));
|
||||
|
||||
// Test with both mesh and controller being provided by the user.
|
||||
auto int32Vol = createAndFillVolumeWithNoise< PagedVolume<int32_t> >(32, 0, 2);
|
||||
RawVolume<int32_t> int32Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||
createAndFillVolumeWithNoise(int32Vol, 32, 0, 2);
|
||||
Mesh< CubicVertex< int32_t >, uint16_t > int32Mesh;
|
||||
extractCubicMeshCustom(int32Vol, int32Vol->getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded<int32_t>());
|
||||
extractCubicMeshCustom(&int32Vol, int32Vol.getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded<int32_t>());
|
||||
QCOMPARE(int32Mesh.getNoOfVertices(), uint16_t(29106));
|
||||
QCOMPARE(int32Mesh.getNoOfIndices(), uint32_t(178566));
|
||||
}
|
||||
|
||||
void TestCubicSurfaceExtractor::testEmptyVolumePerformance()
|
||||
{
|
||||
auto emptyVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 0);
|
||||
FilePager<uint32_t>* filePager = new FilePager<uint32_t>();
|
||||
PagedVolume<uint32_t> emptyVol(filePager);
|
||||
createAndFillVolumeWithNoise(emptyVol, 128, 0, 0);
|
||||
Mesh< CubicVertex< uint32_t >, uint16_t > emptyMesh;
|
||||
QBENCHMARK{ extractCubicMeshCustom(emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); }
|
||||
QBENCHMARK{ extractCubicMeshCustom(&emptyVol, Region(32, 32, 32, 63, 63, 63), &emptyMesh); }
|
||||
QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0));
|
||||
}
|
||||
|
||||
@ -173,9 +178,11 @@ void TestCubicSurfaceExtractor::testRealisticVolumePerformance()
|
||||
|
||||
void TestCubicSurfaceExtractor::testNoiseVolumePerformance()
|
||||
{
|
||||
auto noiseVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 2);
|
||||
FilePager<uint32_t>* filePager = new FilePager<uint32_t>();
|
||||
PagedVolume<uint32_t> noiseVol(filePager);
|
||||
createAndFillVolumeWithNoise(noiseVol, 128, 0, 2);
|
||||
Mesh< CubicVertex< uint32_t >, uint16_t > noiseMesh;
|
||||
QBENCHMARK{ extractCubicMeshCustom(noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); }
|
||||
QBENCHMARK{ extractCubicMeshCustom(&noiseVol, Region(32, 32, 32, 63, 63, 63), &noiseMesh); }
|
||||
QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(57905));
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ void TestLowPassFilter::testExecute()
|
||||
if(x % 2 == 0)
|
||||
{
|
||||
Density8 voxel(32);
|
||||
volData.setVoxelAt(x, y, z, voxel);
|
||||
volData.setVoxel(x, y, z, voxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
||||
#include "TestPicking.h"
|
||||
|
||||
#include "PolyVox/Picking.h"
|
||||
#include "PolyVox/PagedVolume.h"
|
||||
#include "PolyVox/RawVolume.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
@ -34,7 +34,7 @@ void TestPicking::testExecute()
|
||||
{
|
||||
const int32_t uVolumeSideLength = 32;
|
||||
|
||||
PagedVolume<int8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)));
|
||||
RawVolume<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++)
|
||||
@ -43,11 +43,11 @@ void TestPicking::testExecute()
|
||||
{
|
||||
if((x > uVolumeSideLength/2)) //x > 16 is filled
|
||||
{
|
||||
volData.setVoxelAt(x, y, z, 100);
|
||||
volData.setVoxel(x, y, z, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
volData.setVoxelAt(x, y, z, 0);
|
||||
volData.setVoxel(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVox/Density.h"
|
||||
#include "PolyVox/Raycast.h"
|
||||
#include "PolyVox/PagedVolume.h"
|
||||
#include "PolyVox/RawVolume.h"
|
||||
|
||||
#include "PolyVox/Impl/RandomUnitVectors.h"
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const PagedVolume<int8_t>::Sampler& sampler)
|
||||
bool operator()(const RawVolume<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.
|
||||
PagedVolume<int8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)));
|
||||
RawVolume<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++)
|
||||
@ -82,11 +82,11 @@ void TestRaycast::testExecute()
|
||||
{
|
||||
if((x == 0) || (x == uVolumeSideLength-1) || (y == 0) || (y == uVolumeSideLength-1))
|
||||
{
|
||||
volData.setVoxelAt(x, y, z, 100);
|
||||
volData.setVoxel(x, y, z, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
volData.setVoxelAt(x, y, z, -100);
|
||||
volData.setVoxel(x, y, z, -100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,10 +103,8 @@ VolumeType* createAndFillVolume(void)
|
||||
{
|
||||
const int32_t uVolumeSideLength = 64;
|
||||
|
||||
FilePager<typename VolumeType::VoxelType>* pager = new FilePager<typename VolumeType::VoxelType>(".");
|
||||
|
||||
//Create empty volume
|
||||
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)), pager);
|
||||
VolumeType* volData = new VolumeType(Region(0, 0, 0, uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1));
|
||||
|
||||
// Fill
|
||||
for (int32_t z = 0; z < uVolumeSideLength; z++)
|
||||
@ -120,7 +118,7 @@ VolumeType* createAndFillVolume(void)
|
||||
typename VolumeType::VoxelType voxelValue;
|
||||
writeDensityValueToVoxel<typename VolumeType::VoxelType>(x + y + z, voxelValue);
|
||||
writeMaterialValueToVoxel<typename VolumeType::VoxelType>(z > uVolumeSideLength / 2 ? 42 : 79, voxelValue);
|
||||
volData->setVoxelAt(x, y, z, voxelValue);
|
||||
volData->setVoxel(x, y, z, voxelValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,7 +132,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minVal
|
||||
FilePager<float>* pager = new FilePager<float>(".");
|
||||
|
||||
//Create empty volume
|
||||
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)), pager);
|
||||
VolumeType* volData = new VolumeType(pager);
|
||||
|
||||
// Set up a random number generator
|
||||
std::mt19937 rng;
|
||||
@ -150,7 +148,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minVal
|
||||
float voxelValue = static_cast<float>(rng()) / static_cast<float>(std::numeric_limits<int32_t>::max()); // Float in range 0.0 to 1.0
|
||||
voxelValue = voxelValue * (maxValue - minValue) + minValue; // Float in range minValue to maxValue
|
||||
|
||||
volData->setVoxelAt(x, y, z, voxelValue);
|
||||
volData->setVoxel(x, y, z, voxelValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +166,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< PagedVolume<uint8_t> >();
|
||||
auto uintVol = createAndFillVolume< RawVolume<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
|
||||
@ -176,7 +174,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< PagedVolume<float> >();
|
||||
auto floatVol = createAndFillVolume< RawVolume<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
|
||||
@ -186,7 +184,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< PagedVolume<int8_t> >();
|
||||
auto intVol = createAndFillVolume< RawVolume<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
|
||||
@ -195,7 +193,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< PagedVolume<double> >();
|
||||
auto doubleVol = createAndFillVolume< RawVolume<double> >();
|
||||
CustomMarchingCubesController doubleCustomController;
|
||||
Mesh< MarchingCubesVertex< double >, uint16_t > doubleMesh;
|
||||
extractMarchingCubesMeshCustom(doubleVol, doubleVol->getEnclosingRegion(), &doubleMesh, doubleCustomController);
|
||||
@ -205,7 +203,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< PagedVolume<MaterialDensityPair88> >();
|
||||
auto materialVol = createAndFillVolume< RawVolume<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
|
||||
|
@ -62,8 +62,8 @@ public:
|
||||
|
||||
/// Constructor for creating a fixed size volume.
|
||||
VolumeSubclass(const Region& regValid)
|
||||
:BaseVolume<VoxelType>(regValid)
|
||||
, mVolumeData(this->getWidth(), this->getHeight(), this->getDepth())
|
||||
:BaseVolume<VoxelType>()
|
||||
, mVolumeData(regValid.getWidthInVoxels(), regValid.getHeightInVoxels(), regValid.getDepthInVoxels())
|
||||
{
|
||||
//mVolumeData.resize(ArraySizes(this->getWidth())(this->getHeight())(this->getDepth()));
|
||||
}
|
||||
@ -71,83 +71,30 @@ public:
|
||||
~VolumeSubclass() {};
|
||||
|
||||
/// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||
template <WrapMode eWrapMode>
|
||||
VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tBorder = VoxelType()) const
|
||||
VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
|
||||
{
|
||||
// FIXME: This templatised version is implemented in terms of the not template version. This is strange
|
||||
// from a peformance point of view but it's just because we were encountering some compile issues on GCC.
|
||||
return getVoxel(uXPos, uYPos, uZPos, eWrapMode, tBorder);
|
||||
}
|
||||
|
||||
/// Gets a voxel at the position given by a 3D vector
|
||||
template <WrapMode eWrapMode>
|
||||
VoxelType getVoxel(const Vector3DInt32& v3dPos, VoxelType tBorder = VoxelType()) const
|
||||
{
|
||||
// Simply call through to the real implementation
|
||||
return getVoxel<eWrapMode>(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tBorder);
|
||||
}
|
||||
|
||||
/// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||
VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const
|
||||
{
|
||||
switch(eWrapMode)
|
||||
if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2)))
|
||||
{
|
||||
case WrapModes::Validate:
|
||||
{
|
||||
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false)
|
||||
{
|
||||
POLYVOX_THROW(std::out_of_range, "Position is outside valid region");
|
||||
}
|
||||
|
||||
return mVolumeData(uXPos, uYPos, uZPos);
|
||||
}
|
||||
case WrapModes::Clamp:
|
||||
{
|
||||
//Perform clamping
|
||||
uXPos = (std::max)(uXPos, this->m_regValidRegion.getLowerX());
|
||||
uYPos = (std::max)(uYPos, this->m_regValidRegion.getLowerY());
|
||||
uZPos = (std::max)(uZPos, this->m_regValidRegion.getLowerZ());
|
||||
uXPos = (std::min)(uXPos, this->m_regValidRegion.getUpperX());
|
||||
uYPos = (std::min)(uYPos, this->m_regValidRegion.getUpperY());
|
||||
uZPos = (std::min)(uZPos, this->m_regValidRegion.getUpperZ());
|
||||
return mVolumeData(uXPos, uYPos, uZPos);
|
||||
}
|
||||
case WrapModes::Border:
|
||||
{
|
||||
if(this->m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
|
||||
{
|
||||
return mVolumeData(uXPos, uYPos, uZPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tBorder;
|
||||
}
|
||||
}
|
||||
case WrapModes::AssumeValid:
|
||||
{
|
||||
return mVolumeData(uXPos, uYPos, uZPos);
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Should never happen
|
||||
POLYVOX_ASSERT(false, "Invalid wrap mode");
|
||||
return VoxelType();
|
||||
}
|
||||
return mVolumeData(uXPos, uYPos, uZPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return VoxelType();
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a voxel at the position given by a 3D vector
|
||||
VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const
|
||||
VoxelType getVoxel(const Vector3DInt32& v3dPos) const
|
||||
{
|
||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
|
||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||
}
|
||||
|
||||
/// Sets the value used for voxels which are outside the volume
|
||||
void setBorderValue(const VoxelType& tBorder) { }
|
||||
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
|
||||
bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
|
||||
{
|
||||
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)))
|
||||
if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2)))
|
||||
{
|
||||
mVolumeData(uXPos, uYPos, uZPos) = tValue;
|
||||
return true;
|
||||
@ -158,7 +105,7 @@ public:
|
||||
}
|
||||
}
|
||||
/// Sets the voxel at the position given by a 3D vector
|
||||
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) { return setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); }
|
||||
bool setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue) { return setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); }
|
||||
|
||||
/// Calculates approximatly how many bytes of memory the volume is currently using.
|
||||
uint32_t calculateSizeInBytes(void) { return 0; }
|
||||
@ -172,21 +119,22 @@ private:
|
||||
|
||||
void TestVolumeSubclass::testExtractSurface()
|
||||
{
|
||||
VolumeSubclass<Material8> volumeSubclass(Region(0,0,0,16,16,16));
|
||||
Region region(0, 0, 0, 16, 16, 16);
|
||||
VolumeSubclass<Material8> volumeSubclass(region);
|
||||
|
||||
for(int32_t z = 0; z < volumeSubclass.getDepth() / 2; z++)
|
||||
for (int32_t z = 0; z < region.getDepthInVoxels() / 2; z++)
|
||||
{
|
||||
for(int32_t y = 0; y < volumeSubclass.getHeight(); y++)
|
||||
for (int32_t y = 0; y < region.getHeightInVoxels(); y++)
|
||||
{
|
||||
for(int32_t x = 0; x < volumeSubclass.getWidth(); x++)
|
||||
for (int32_t x = 0; x < region.getWidthInVoxels(); x++)
|
||||
{
|
||||
Material8 mat(1);
|
||||
volumeSubclass.setVoxelAt(Vector3DInt32(x,y,z),mat);
|
||||
volumeSubclass.setVoxel(Vector3DInt32(x,y,z),mat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto result = extractCubicMesh(&volumeSubclass, volumeSubclass.getEnclosingRegion());
|
||||
auto result = extractCubicMesh(&volumeSubclass, region);
|
||||
|
||||
QCOMPARE(result.getNoOfVertices(), static_cast<uint32_t>(8));
|
||||
}
|
||||
|
@ -46,18 +46,15 @@ inline int32_t cantorTupleFunction(int32_t previousResult, int32_t value)
|
||||
// We allow user provided offset in this function so we can test the case when all samples are inside a volume and also the case when some samples are outside.
|
||||
// This is important because samplers are often slower when outside the volume as they have to fall back on directly accessing the volume data.
|
||||
template <typename VolumeType>
|
||||
int32_t testDirectAccessWithWrappingForwards(const VolumeType* volume, int lowXOffset, int lowYOffset, int lowZOffset, int highXOffset, int highYOffset, int highZOffset)
|
||||
int32_t testDirectAccessWithWrappingForwards(const VolumeType* volume, Region region)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
// If we know that we are only iterating over voxels internal to the volume then we can avoid calling the 'wrapping' function. This should be faster.
|
||||
bool bAllVoxelsInternal = (lowXOffset > 0) && (lowYOffset > 0) && (lowZOffset > 0) && (highXOffset < 0) && (highYOffset < 0) && (highZOffset < 0);
|
||||
|
||||
for(int z = volume->getEnclosingRegion().getLowerZ() + lowZOffset; z <= volume->getEnclosingRegion().getUpperZ() + highZOffset; z++)
|
||||
for (int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
|
||||
{
|
||||
for(int y = volume->getEnclosingRegion().getLowerY() + lowYOffset; y <= volume->getEnclosingRegion().getUpperY() + highYOffset; y++)
|
||||
for (int y = region.getLowerY(); y <= region.getUpperY(); y++)
|
||||
{
|
||||
for(int x = volume->getEnclosingRegion().getLowerX() + lowXOffset; x <= volume->getEnclosingRegion().getUpperX() + highXOffset; x++)
|
||||
for (int x = region.getLowerX(); x <= region.getUpperX(); x++)
|
||||
{
|
||||
//Three level loop now processes 27 voxel neighbourhood
|
||||
for(int innerZ = -1; innerZ <=1; innerZ++)
|
||||
@ -66,16 +63,7 @@ int32_t testDirectAccessWithWrappingForwards(const VolumeType* volume, int lowXO
|
||||
{
|
||||
for(int innerX = -1; innerX <=1; innerX++)
|
||||
{
|
||||
// Deeply nested 'if', but this is just a unit test and we should still
|
||||
// see some performance improvement by skipping the wrapping versions.
|
||||
if(bAllVoxelsInternal)
|
||||
{
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ, WrapModes::Border, 3));
|
||||
}
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +76,7 @@ int32_t testDirectAccessWithWrappingForwards(const VolumeType* volume, int lowXO
|
||||
}
|
||||
|
||||
template <typename VolumeType>
|
||||
int32_t testSamplersWithWrappingForwards(VolumeType* volume, int lowXOffset, int lowYOffset, int lowZOffset, int highXOffset, int highYOffset, int highZOffset)
|
||||
int32_t testSamplersWithWrappingForwards(VolumeType* volume, Region region)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
@ -97,18 +85,14 @@ int32_t testSamplersWithWrappingForwards(VolumeType* volume, int lowXOffset, int
|
||||
typename VolumeType::Sampler ySampler(volume);
|
||||
typename VolumeType::Sampler zSampler(volume);
|
||||
|
||||
xSampler.setWrapMode(WrapModes::Border, 3);
|
||||
ySampler.setWrapMode(WrapModes::Border, 3);
|
||||
zSampler.setWrapMode(WrapModes::Border, 3);
|
||||
|
||||
zSampler.setPosition(volume->getEnclosingRegion().getLowerX() + lowXOffset, volume->getEnclosingRegion().getLowerY() + lowYOffset, volume->getEnclosingRegion().getLowerZ() + lowZOffset);
|
||||
for(int z = volume->getEnclosingRegion().getLowerZ() + lowZOffset; z <= volume->getEnclosingRegion().getUpperZ() + highZOffset; z++)
|
||||
zSampler.setPosition(region.getLowerX(), region.getLowerY(), region.getLowerZ());
|
||||
for (int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
|
||||
{
|
||||
ySampler = zSampler;
|
||||
for(int y = volume->getEnclosingRegion().getLowerY() + lowYOffset; y <= volume->getEnclosingRegion().getUpperY() + highYOffset; y++)
|
||||
for (int y = region.getLowerY(); y <= region.getUpperY(); y++)
|
||||
{
|
||||
xSampler = ySampler;
|
||||
for(int x = volume->getEnclosingRegion().getLowerX() + lowXOffset; x <= volume->getEnclosingRegion().getUpperX() + highXOffset; x++)
|
||||
for (int x = region.getLowerX(); x <= region.getUpperX(); x++)
|
||||
{
|
||||
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the PagedVolume.
|
||||
|
||||
@ -159,18 +143,15 @@ int32_t testSamplersWithWrappingForwards(VolumeType* volume, int lowXOffset, int
|
||||
// We allow user provided offset in this function so we can test the case when all samples are inside a volume and also the case when some samples are outside.
|
||||
// This is important because samplers are often slower when outside the volume as they have to fall back on directly accessing the volume data.
|
||||
template <typename VolumeType>
|
||||
int32_t testDirectAccessWithWrappingBackwards(const VolumeType* volume, int lowXOffset, int lowYOffset, int lowZOffset, int highXOffset, int highYOffset, int highZOffset)
|
||||
int32_t testDirectAccessWithWrappingBackwards(const VolumeType* volume, Region region)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
// If we know that we are only iterating over voxels internal to the volume then we can avoid calling the 'wrapping' function. This should be faster.
|
||||
bool bAllVoxelsInternal = (lowXOffset > 0) && (lowYOffset > 0) && (lowZOffset > 0) && (highXOffset < 0) && (highYOffset < 0) && (highZOffset < 0);
|
||||
|
||||
for(int z = volume->getEnclosingRegion().getUpperZ() + highZOffset; z >= volume->getEnclosingRegion().getLowerZ() + lowZOffset; z--)
|
||||
for (int z = region.getUpperZ(); z >= region.getLowerZ(); z--)
|
||||
{
|
||||
for(int y = volume->getEnclosingRegion().getUpperY() + highYOffset; y >= volume->getEnclosingRegion().getLowerY() + lowYOffset; y--)
|
||||
for (int y = region.getUpperY(); y >= region.getLowerY(); y--)
|
||||
{
|
||||
for(int x = volume->getEnclosingRegion().getUpperX() + highXOffset; x >= volume->getEnclosingRegion().getLowerX() + lowXOffset; x--)
|
||||
for (int x = region.getUpperX(); x >= region.getLowerX(); x--)
|
||||
{
|
||||
//Three level loop now processes 27 voxel neighbourhood
|
||||
for(int innerZ = -1; innerZ <=1; innerZ++)
|
||||
@ -179,16 +160,7 @@ int32_t testDirectAccessWithWrappingBackwards(const VolumeType* volume, int lowX
|
||||
{
|
||||
for(int innerX = -1; innerX <=1; innerX++)
|
||||
{
|
||||
// Deeply nested 'if', but this is just a unit test and we should still
|
||||
// see some performance improvement by skipping the wrapping versions.
|
||||
if(bAllVoxelsInternal)
|
||||
{
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ, WrapModes::Border, 3));
|
||||
}
|
||||
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,7 +173,7 @@ int32_t testDirectAccessWithWrappingBackwards(const VolumeType* volume, int lowX
|
||||
}
|
||||
|
||||
template <typename VolumeType>
|
||||
int32_t testSamplersWithWrappingBackwards(VolumeType* volume, int lowXOffset, int lowYOffset, int lowZOffset, int highXOffset, int highYOffset, int highZOffset)
|
||||
int32_t testSamplersWithWrappingBackwards(VolumeType* volume, Region region)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
@ -210,18 +182,14 @@ int32_t testSamplersWithWrappingBackwards(VolumeType* volume, int lowXOffset, in
|
||||
typename VolumeType::Sampler ySampler(volume);
|
||||
typename VolumeType::Sampler zSampler(volume);
|
||||
|
||||
xSampler.setWrapMode(WrapModes::Border, 3);
|
||||
ySampler.setWrapMode(WrapModes::Border, 3);
|
||||
zSampler.setWrapMode(WrapModes::Border, 3);
|
||||
|
||||
zSampler.setPosition(volume->getEnclosingRegion().getUpperX() + highXOffset, volume->getEnclosingRegion().getUpperY() + highYOffset, volume->getEnclosingRegion().getUpperZ() + highZOffset);
|
||||
for(int z = volume->getEnclosingRegion().getUpperZ() + highZOffset; z >= volume->getEnclosingRegion().getLowerZ() + lowZOffset; z--)
|
||||
zSampler.setPosition(region.getUpperX(), region.getUpperY(), region.getUpperZ());
|
||||
for (int z = region.getUpperZ(); z >= region.getLowerZ(); z--)
|
||||
{
|
||||
ySampler = zSampler;
|
||||
for(int y = volume->getEnclosingRegion().getUpperY() + highYOffset; y >= volume->getEnclosingRegion().getLowerY() + lowYOffset; y--)
|
||||
for (int y = region.getUpperY(); y >= region.getLowerY(); y--)
|
||||
{
|
||||
xSampler = ySampler;
|
||||
for(int x = volume->getEnclosingRegion().getUpperX() + highXOffset; x >= volume->getEnclosingRegion().getLowerX() + lowXOffset; x--)
|
||||
for (int x = region.getUpperX(); x >= region.getLowerX(); x--)
|
||||
{
|
||||
xSampler.setPosition(x, y, z); // HACK - Accessing a volume through multiple samplers currently breaks the PagedVolume.
|
||||
|
||||
@ -267,26 +235,32 @@ int32_t testSamplersWithWrappingBackwards(VolumeType* volume, int lowXOffset, in
|
||||
|
||||
TestVolume::TestVolume()
|
||||
{
|
||||
Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size
|
||||
m_regVolume = Region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size
|
||||
|
||||
m_regInternal = m_regVolume;
|
||||
m_regInternal.shiftLowerCorner(4, 2, 2);
|
||||
m_regInternal.shiftUpperCorner(-3, -1, -2);
|
||||
|
||||
m_regExternal = m_regVolume;
|
||||
m_regExternal.shiftLowerCorner(-1, -3, -2);
|
||||
m_regExternal.shiftUpperCorner(2, 5, 4);
|
||||
|
||||
m_pFilePager = new FilePager<int32_t>(".");
|
||||
|
||||
//Create the volumes
|
||||
m_pRawVolume = new RawVolume<int32_t>(region);
|
||||
m_pPagedVolume = new PagedVolume<int32_t>(region, m_pFilePager, 32);
|
||||
|
||||
m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024);
|
||||
m_pRawVolume = new RawVolume<int32_t>(m_regVolume);
|
||||
m_pPagedVolume = new PagedVolume<int32_t>(m_pFilePager, 1 * 1024 * 1024, 32);
|
||||
|
||||
//Fill the volume with some data
|
||||
for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
|
||||
for (int z = m_regVolume.getLowerZ(); z <= m_regVolume.getUpperZ(); z++)
|
||||
{
|
||||
for(int y = region.getLowerY(); y <= region.getUpperY(); y++)
|
||||
for (int y = m_regVolume.getLowerY(); y <= m_regVolume.getUpperY(); y++)
|
||||
{
|
||||
for(int x = region.getLowerX(); x <= region.getUpperX(); x++)
|
||||
for (int x = m_regVolume.getLowerX(); x <= m_regVolume.getUpperX(); x++)
|
||||
{
|
||||
int32_t value = x + y + z;
|
||||
m_pRawVolume->setVoxelAt(x, y, z, value);
|
||||
m_pPagedVolume->setVoxelAt(x, y, z, value);
|
||||
m_pRawVolume->setVoxel(x, y, z, value);
|
||||
m_pPagedVolume->setVoxel(x, y, z, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,7 +284,7 @@ void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingForwards(m_pRawVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testDirectAccessWithWrappingForwards(m_pRawVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(1004598054));
|
||||
}
|
||||
@ -321,7 +295,7 @@ void TestVolume::testRawVolumeSamplersAllInternalForwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingForwards(m_pRawVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testSamplersWithWrappingForwards(m_pRawVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(1004598054));
|
||||
}
|
||||
@ -332,9 +306,9 @@ void TestVolume::testRawVolumeDirectAccessWithExternalForwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingForwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testDirectAccessWithWrappingForwards(m_pRawVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||
QCOMPARE(result, static_cast<int32_t>(337227750));
|
||||
}
|
||||
|
||||
void TestVolume::testRawVolumeSamplersWithExternalForwards()
|
||||
@ -343,9 +317,9 @@ void TestVolume::testRawVolumeSamplersWithExternalForwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingForwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testSamplersWithWrappingForwards(m_pRawVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||
QCOMPARE(result, static_cast<int32_t>(337227750));
|
||||
}
|
||||
|
||||
void TestVolume::testRawVolumeDirectAccessAllInternalBackwards()
|
||||
@ -354,7 +328,7 @@ void TestVolume::testRawVolumeDirectAccessAllInternalBackwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingBackwards(m_pRawVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testDirectAccessWithWrappingBackwards(m_pRawVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-269366578));
|
||||
}
|
||||
@ -365,7 +339,7 @@ void TestVolume::testRawVolumeSamplersAllInternalBackwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingBackwards(m_pRawVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testSamplersWithWrappingBackwards(m_pRawVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-269366578));
|
||||
}
|
||||
@ -376,9 +350,9 @@ void TestVolume::testRawVolumeDirectAccessWithExternalBackwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testDirectAccessWithWrappingBackwards(m_pRawVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
QCOMPARE(result, static_cast<int32_t>(-993539594));
|
||||
}
|
||||
|
||||
void TestVolume::testRawVolumeSamplersWithExternalBackwards()
|
||||
@ -387,9 +361,9 @@ void TestVolume::testRawVolumeSamplersWithExternalBackwards()
|
||||
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testSamplersWithWrappingBackwards(m_pRawVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
QCOMPARE(result, static_cast<int32_t>(-993539594));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -401,7 +375,7 @@ void TestVolume::testPagedVolumeDirectAccessAllInternalForwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingForwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testDirectAccessWithWrappingForwards(m_pPagedVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(1004598054));
|
||||
}
|
||||
@ -411,7 +385,7 @@ void TestVolume::testPagedVolumeSamplersAllInternalForwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingForwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testSamplersWithWrappingForwards(m_pPagedVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(1004598054));
|
||||
}
|
||||
@ -421,9 +395,9 @@ void TestVolume::testPagedVolumeDirectAccessWithExternalForwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingForwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testDirectAccessWithWrappingForwards(m_pPagedVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||
QCOMPARE(result, static_cast<int32_t>(337227750));
|
||||
}
|
||||
|
||||
void TestVolume::testPagedVolumeSamplersWithExternalForwards()
|
||||
@ -431,9 +405,9 @@ void TestVolume::testPagedVolumeSamplersWithExternalForwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingForwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testSamplersWithWrappingForwards(m_pPagedVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||
QCOMPARE(result, static_cast<int32_t>(337227750));
|
||||
}
|
||||
|
||||
void TestVolume::testPagedVolumeDirectAccessAllInternalBackwards()
|
||||
@ -441,7 +415,7 @@ void TestVolume::testPagedVolumeDirectAccessAllInternalBackwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-269366578));
|
||||
}
|
||||
@ -451,7 +425,7 @@ void TestVolume::testPagedVolumeSamplersAllInternalBackwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingBackwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
|
||||
result = testSamplersWithWrappingBackwards(m_pPagedVolume, m_regInternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-269366578));
|
||||
}
|
||||
@ -461,9 +435,9 @@ void TestVolume::testPagedVolumeDirectAccessWithExternalBackwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
QCOMPARE(result, static_cast<int32_t>(-993539594));
|
||||
}
|
||||
|
||||
void TestVolume::testPagedVolumeSamplersWithExternalBackwards()
|
||||
@ -471,9 +445,9 @@ void TestVolume::testPagedVolumeSamplersWithExternalBackwards()
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
{
|
||||
result = testSamplersWithWrappingBackwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
|
||||
result = testSamplersWithWrappingBackwards(m_pPagedVolume, m_regExternal);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
QCOMPARE(result, static_cast<int32_t>(-993539594));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestVolume)
|
||||
|
@ -25,6 +25,7 @@ freely, subject to the following restrictions:
|
||||
#define __PolyVox_TestVolume_H__
|
||||
|
||||
#include "PolyVox/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVox/Region.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@ -56,6 +57,9 @@ private slots:
|
||||
void testPagedVolumeSamplersWithExternalBackwards();
|
||||
|
||||
private:
|
||||
PolyVox::Region m_regVolume;
|
||||
PolyVox::Region m_regInternal;
|
||||
PolyVox::Region m_regExternal;
|
||||
PolyVox::FilePager<int32_t>* m_pFilePager;
|
||||
|
||||
PolyVox::RawVolume<int32_t>* m_pRawVolume;
|
||||
|
Reference in New Issue
Block a user