Committing slightly dodgy code as I need to test on Linux.
This commit is contained in:
parent
d9192270b6
commit
1f748cbd72
@ -31,6 +31,10 @@ freely, subject to the following restrictions:
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Raycast.h"
|
||||
|
||||
//These two should not be here!
|
||||
#include "PolyVoxCore/Material.h"
|
||||
#include "PolyVoxCore/SimpleVolume.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace PolyVox
|
||||
@ -39,12 +43,16 @@ namespace PolyVox
|
||||
class AmbientOcclusionCalculator
|
||||
{
|
||||
public:
|
||||
AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement);
|
||||
AmbientOcclusionCalculator(VolumeType<VoxelType>* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement/*, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent*/);
|
||||
~AmbientOcclusionCalculator();
|
||||
|
||||
void execute(void);
|
||||
|
||||
private:
|
||||
|
||||
//bool raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler);
|
||||
bool raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler);
|
||||
|
||||
Region m_region;
|
||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
||||
VolumeType<VoxelType>* m_volInput;
|
||||
@ -56,6 +64,8 @@ namespace PolyVox
|
||||
uint16_t mRandomUnitVectorIndex;
|
||||
uint16_t mRandomVectorIndex;
|
||||
uint16_t mIndexIncreament;
|
||||
|
||||
polyvox_function<bool(const VoxelType& voxel)> m_funcIsTransparent;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
||||
namespace PolyVox
|
||||
{
|
||||
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)
|
||||
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_sampVolume(volInput)
|
||||
,m_volInput(volInput)
|
||||
@ -33,6 +33,7 @@ namespace PolyVox
|
||||
,m_uNoOfSamplesPerOutputElement(uNoOfSamplesPerOutputElement)
|
||||
,mRandomUnitVectorIndex(0) //Although these could be uninitialised, we
|
||||
,mRandomVectorIndex(0) //initialise for consistant results in the tests.
|
||||
//,m_funcIsTransparent(funcIsTransparent)
|
||||
{
|
||||
//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);
|
||||
@ -74,7 +75,7 @@ namespace PolyVox
|
||||
const Vector3DFloat v3dOffset(0.5f,0.5f,0.5f);
|
||||
|
||||
RaycastResult raycastResult;
|
||||
Raycast<VolumeType, VoxelType> raycast(m_volInput, Vector3DFloat(0.0f,0.0f,0.0f), Vector3DFloat(1.0f,1.0f,1.0f), raycastResult);
|
||||
Raycast<VolumeType, VoxelType> raycast(m_volInput, Vector3DFloat(0.0f,0.0f,0.0f), Vector3DFloat(1.0f,1.0f,1.0f), raycastResult, polyvox_bind(&PolyVox::AmbientOcclusionCalculator<VolumeType,VoxelType>::raycastCallback, this, std::placeholders::_1));
|
||||
|
||||
//This loop iterates over the bottom-lower-left voxel in each of the cells in the output array
|
||||
for(uint16_t z = m_region.getLowerCorner().getZ(); z <= m_region.getUpperCorner().getZ(); z += iRatioZ)
|
||||
@ -131,4 +132,13 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
//bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler)
|
||||
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler)
|
||||
{
|
||||
//VoxelType voxel = sampler.getVoxel();
|
||||
//return m_funcIsTransparent(voxel);
|
||||
return sampler.getVoxel().getMaterial() == 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user