Removed the ability to specify a region in the PagedVolume's constructor, and updated the tests and examples where required.
This commit is contained in:
parent
7e03c3e05b
commit
bfc7dfdc1b
@ -26,14 +26,14 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVox/CubicSurfaceExtractor.h"
|
#include "PolyVox/CubicSurfaceExtractor.h"
|
||||||
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVox/Mesh.h"
|
#include "PolyVox/Mesh.h"
|
||||||
#include "PolyVox/PagedVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
//Use the PolyVox namespace
|
//Use the PolyVox namespace
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
{
|
{
|
||||||
//This vector hold the position of the center of the volume
|
//This vector hold the position of the center of the volume
|
||||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
@ -78,7 +78,7 @@ protected:
|
|||||||
void initializeExample() override
|
void initializeExample() override
|
||||||
{
|
{
|
||||||
// Create an empty volume and then place a sphere in it
|
// Create an empty volume and then place a sphere in it
|
||||||
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
createSphereInVolume(volData, 30);
|
createSphereInVolume(volData, 30);
|
||||||
|
|
||||||
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
||||||
|
@ -26,14 +26,14 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVox/CubicSurfaceExtractor.h"
|
#include "PolyVox/CubicSurfaceExtractor.h"
|
||||||
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVox/Mesh.h"
|
#include "PolyVox/Mesh.h"
|
||||||
#include "PolyVox/PagedVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
//Use the PolyVox namespace
|
//Use the PolyVox namespace
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
{
|
{
|
||||||
//This vector hold the position of the center of the volume
|
//This vector hold the position of the center of the volume
|
||||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
@ -94,7 +94,7 @@ protected:
|
|||||||
setShader(shader);
|
setShader(shader);
|
||||||
|
|
||||||
//Create an empty volume and then place a sphere in it
|
//Create an empty volume and then place a sphere in it
|
||||||
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
createSphereInVolume(volData, 30);
|
createSphereInVolume(volData, 30);
|
||||||
|
|
||||||
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
||||||
|
@ -27,7 +27,7 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
void createSphereInVolume(PagedVolume<MaterialDensityPair88>& volData, float fRadius, uint8_t uValue)
|
void createSphereInVolume(RawVolume<MaterialDensityPair88>& volData, float fRadius, uint8_t uValue)
|
||||||
{
|
{
|
||||||
//This vector hold the position of the center of the volume
|
//This vector hold the position of the center of the volume
|
||||||
Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / static_cast<int32_t>(2);
|
Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / static_cast<int32_t>(2);
|
||||||
@ -55,7 +55,7 @@ void createSphereInVolume(PagedVolume<MaterialDensityPair88>& volData, float fRa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCubeInVolume(PagedVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
|
void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
|
||||||
{
|
{
|
||||||
uint8_t maxDen = MaterialDensityPair88::getMaxDensity();
|
uint8_t maxDen = MaterialDensityPair88::getMaxDensity();
|
||||||
uint8_t minDen = MaterialDensityPair88::getMinDensity();
|
uint8_t minDen = MaterialDensityPair88::getMinDensity();
|
||||||
|
@ -24,10 +24,10 @@ freely, subject to the following restrictions:
|
|||||||
#ifndef __OpenGLExample_Shapes_H__
|
#ifndef __OpenGLExample_Shapes_H__
|
||||||
#define __OpenGLExample_Shapes_H__
|
#define __OpenGLExample_Shapes_H__
|
||||||
|
|
||||||
#include "PolyVox/PagedVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
#include "PolyVox/MaterialDensityPair.h"
|
#include "PolyVox/MaterialDensityPair.h"
|
||||||
|
|
||||||
void createSphereInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair88>& volData, float fRadius, uint8_t uValue);
|
void createSphereInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, float fRadius, uint8_t uValue);
|
||||||
void createCubeInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair88>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
|
void createCubeInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
|
||||||
|
|
||||||
#endif //__OpenGLExample_Shapes_H__
|
#endif //__OpenGLExample_Shapes_H__
|
@ -58,8 +58,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void initializeExample() override
|
void initializeExample() override
|
||||||
{
|
{
|
||||||
FilePager<MaterialDensityPair88>* pager = new FilePager<MaterialDensityPair88>(".");
|
RawVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
|
||||||
PagedVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)), pager);
|
|
||||||
|
|
||||||
//Make our volume contain a sphere in the center.
|
//Make our volume contain a sphere in the center.
|
||||||
int32_t minPos = 0;
|
int32_t minPos = 0;
|
||||||
|
@ -151,7 +151,7 @@ protected:
|
|||||||
void initializeExample() override
|
void initializeExample() override
|
||||||
{
|
{
|
||||||
PerlinNoisePager* pager = new PerlinNoisePager();
|
PerlinNoisePager* pager = new PerlinNoisePager();
|
||||||
PagedVolume<MaterialDensityPair44> volData(PolyVox::Region::MaxRegion(), pager, 64);
|
PagedVolume<MaterialDensityPair44> volData(pager, 64);
|
||||||
volData.setMemoryUsageLimit(8 * 1024 * 1024); // 8Mb
|
volData.setMemoryUsageLimit(8 * 1024 * 1024); // 8Mb
|
||||||
|
|
||||||
//createSphereInVolume(volData, 30);
|
//createSphereInVolume(volData, 30);
|
||||||
|
@ -27,7 +27,6 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVox/Mesh.h"
|
#include "PolyVox/Mesh.h"
|
||||||
#include "PolyVox/RawVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
#include "PolyVox/PagedVolume.h"
|
|
||||||
#include "PolyVox/VolumeResampler.h"
|
#include "PolyVox/VolumeResampler.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -35,7 +34,7 @@ freely, subject to the following restrictions:
|
|||||||
//Use the PolyVox namespace
|
//Use the PolyVox namespace
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
{
|
{
|
||||||
//This vector hold the position of the center of the volume
|
//This vector hold the position of the center of the volume
|
||||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
@ -80,7 +79,7 @@ protected:
|
|||||||
void initializeExample() override
|
void initializeExample() override
|
||||||
{
|
{
|
||||||
//Create an empty volume and then place a sphere in it
|
//Create an empty volume and then place a sphere in it
|
||||||
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
createSphereInVolume(volData, 28);
|
createSphereInVolume(volData, 28);
|
||||||
|
|
||||||
//Smooth the data - should reimplement this using LowPassFilter
|
//Smooth the data - should reimplement this using LowPassFilter
|
||||||
@ -90,7 +89,7 @@ protected:
|
|||||||
|
|
||||||
RawVolume<uint8_t> volDataLowLOD(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(15, 31, 31)));
|
RawVolume<uint8_t> volDataLowLOD(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(15, 31, 31)));
|
||||||
|
|
||||||
VolumeResampler< PagedVolume<uint8_t>, RawVolume<uint8_t> > volumeResampler(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(31, 63, 63)), &volDataLowLOD, volDataLowLOD.getEnclosingRegion());
|
VolumeResampler< RawVolume<uint8_t>, RawVolume<uint8_t> > volumeResampler(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(31, 63, 63)), &volDataLowLOD, volDataLowLOD.getEnclosingRegion());
|
||||||
volumeResampler.execute();
|
volumeResampler.execute();
|
||||||
|
|
||||||
//Extract the surface
|
//Extract the surface
|
||||||
|
@ -251,7 +251,6 @@ namespace PolyVox
|
|||||||
/// Constructor for creating a fixed size volume.
|
/// Constructor for creating a fixed size volume.
|
||||||
PagedVolume
|
PagedVolume
|
||||||
(
|
(
|
||||||
const Region& regValid,
|
|
||||||
Pager* pPager = nullptr,
|
Pager* pPager = nullptr,
|
||||||
uint16_t uChunkSideLength = 32
|
uint16_t uChunkSideLength = 32
|
||||||
);
|
);
|
||||||
|
@ -39,11 +39,10 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
PagedVolume<VoxelType>::PagedVolume
|
PagedVolume<VoxelType>::PagedVolume
|
||||||
(
|
(
|
||||||
const Region& regValid,
|
|
||||||
Pager* pPager,
|
Pager* pPager,
|
||||||
uint16_t uChunkSideLength
|
uint16_t uChunkSideLength
|
||||||
)
|
)
|
||||||
:BaseVolume<VoxelType>(regValid)
|
:BaseVolume<VoxelType>(Region::MaxRegion())
|
||||||
{
|
{
|
||||||
m_uChunkSideLength = uChunkSideLength;
|
m_uChunkSideLength = uChunkSideLength;
|
||||||
m_pPager = pPager;
|
m_pPager = pPager;
|
||||||
@ -52,10 +51,10 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// If the user is creating a vast (almost infinite) volume then we can bet they will be
|
// If the user is creating a vast (almost infinite) volume then we can bet they will be
|
||||||
// expecting a high memory usage and will want a fair number of chunks to play around with.
|
// expecting a high memory usage and will want a fair number of chunks to play around with.
|
||||||
if (regValid == Region::MaxRegion())
|
/*if (regValid == Region::MaxRegion())
|
||||||
{
|
{*/
|
||||||
m_uChunkCountLimit = 1024;
|
m_uChunkCountLimit = 1024;
|
||||||
}
|
/*}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Otherwise we try to choose a chunk count to avoid too much thrashing, particularly when iterating
|
// Otherwise we try to choose a chunk count to avoid too much thrashing, particularly when iterating
|
||||||
@ -68,7 +67,7 @@ namespace PolyVox
|
|||||||
shortestSide /= m_uChunkSideLength;
|
shortestSide /= m_uChunkSideLength;
|
||||||
|
|
||||||
m_uChunkCountLimit = longestSide * shortestSide;
|
m_uChunkCountLimit = longestSide * shortestSide;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ void TestAmbientOcclusionGenerator::testExecute()
|
|||||||
const int32_t g_uVolumeSideLength = 64;
|
const int32_t g_uVolumeSideLength = 64;
|
||||||
|
|
||||||
//Create empty volume
|
//Create empty volume
|
||||||
PagedVolume<uint8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
|
PagedVolume<uint8_t> volData;
|
||||||
|
|
||||||
//Create two solid walls at opposite sides of the volume
|
//Create two solid walls at opposite sides of the volume
|
||||||
for (int32_t z = 0; z < g_uVolumeSideLength; z++)
|
for (int32_t z = 0; z < g_uVolumeSideLength; z++)
|
||||||
|
@ -60,11 +60,8 @@ public:
|
|||||||
|
|
||||||
// Runs the surface extractor for a given type.
|
// Runs the surface extractor for a given type.
|
||||||
template <typename VolumeType>
|
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
|
// Set up a random number generator
|
||||||
std::mt19937 rng;
|
std::mt19937 rng;
|
||||||
|
|
||||||
@ -78,7 +75,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol
|
|||||||
if (minValue == maxValue)
|
if (minValue == maxValue)
|
||||||
{
|
{
|
||||||
// In this case we are filling the whole volume with a single value.
|
// In this case we are filling the whole volume with a single value.
|
||||||
volData->setVoxel(x, y, z, minValue);
|
volData.setVoxel(x, y, z, minValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -86,13 +83,11 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol
|
|||||||
// We can't use std distributions because they vary between platforms (breaking tests).
|
// We can't use std distributions because they vary between platforms (breaking tests).
|
||||||
int voxelValue = (rng() % (maxValue - minValue + 1)) + minValue; // +1 for inclusive bounds
|
int voxelValue = (rng() % (maxValue - minValue + 1)) + minValue; // +1 for inclusive bounds
|
||||||
|
|
||||||
volData->setVoxel(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.
|
// Runs the surface extractor for a given type.
|
||||||
@ -100,7 +95,7 @@ template <typename VolumeType>
|
|||||||
VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
||||||
{
|
{
|
||||||
//Create empty volume
|
//Create empty volume
|
||||||
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)));
|
VolumeType* volData = new VolumeType;
|
||||||
|
|
||||||
//Fill the volume with data
|
//Fill the volume with data
|
||||||
for (int32_t z = 0; z < iVolumeSideLength; z++)
|
for (int32_t z = 0; z < iVolumeSideLength; z++)
|
||||||
@ -128,38 +123,45 @@ VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength)
|
|||||||
|
|
||||||
void TestCubicSurfaceExtractor::testBehaviour()
|
void TestCubicSurfaceExtractor::testBehaviour()
|
||||||
{
|
{
|
||||||
|
int32_t iVolumeSideLength = 32;
|
||||||
|
|
||||||
// Test with default mesh and contoller types.
|
// Test with default mesh and contoller types.
|
||||||
auto uint8Vol = createAndFillVolumeWithNoise< PagedVolume<uint8_t> >(32, 0, 2);
|
RawVolume<uint8_t> uint8Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||||
auto uint8Mesh = extractCubicMesh(uint8Vol, uint8Vol->getEnclosingRegion());
|
createAndFillVolumeWithNoise(uint8Vol, 32, 0, 2);
|
||||||
|
auto uint8Mesh = extractCubicMesh(&uint8Vol, uint8Vol.getEnclosingRegion());
|
||||||
QCOMPARE(uint8Mesh.getNoOfVertices(), uint32_t(57544));
|
QCOMPARE(uint8Mesh.getNoOfVertices(), uint32_t(57544));
|
||||||
QCOMPARE(uint8Mesh.getNoOfIndices(), uint32_t(215304));
|
QCOMPARE(uint8Mesh.getNoOfIndices(), uint32_t(215304));
|
||||||
|
|
||||||
// Test with default mesh type but user-provided controller.
|
// Test with default mesh type but user-provided controller.
|
||||||
auto int8Vol = createAndFillVolumeWithNoise< PagedVolume<int8_t> >(32, 0, 2);
|
RawVolume<int8_t> int8Vol(Region(0, 0, 0, iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1));
|
||||||
auto int8Mesh = extractCubicMesh(int8Vol, int8Vol->getEnclosingRegion(), CustomIsQuadNeeded<int8_t>());
|
createAndFillVolumeWithNoise(int8Vol, 32, 0, 2);
|
||||||
|
auto int8Mesh = extractCubicMesh(&int8Vol, int8Vol.getEnclosingRegion(), CustomIsQuadNeeded<int8_t>());
|
||||||
QCOMPARE(int8Mesh.getNoOfVertices(), uint32_t(29106));
|
QCOMPARE(int8Mesh.getNoOfVertices(), uint32_t(29106));
|
||||||
QCOMPARE(int8Mesh.getNoOfIndices(), uint32_t(178566));
|
QCOMPARE(int8Mesh.getNoOfIndices(), uint32_t(178566));
|
||||||
|
|
||||||
// Test with default controller but user-provided mesh.
|
// 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;
|
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.getNoOfVertices(), uint16_t(57544));
|
||||||
QCOMPARE(uint32Mesh.getNoOfIndices(), uint32_t(215304));
|
QCOMPARE(uint32Mesh.getNoOfIndices(), uint32_t(215304));
|
||||||
|
|
||||||
// Test with both mesh and controller being provided by the user.
|
// 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;
|
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.getNoOfVertices(), uint16_t(29106));
|
||||||
QCOMPARE(int32Mesh.getNoOfIndices(), uint32_t(178566));
|
QCOMPARE(int32Mesh.getNoOfIndices(), uint32_t(178566));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCubicSurfaceExtractor::testEmptyVolumePerformance()
|
void TestCubicSurfaceExtractor::testEmptyVolumePerformance()
|
||||||
{
|
{
|
||||||
auto emptyVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 0);
|
PagedVolume<uint32_t> emptyVol;
|
||||||
|
createAndFillVolumeWithNoise(emptyVol, 128, 0, 0);
|
||||||
Mesh< CubicVertex< uint32_t >, uint16_t > emptyMesh;
|
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));
|
QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,9 +175,10 @@ void TestCubicSurfaceExtractor::testRealisticVolumePerformance()
|
|||||||
|
|
||||||
void TestCubicSurfaceExtractor::testNoiseVolumePerformance()
|
void TestCubicSurfaceExtractor::testNoiseVolumePerformance()
|
||||||
{
|
{
|
||||||
auto noiseVol = createAndFillVolumeWithNoise< PagedVolume<uint32_t> >(128, 0, 2);
|
PagedVolume<uint32_t> noiseVol;
|
||||||
|
createAndFillVolumeWithNoise(noiseVol, 128, 0, 2);
|
||||||
Mesh< CubicVertex< uint32_t >, uint16_t > noiseMesh;
|
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));
|
QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(57905));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
|||||||
#include "TestPicking.h"
|
#include "TestPicking.h"
|
||||||
|
|
||||||
#include "PolyVox/Picking.h"
|
#include "PolyVox/Picking.h"
|
||||||
#include "PolyVox/PagedVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ void TestPicking::testExecute()
|
|||||||
{
|
{
|
||||||
const int32_t uVolumeSideLength = 32;
|
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 z = 0; z < uVolumeSideLength; z++)
|
||||||
{
|
{
|
||||||
for (int32_t y = 0; y < uVolumeSideLength; y++)
|
for (int32_t y = 0; y < uVolumeSideLength; y++)
|
||||||
|
@ -25,7 +25,7 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
#include "PolyVox/Density.h"
|
#include "PolyVox/Density.h"
|
||||||
#include "PolyVox/Raycast.h"
|
#include "PolyVox/Raycast.h"
|
||||||
#include "PolyVox/PagedVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
#include "PolyVox/Impl/RandomUnitVectors.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++;
|
m_uVoxelsTouched++;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void TestRaycast::testExecute()
|
|||||||
const int32_t uVolumeSideLength = 32;
|
const int32_t uVolumeSideLength = 32;
|
||||||
|
|
||||||
//Create a hollow volume, with solid sides on x and y but with open ends in z.
|
//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 z = 0; z < uVolumeSideLength; z++)
|
||||||
{
|
{
|
||||||
for (int32_t y = 0; y < uVolumeSideLength; y++)
|
for (int32_t y = 0; y < uVolumeSideLength; y++)
|
||||||
|
@ -103,10 +103,8 @@ VolumeType* createAndFillVolume(void)
|
|||||||
{
|
{
|
||||||
const int32_t uVolumeSideLength = 64;
|
const int32_t uVolumeSideLength = 64;
|
||||||
|
|
||||||
FilePager<typename VolumeType::VoxelType>* pager = new FilePager<typename VolumeType::VoxelType>(".");
|
|
||||||
|
|
||||||
//Create empty volume
|
//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
|
// Fill
|
||||||
for (int32_t z = 0; z < uVolumeSideLength; z++)
|
for (int32_t z = 0; z < uVolumeSideLength; z++)
|
||||||
@ -134,7 +132,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minVal
|
|||||||
FilePager<float>* pager = new FilePager<float>(".");
|
FilePager<float>* pager = new FilePager<float>(".");
|
||||||
|
|
||||||
//Create empty volume
|
//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
|
// Set up a random number generator
|
||||||
std::mt19937 rng;
|
std::mt19937 rng;
|
||||||
@ -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.
|
// 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.
|
// 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());
|
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.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
|
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
|
QCOMPARE(uintMesh.getVertex(100).data, uint8_t(1)); // Not really meaningful for a primative type
|
||||||
|
|
||||||
// This test makes use of a custom controller
|
// This test makes use of a custom controller
|
||||||
auto floatVol = createAndFillVolume< PagedVolume<float> >();
|
auto floatVol = createAndFillVolume< RawVolume<float> >();
|
||||||
CustomMarchingCubesController floatCustomController;
|
CustomMarchingCubesController floatCustomController;
|
||||||
auto floatMesh = extractMarchingCubesMesh(floatVol, floatVol->getEnclosingRegion(), 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
|
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
|
// 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.
|
// 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;
|
Mesh< MarchingCubesVertex< int8_t >, uint16_t > intMesh;
|
||||||
extractMarchingCubesMeshCustom(intVol, intVol->getEnclosingRegion(), &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.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
|
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.
|
// 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;
|
CustomMarchingCubesController doubleCustomController;
|
||||||
Mesh< MarchingCubesVertex< double >, uint16_t > doubleMesh;
|
Mesh< MarchingCubesVertex< double >, uint16_t > doubleMesh;
|
||||||
extractMarchingCubesMeshCustom(doubleVol, doubleVol->getEnclosingRegion(), &doubleMesh, doubleCustomController);
|
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
|
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.
|
// 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());
|
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.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
|
QCOMPARE(materialMesh.getNoOfIndices(), uint32_t(35157)); // Verifies size of mesh
|
||||||
|
@ -265,7 +265,7 @@ TestVolume::TestVolume()
|
|||||||
|
|
||||||
//Create the volumes
|
//Create the volumes
|
||||||
m_pRawVolume = new RawVolume<int32_t>(region);
|
m_pRawVolume = new RawVolume<int32_t>(region);
|
||||||
m_pPagedVolume = new PagedVolume<int32_t>(region, m_pFilePager, 32);
|
m_pPagedVolume = new PagedVolume<int32_t>(m_pFilePager, 32);
|
||||||
|
|
||||||
m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024);
|
m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user