Removed use of template template parameters from Raycast and AmbientOcclusionCalculator.
This commit is contained in:
parent
29d816d416
commit
9db04f38bc
@ -41,26 +41,21 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
template<typename VolumeType>
|
||||
class AmbientOcclusionCalculator
|
||||
{
|
||||
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* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement, polyvox_function<bool(const typename VolumeType::VoxelType& voxel)> funcIsTransparent);
|
||||
~AmbientOcclusionCalculator();
|
||||
|
||||
void execute(void);
|
||||
|
||||
private:
|
||||
|
||||
#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);
|
||||
#else
|
||||
bool raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler);
|
||||
#endif
|
||||
bool raycastCallback(const typename VolumeType::Sampler& sampler);
|
||||
|
||||
Region m_region;
|
||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
||||
VolumeType<VoxelType>* m_volInput;
|
||||
typename VolumeType::Sampler m_sampVolume;
|
||||
VolumeType* m_volInput;
|
||||
Array<3, uint8_t>* m_arrayResult;
|
||||
float m_fRayLength;
|
||||
|
||||
@ -70,7 +65,7 @@ namespace PolyVox
|
||||
uint16_t mRandomVectorIndex;
|
||||
uint16_t mIndexIncreament;
|
||||
|
||||
polyvox_function<bool(const VoxelType& voxel)> m_funcIsTransparent;
|
||||
polyvox_function<bool(const typename VolumeType::VoxelType& voxel)> m_funcIsTransparent;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ 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, polyvox_function<bool(const VoxelType& voxel)> funcIsTransparent)
|
||||
template<typename VolumeType>
|
||||
AmbientOcclusionCalculator<VolumeType>::AmbientOcclusionCalculator(VolumeType* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement, polyvox_function<bool(const typename VolumeType::VoxelType& voxel)> funcIsTransparent)
|
||||
:m_region(region)
|
||||
,m_sampVolume(volInput)
|
||||
,m_volInput(volInput)
|
||||
@ -50,13 +50,13 @@ namespace PolyVox
|
||||
mIndexIncreament = 1;
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
AmbientOcclusionCalculator<VolumeType, VoxelType>::~AmbientOcclusionCalculator()
|
||||
template<typename VolumeType>
|
||||
AmbientOcclusionCalculator<VolumeType>::~AmbientOcclusionCalculator()
|
||||
{
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void AmbientOcclusionCalculator<VolumeType, VoxelType>::execute(void)
|
||||
template<typename VolumeType>
|
||||
void AmbientOcclusionCalculator<VolumeType>::execute(void)
|
||||
{
|
||||
const int iRatioX = m_volInput->getWidth() / m_arrayResult->getDimension(0);
|
||||
const int iRatioY = m_volInput->getHeight() / m_arrayResult->getDimension(1);
|
||||
@ -75,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, polyvox_bind(&PolyVox::AmbientOcclusionCalculator<VolumeType,VoxelType>::raycastCallback, this, std::placeholders::_1));
|
||||
Raycast<VolumeType> raycast(m_volInput, Vector3DFloat(0.0f,0.0f,0.0f), Vector3DFloat(1.0f,1.0f,1.0f), raycastResult, polyvox_bind(&PolyVox::AmbientOcclusionCalculator<VolumeType>::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)
|
||||
@ -133,14 +133,10 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
#if defined(_MSC_VER)
|
||||
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename SimpleVolume<VoxelType>::Sampler& sampler)
|
||||
#else
|
||||
bool AmbientOcclusionCalculator<VolumeType, VoxelType>::raycastCallback(const typename VolumeType<VoxelType>::Sampler& sampler)
|
||||
#endif
|
||||
template<typename VolumeType>
|
||||
bool AmbientOcclusionCalculator<VolumeType>::raycastCallback(const typename VolumeType::Sampler& sampler)
|
||||
{
|
||||
VoxelType voxel = sampler.getVoxel();
|
||||
VolumeType::VoxelType voxel = sampler.getVoxel();
|
||||
return m_funcIsTransparent(voxel);
|
||||
}
|
||||
}
|
||||
|
@ -91,12 +91,12 @@ namespace PolyVox
|
||||
/// surace extractors. It's behaviour with the Marching Cubes surface extractor has not
|
||||
/// been tested yet.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
template<typename VolumeType>
|
||||
class Raycast
|
||||
{
|
||||
public:
|
||||
///Constructor
|
||||
Raycast(VolumeType<VoxelType>* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirectionAndLength, RaycastResult& result, polyvox_function<bool(const typename VolumeType<VoxelType>::Sampler& sampler)> funcIsPassable);
|
||||
Raycast(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirectionAndLength, RaycastResult& result, polyvox_function<bool(const typename VolumeType::Sampler& sampler)> funcIsPassable);
|
||||
|
||||
///Sets the start position for the ray.
|
||||
void setStart(const Vector3DFloat& v3dStart);
|
||||
@ -109,12 +109,12 @@ namespace PolyVox
|
||||
private:
|
||||
RaycastResult& m_result;
|
||||
|
||||
polyvox_function<bool(const typename VolumeType<VoxelType>::Sampler& position)> m_funcIsPassable;
|
||||
polyvox_function<bool(const typename VolumeType::Sampler& position)> m_funcIsPassable;
|
||||
|
||||
void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2);
|
||||
|
||||
VolumeType<VoxelType>* m_volData;
|
||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
||||
VolumeType* m_volData;
|
||||
typename VolumeType::Sampler m_sampVolume;
|
||||
|
||||
Vector3DFloat m_v3dStart;
|
||||
Vector3DFloat m_v3dDirectionAndLength;
|
||||
|
@ -31,8 +31,8 @@ namespace PolyVox
|
||||
/// represents the length of the ray.
|
||||
/// \param result An instance of RaycastResult in which the result will be stored.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
Raycast<VolumeType, VoxelType>::Raycast(VolumeType<VoxelType>* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirectionAndLength, RaycastResult& result, polyvox_function<bool(const typename VolumeType<VoxelType>::Sampler& sampler)> funcIsPassable)
|
||||
template<typename VolumeType>
|
||||
Raycast<VolumeType>::Raycast(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirectionAndLength, RaycastResult& result, polyvox_function<bool(const typename VolumeType::Sampler& sampler)> funcIsPassable)
|
||||
:m_result(result)
|
||||
,m_volData(volData)
|
||||
,m_sampVolume(volData)
|
||||
@ -45,8 +45,8 @@ namespace PolyVox
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \param v3dStart The starting position of the ray.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void Raycast<VolumeType, VoxelType>::setStart(const Vector3DFloat& v3dStart)
|
||||
template<typename VolumeType>
|
||||
void Raycast<VolumeType>::setStart(const Vector3DFloat& v3dStart)
|
||||
{
|
||||
m_v3dStart = v3dStart;
|
||||
}
|
||||
@ -55,8 +55,8 @@ namespace PolyVox
|
||||
/// \param v3dDirectionAndLength The direction of the ray. The length of this vector also
|
||||
/// represents the length of the ray.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void Raycast<VolumeType, VoxelType>::setDirection(const Vector3DFloat& v3dDirectionAndLength)
|
||||
template<typename VolumeType>
|
||||
void Raycast<VolumeType>::setDirection(const Vector3DFloat& v3dDirectionAndLength)
|
||||
{
|
||||
//FIXME: We should add a warning when the ray direction is of length one, as this seems to be a common mistake.
|
||||
m_v3dDirectionAndLength = v3dDirectionAndLength;
|
||||
@ -65,8 +65,8 @@ namespace PolyVox
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The result is stored in the RaycastResult instance which was passed to the constructor.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void Raycast<VolumeType, VoxelType>::execute(void)
|
||||
template<typename VolumeType>
|
||||
void Raycast<VolumeType>::execute(void)
|
||||
{
|
||||
//The doRaycast function is assuming that it is iterating over the areas defined between
|
||||
//voxels. We actually want to define the areas as being centered on voxels (as this is
|
||||
@ -109,8 +109,8 @@ namespace PolyVox
|
||||
// It should simply read "if (ty <= tz)".
|
||||
//
|
||||
// This error was reported by Joey Hammer (PixelActive).
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void Raycast<VolumeType, VoxelType>::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
template<typename VolumeType>
|
||||
void Raycast<VolumeType>::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
int i = (int)floorf(x1);
|
||||
int j = (int)floorf(y1);
|
||||
|
@ -62,7 +62,7 @@ void TestAmbientOcclusionGenerator::testExecute()
|
||||
Array<3, uint8_t> ambientOcclusionResult(ArraySizes(g_uArraySideLength)(g_uArraySideLength)(g_uArraySideLength));
|
||||
|
||||
//Create the ambient occlusion calculator
|
||||
AmbientOcclusionCalculator<SimpleVolume, uint8_t> calculator(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255, isVoxelTransparent);
|
||||
AmbientOcclusionCalculator< SimpleVolume<uint8_t> > calculator(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255, isVoxelTransparent);
|
||||
|
||||
//Execute the calculator
|
||||
calculator.execute();
|
||||
|
@ -68,7 +68,7 @@ void TestRaycast::testExecute()
|
||||
for(int ct = 0; ct < 1000000; ct++)
|
||||
{
|
||||
RaycastResult result;
|
||||
Raycast<SimpleVolume, int8_t> raycast(&volData, start, randomUnitVectors[ct % 1024] * 1000.0f, result, isPassableByRay);
|
||||
Raycast< SimpleVolume<int8_t> > raycast(&volData, start, randomUnitVectors[ct % 1024] * 1000.0f, result, isPassableByRay);
|
||||
raycast.execute();
|
||||
if(result.foundIntersection)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user