diff --git a/library/PolyVoxCore/include/AStarPathfinder.h b/library/PolyVoxCore/include/AStarPathfinder.h index 03fd4da2..33878b08 100644 --- a/library/PolyVoxCore/include/AStarPathfinder.h +++ b/library/PolyVoxCore/include/AStarPathfinder.h @@ -43,8 +43,8 @@ namespace PolyVox /// This function provides the default method for checking whether a given voxel /// is vaid for the path computed by the AStarPathfinder. - template - bool aStarDefaultVoxelValidator(const LargeVolume* volData, const Vector3DInt32& v3dPos); + template< template class VolumeType, typename VoxelType> + bool aStarDefaultVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos); /// Provides a configuration for the AStarPathfinder. //////////////////////////////////////////////////////////////////////////////// @@ -57,20 +57,20 @@ namespace PolyVox /// /// \sa AStarPathfinder //////////////////////////////////////////////////////////////////////////////// - template + template< template class VolumeType, typename VoxelType> struct AStarPathfinderParams { public: AStarPathfinderParams ( - LargeVolume* volData, + VolumeType* volData, const Vector3DInt32& v3dStart, const Vector3DInt32& v3dEnd, std::list* listResult, float fHBias = 1.0, uint32_t uMaxNoOfNodes = 10000, Connectivity connectivity = TwentySixConnected, - polyvox_function*, const Vector3DInt32&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator, + polyvox_function*, const Vector3DInt32&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator, polyvox_function funcProgressCallback = 0 ) :volume(volData) @@ -86,7 +86,7 @@ namespace PolyVox } /// This is the volume through which the AStarPathfinder must find a path. - LargeVolume* volume; + VolumeType* volume; /// The start point for the pathfinding algorithm. Vector3DInt32 start; @@ -125,7 +125,7 @@ namespace PolyVox /// you could check to ensure that the voxel above is empty and the voxel below is solid. /// /// \sa aStarDefaultVoxelValidator - polyvox_function*, const Vector3DInt32&)> isVoxelValidForPath; + polyvox_function*, const Vector3DInt32&)> isVoxelValidForPath; /// This function is called by the AStarPathfinder to report on its progress in getting to /// the goal. The progress is reported by computing the distance from the closest node found @@ -159,11 +159,11 @@ namespace PolyVox /// /// \sa AStarPathfinderParams //////////////////////////////////////////////////////////////////////////////// - template + template< template class VolumeType, typename VoxelType> class AStarPathfinder { public: - AStarPathfinder(const AStarPathfinderParams& params); + AStarPathfinder(const AStarPathfinderParams& params); void execute(); @@ -185,7 +185,7 @@ namespace PolyVox float m_fProgress; - AStarPathfinderParams m_params; + AStarPathfinderParams m_params; }; } diff --git a/library/PolyVoxCore/include/AStarPathfinder.inl b/library/PolyVoxCore/include/AStarPathfinder.inl index fc9bbf27..180d7271 100644 --- a/library/PolyVoxCore/include/AStarPathfinder.inl +++ b/library/PolyVoxCore/include/AStarPathfinder.inl @@ -30,8 +30,8 @@ namespace PolyVox /// volume and if its density is below that returned by the voxel's getDensity() function. /// \return true is the voxel is valid for the path //////////////////////////////////////////////////////////////////////////////// - template - bool aStarDefaultVoxelValidator(const LargeVolume* volData, const Vector3DInt32& v3dPos) + template< template class VolumeType, typename VoxelType> + bool aStarDefaultVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos) { //Voxels are considered valid candidates for the path if they are inside the volume... if(volData->getEnclosingRegion().containsPoint(v3dPos) == false) @@ -52,14 +52,14 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// // AStarPathfinder Class //////////////////////////////////////////////////////////////////////////////// - template - AStarPathfinder::AStarPathfinder(const AStarPathfinderParams& params) + template< template class VolumeType, typename VoxelType> + AStarPathfinder::AStarPathfinder(const AStarPathfinderParams& params) :m_params(params) { } - template - void AStarPathfinder::execute() + template< template class VolumeType, typename VoxelType> + void AStarPathfinder::execute() { //Clear any existing nodes allNodes.clear(); @@ -191,8 +191,8 @@ namespace PolyVox } } - template - void AStarPathfinder::processNeighbour(const Vector3DInt32& neighbourPos, float neighbourGVal) + template< template class VolumeType, typename VoxelType> + void AStarPathfinder::processNeighbour(const Vector3DInt32& neighbourPos, float neighbourGVal) { bool bIsVoxelValidForPath = m_params.isVoxelValidForPath(m_params.volume, neighbourPos); if(!bIsVoxelValidForPath) @@ -247,8 +247,8 @@ namespace PolyVox } } - template - float AStarPathfinder::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) + template< template class VolumeType, typename VoxelType> + float AStarPathfinder::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) { //This is the only heuristic I'm sure of - just use the manhatten distance for the 6-connected case. uint32_t faceSteps = abs(a.getX()-b.getX()) + abs(a.getY()-b.getY()) + abs(a.getZ()-b.getZ()); @@ -256,8 +256,8 @@ namespace PolyVox return faceSteps * 1.0f; } - template - float AStarPathfinder::EighteenConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) + template< template class VolumeType, typename VoxelType> + float AStarPathfinder::EighteenConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) { //I'm not sure of the correct heuristic for the 18-connected case, so I'm just letting it fall through to the //6-connected case. This means 'h' will be bigger than it should be, resulting in a faster path which may not @@ -266,8 +266,8 @@ namespace PolyVox return SixConnectedCost(a,b); } - template - float AStarPathfinder::TwentySixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) + template< template class VolumeType, typename VoxelType> + float AStarPathfinder::TwentySixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) { //Can't say I'm certain about this heuristic - if anyone has //a better idea of what it should be then please let me know. @@ -288,8 +288,8 @@ namespace PolyVox return cornerSteps * sqrt_3 + edgeSteps * sqrt_2 + faceSteps * sqrt_1; } - template - float AStarPathfinder::computeH(const Vector3DInt32& a, const Vector3DInt32& b) + template< template class VolumeType, typename VoxelType> + float AStarPathfinder::computeH(const Vector3DInt32& a, const Vector3DInt32& b) { float hVal; diff --git a/library/PolyVoxCore/include/AmbientOcclusionCalculator.h b/library/PolyVoxCore/include/AmbientOcclusionCalculator.h index 07b6411d..f6ad0640 100644 --- a/library/PolyVoxCore/include/AmbientOcclusionCalculator.h +++ b/library/PolyVoxCore/include/AmbientOcclusionCalculator.h @@ -29,19 +29,19 @@ freely, subject to the following restrictions: namespace PolyVox { - template + template< template class VolumeType, typename VoxelType> class AmbientOcclusionCalculator { public: - AmbientOcclusionCalculator(LargeVolume* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement); + AmbientOcclusionCalculator(VolumeType* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement); ~AmbientOcclusionCalculator(); void execute(void); private: Region m_region; - typename LargeVolume::Sampler m_sampVolume; - LargeVolume* m_volInput; + typename VolumeType::Sampler m_sampVolume; + VolumeType* m_volInput; Array<3, uint8_t>* m_arrayResult; float m_fRayLength; diff --git a/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl b/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl index 0e4e76b0..9f64b481 100644 --- a/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl +++ b/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl @@ -28,10 +28,12 @@ freely, subject to the following restrictions: #include "PolyVoxImpl/RandomUnitVectors.h" #include "PolyVoxImpl/RandomVectors.h" +#include + namespace PolyVox { - template - AmbientOcclusionCalculator::AmbientOcclusionCalculator(LargeVolume* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement) + template< template class VolumeType, typename VoxelType> + AmbientOcclusionCalculator::AmbientOcclusionCalculator(VolumeType* volInput, Array<3, uint8_t>* arrayResult, Region region, float fRayLength, uint8_t uNoOfSamplesPerOutputElement) :m_region(region) ,m_sampVolume(volInput) ,m_volInput(volInput) @@ -54,18 +56,18 @@ namespace PolyVox mIndexIncreament = 1; } - template - AmbientOcclusionCalculator::~AmbientOcclusionCalculator() + template< template class VolumeType, typename VoxelType> + AmbientOcclusionCalculator::~AmbientOcclusionCalculator() { } - template - void AmbientOcclusionCalculator::execute(void) + template< template class VolumeType, typename VoxelType> + void AmbientOcclusionCalculator::execute(void) { const int iRatioX = m_volInput->getWidth() / m_arrayResult->getDimension(0); const int iRatioY = m_volInput->getHeight() / m_arrayResult->getDimension(1); const int iRatioZ = m_volInput->getDepth() / m_arrayResult->getDimension(2); - const int iRatioMax = std::max(std::max(iRatioX, iRatioY), iRatioZ); + const int iRatioMax = (std::max)((std::max)(iRatioX, iRatioY), iRatioZ); const float fRatioX = iRatioX; const float fRatioY = iRatioY; @@ -82,7 +84,7 @@ namespace PolyVox const Vector3DFloat v3dOffset(0.5f,0.5f,0.5f); RaycastResult raycastResult; - Raycast raycast(m_volInput, Vector3DFloat(0.0f,0.0f,0.0f), Vector3DFloat(1.0f,1.0f,1.0f), raycastResult); + Raycast raycast(m_volInput, Vector3DFloat(0.0f,0.0f,0.0f), Vector3DFloat(1.0f,1.0f,1.0f), raycastResult); //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) diff --git a/library/PolyVoxCore/include/Raycast.h b/library/PolyVoxCore/include/Raycast.h index 3c43da85..d43a6ff9 100644 --- a/library/PolyVoxCore/include/Raycast.h +++ b/library/PolyVoxCore/include/Raycast.h @@ -80,12 +80,12 @@ namespace PolyVox /// surace extractors. It's behaviour with the Marching Cubes surface extractor has not /// been tested yet. //////////////////////////////////////////////////////////////////////////////// - template + template< template class VolumeType, typename VoxelType> class Raycast { public: ///Constructor - Raycast(LargeVolume* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, RaycastResult& result); + Raycast(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, RaycastResult& result); ///Sets the start position for the ray. void setStart(const Vector3DFloat& v3dStart); @@ -100,8 +100,8 @@ namespace PolyVox void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2); - LargeVolume* m_volData; - typename LargeVolume::Sampler m_sampVolume; + VolumeType* m_volData; + typename VolumeType::Sampler m_sampVolume; Vector3DFloat m_v3dStart; Vector3DFloat m_v3dDirection; diff --git a/library/PolyVoxCore/include/Raycast.inl b/library/PolyVoxCore/include/Raycast.inl index d0eb30be..70f6d76c 100644 --- a/library/PolyVoxCore/include/Raycast.inl +++ b/library/PolyVoxCore/include/Raycast.inl @@ -30,8 +30,8 @@ namespace PolyVox /// represents the length of the ray. /// \param result An instance of RaycastResult in which the result will be stored. //////////////////////////////////////////////////////////////////////////////// - template - Raycast::Raycast(LargeVolume* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, RaycastResult& result) + template< template class VolumeType, typename VoxelType> + Raycast::Raycast(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, RaycastResult& result) :m_volData(volData) ,m_sampVolume(volData) ,m_v3dStart(v3dStart) @@ -43,8 +43,8 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// \param v3dStart The starting position of the ray. //////////////////////////////////////////////////////////////////////////////// - template - void Raycast::setStart(const Vector3DFloat& v3dStart) + template< template class VolumeType, typename VoxelType> + void Raycast::setStart(const Vector3DFloat& v3dStart) { m_v3dStart = v3dStart; } @@ -53,8 +53,8 @@ namespace PolyVox /// \param v3dDirection The direction of the ray. The length of this vector also /// represents the length of the ray. //////////////////////////////////////////////////////////////////////////////// - template - void Raycast::setDirection(const Vector3DFloat& v3dDirection) + template< template class VolumeType, typename VoxelType> + void Raycast::setDirection(const Vector3DFloat& v3dDirection) { m_v3dDirection = v3dDirection; } @@ -62,8 +62,8 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// The result is stored in the RaycastResult instance which was passed to the constructor. //////////////////////////////////////////////////////////////////////////////// - template - void Raycast::execute(void) + template< template class VolumeType, typename VoxelType> + void Raycast::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 @@ -106,8 +106,8 @@ namespace PolyVox // It should simply read "if (ty <= tz)". // // This error was reported by Joey Hammer (PixelActive). - template - void Raycast::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2) + template< template class VolumeType, typename VoxelType> + void Raycast::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2) { int i = (int)floorf(x1); int j = (int)floorf(y1); diff --git a/library/PolyVoxCore/include/RaycastWithCallback.h b/library/PolyVoxCore/include/RaycastWithCallback.h index 40b3a7d0..53a61640 100644 --- a/library/PolyVoxCore/include/RaycastWithCallback.h +++ b/library/PolyVoxCore/include/RaycastWithCallback.h @@ -26,12 +26,12 @@ freely, subject to the following restrictions: namespace PolyVox { - template + template< template class VolumeType, typename VoxelType> class RaycastWithCallback { public: ///Constructor - RaycastWithCallback(LargeVolume* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function funcCallback); + RaycastWithCallback(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function funcCallback); ///Sets the start position for the ray. void setStart(const Vector3DFloat& v3dStart); @@ -46,8 +46,8 @@ namespace PolyVox void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2); - LargeVolume* m_volData; - typename LargeVolume::Sampler m_sampVolume; + VolumeType* m_volData; + typename VolumeType::Sampler m_sampVolume; Vector3DFloat m_v3dStart; Vector3DFloat m_v3dDirection; diff --git a/library/PolyVoxCore/include/RaycastWithCallback.inl b/library/PolyVoxCore/include/RaycastWithCallback.inl index 166cb3b9..df50c7bd 100644 --- a/library/PolyVoxCore/include/RaycastWithCallback.inl +++ b/library/PolyVoxCore/include/RaycastWithCallback.inl @@ -22,8 +22,8 @@ freely, subject to the following restrictions: *******************************************************************************/ namespace PolyVox { - template - RaycastWithCallback::RaycastWithCallback(LargeVolume* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function funcCallback) + template< template class VolumeType, typename VoxelType> + RaycastWithCallback::RaycastWithCallback(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirection, polyvox_function funcCallback) :m_volData(volData) ,m_sampVolume(volData) ,m_v3dStart(v3dStart) @@ -35,20 +35,20 @@ namespace PolyVox assert(m_funcCallback); } - template - void RaycastWithCallback::setStart(const Vector3DFloat& v3dStart) + template< template class VolumeType, typename VoxelType> + void RaycastWithCallback::setStart(const Vector3DFloat& v3dStart) { m_v3dStart = v3dStart; } - template - void RaycastWithCallback::setDirection(const Vector3DFloat& v3dDirection) + template< template class VolumeType, typename VoxelType> + void RaycastWithCallback::setDirection(const Vector3DFloat& v3dDirection) { m_v3dDirection = v3dDirection; } - template - void RaycastWithCallback::execute(void) + template< template class VolumeType, typename VoxelType> + void RaycastWithCallback::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 - void RaycastWithCallback::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2) + template< template class VolumeType, typename VoxelType> + void RaycastWithCallback::doRaycast(float x1, float y1, float z1, float x2, float y2, float z2) { int i = (int)floorf(x1); int j = (int)floorf(y1);