Made raycasting, ambient occlusion, and A* pathfinding independant of volume type.

This commit is contained in:
David Williams
2011-05-01 17:26:12 +01:00
parent 27968973a4
commit 6a38d9fca7
8 changed files with 68 additions and 66 deletions

View File

@ -22,8 +22,8 @@ freely, subject to the following restrictions:
*******************************************************************************/
namespace PolyVox
{
template <typename VoxelType>
RaycastWithCallback<VoxelType>::RaycastWithCallback(LargeVolume<VoxelType>* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function<bool(const Vector3DInt32& position)> funcCallback)
template< template<typename> class VolumeType, typename VoxelType>
RaycastWithCallback<VolumeType, VoxelType>::RaycastWithCallback(VolumeType<VoxelType>* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function<bool(const Vector3DInt32& position)> funcCallback)
:m_volData(volData)
,m_sampVolume(volData)
,m_v3dStart(v3dStart)
@ -35,20 +35,20 @@ namespace PolyVox
assert(m_funcCallback);
}
template <typename VoxelType>
void RaycastWithCallback<VoxelType>::setStart(const Vector3DFloat& v3dStart)
template< template<typename> class VolumeType, typename VoxelType>
void RaycastWithCallback<VolumeType, VoxelType>::setStart(const Vector3DFloat& v3dStart)
{
m_v3dStart = v3dStart;
}
template <typename VoxelType>
void RaycastWithCallback<VoxelType>::setDirection(const Vector3DFloat& v3dDirection)
template< template<typename> class VolumeType, typename VoxelType>
void RaycastWithCallback<VolumeType, VoxelType>::setDirection(const Vector3DFloat& v3dDirection)
{
m_v3dDirection = v3dDirection;
}
template <typename VoxelType>
void RaycastWithCallback<VoxelType>::execute(void)
template< template<typename> class VolumeType, typename VoxelType>
void RaycastWithCallback<VolumeType, VoxelType>::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
@ -91,8 +91,8 @@ namespace PolyVox
// It should simply read "if (ty <= tz)".
//
// This error was reported by Joey Hammer (PixelActive).
template <typename VoxelType>
void RaycastWithCallback<VoxelType>::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2)
template< template<typename> class VolumeType, typename VoxelType>
void RaycastWithCallback<VolumeType, VoxelType>::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2)
{
int i = (int)floorf(x1);
int j = (int)floorf(y1);