Work on voxel refactoring...
This commit is contained in:
parent
1f748cbd72
commit
6d656ad173
@ -43,15 +43,18 @@ namespace PolyVox
|
|||||||
class AmbientOcclusionCalculator
|
class AmbientOcclusionCalculator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement/*, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent*/);
|
AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent);
|
||||||
~AmbientOcclusionCalculator();
|
~AmbientOcclusionCalculator();
|
||||||
|
|
||||||
void execute(void);
|
void execute(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//bool raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler);
|
#if defined(_MSC_VER) //FIXME: To be investigated. Linux version is more general and should be correct.
|
||||||
bool raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler);
|
bool raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler);
|
||||||
|
#else
|
||||||
|
bool raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler);
|
||||||
|
#endif
|
||||||
|
|
||||||
Region m_region;
|
Region m_region;
|
||||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
||||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template< template<typename> class VolumeType, typename VoxelType>
|
||||||
AmbientOcclusionCalculator<VolumeType, VoxelType>::AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement/*, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent*/)
|
AmbientOcclusionCalculator<VolumeType, VoxelType>::AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent)
|
||||||
:m_region(region)
|
:m_region(region)
|
||||||
,m_sampVolume(volInput)
|
,m_sampVolume(volInput)
|
||||||
,m_volInput(volInput)
|
,m_volInput(volInput)
|
||||||
@ -33,7 +33,7 @@ namespace PolyVox
|
|||||||
,m_uNoOfSamplesPerOutputElement(uNoOfSamplesPerOutputElement)
|
,m_uNoOfSamplesPerOutputElement(uNoOfSamplesPerOutputElement)
|
||||||
,mRandomUnitVectorIndex(0) //Although these could be uninitialised, we
|
,mRandomUnitVectorIndex(0) //Although these could be uninitialised, we
|
||||||
,mRandomVectorIndex(0) //initialise for consistant results in the tests.
|
,mRandomVectorIndex(0) //initialise for consistant results in the tests.
|
||||||
//,m_funcIsTransparent(funcIsTransparent)
|
,m_funcIsTransparent(funcIsTransparent)
|
||||||
{
|
{
|
||||||
//Make sure that the size of the volume is an exact multiple of the size of the array.
|
//Make sure that the size of the volume is an exact multiple of the size of the array.
|
||||||
assert(m_volInput->getWidth() % arrayResult->getDimension(0) == 0);
|
assert(m_volInput->getWidth() % arrayResult->getDimension(0) == 0);
|
||||||
@ -134,11 +134,13 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template< template<typename> class VolumeType, typename VoxelType>
|
||||||
//bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler)
|
#if defined(_MSC_VER)
|
||||||
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler)
|
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler)
|
||||||
|
#else
|
||||||
|
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
//VoxelType voxel = sampler.getVoxel();
|
VoxelType voxel = sampler.getVoxel();
|
||||||
//return m_funcIsTransparent(voxel);
|
return m_funcIsTransparent(voxel);
|
||||||
return sampler.getVoxel().getMaterial() == 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,11 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
|
bool isVoxelTransparent(Material8 voxel)
|
||||||
|
{
|
||||||
|
return voxel.getMaterial() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
void TestAmbientOcclusionGenerator::testExecute()
|
void TestAmbientOcclusionGenerator::testExecute()
|
||||||
{
|
{
|
||||||
const int32_t g_uVolumeSideLength = 64;
|
const int32_t g_uVolumeSideLength = 64;
|
||||||
@ -59,7 +64,7 @@ void TestAmbientOcclusionGenerator::testExecute()
|
|||||||
Array<3, uint8_t> ambientOcclusionResult(ArraySizes(g_uArraySideLength)(g_uArraySideLength)(g_uArraySideLength));
|
Array<3, uint8_t> ambientOcclusionResult(ArraySizes(g_uArraySideLength)(g_uArraySideLength)(g_uArraySideLength));
|
||||||
|
|
||||||
//Create the ambient occlusion calculator
|
//Create the ambient occlusion calculator
|
||||||
AmbientOcclusionCalculator<SimpleVolume, Material8> calculator(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255);
|
AmbientOcclusionCalculator<SimpleVolume, Material8> calculator(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255, isVoxelTransparent);
|
||||||
|
|
||||||
//Execute the calculator
|
//Execute the calculator
|
||||||
calculator.execute();
|
calculator.execute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user