Adding defines so that Boost can be used instead of C++0x when pathfinding.
This commit is contained in:
parent
c9331c3e35
commit
cb7180f7d0
@ -32,8 +32,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
const float sqrt_1 = 1.0f;
|
||||
@ -60,8 +58,8 @@ namespace PolyVox
|
||||
float fHBias = 1.0,
|
||||
uint32_t uMaxNoOfNodes = 10000,
|
||||
Connectivity connectivity = TwentySixConnected,
|
||||
std::function<bool (const Volume<VoxelType>*, const Vector3DInt16&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator<VoxelType>,
|
||||
std::function<void (float)> funcProgressCallback = 0
|
||||
polyvox_function<bool (const Volume<VoxelType>*, const Vector3DInt16&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator<VoxelType>,
|
||||
polyvox_function<void (float)> funcProgressCallback = 0
|
||||
)
|
||||
:volume(volData)
|
||||
,start(v3dStart)
|
||||
@ -94,10 +92,10 @@ namespace PolyVox
|
||||
uint32_t maxNumberOfNodes;
|
||||
|
||||
//Used to determine whether a given voxel is valid.
|
||||
std::function<bool (const Volume<VoxelType>*, const Vector3DInt16&)> isVoxelValidForPath;
|
||||
polyvox_function<bool (const Volume<VoxelType>*, const Vector3DInt16&)> isVoxelValidForPath;
|
||||
|
||||
//Progress callback
|
||||
std::function<void (float)> progressCallback;
|
||||
polyvox_function<void (float)> progressCallback;
|
||||
};
|
||||
|
||||
template <typename VoxelType>
|
||||
|
@ -264,7 +264,10 @@ namespace PolyVox
|
||||
array[0] = abs(a.getX() - b.getX());
|
||||
array[1] = abs(a.getY() - b.getY());
|
||||
array[2] = abs(a.getZ() - b.getZ());
|
||||
|
||||
|
||||
//Maybe this is better implemented directly
|
||||
//using three compares and two swaps... but not
|
||||
//until the profiler says so.
|
||||
std::sort(&array[0], &array[3]);
|
||||
|
||||
uint16_t cornerSteps = array[0];
|
||||
@ -303,20 +306,22 @@ namespace PolyVox
|
||||
//Apply the bias to the computed h value;
|
||||
hVal *= m_params.hBias;
|
||||
|
||||
std::hash<uint32_t> uint32Hash;
|
||||
|
||||
//Having computed hVal, we now apply some random bias to break ties.
|
||||
//This needs to be deterministic on the input position. This random
|
||||
//bias means it is much les likely that two paths are exactly the same
|
||||
//length, and so far fewer nodes must be expanded to find the shortest path.
|
||||
//See http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#S12
|
||||
polyvox_hash<uint32_t> uint32Hash;
|
||||
uint32_t hashValX = uint32Hash(a.getX());
|
||||
uint32_t hashValY = uint32Hash(a.getY());
|
||||
uint32_t hashValZ = uint32Hash(a.getZ());
|
||||
|
||||
uint32_t hashVal = hashValX ^ hashValY ^ hashValZ;
|
||||
|
||||
//Stop hashVal going over 65535, and divide by 1000000 to make sure it is small.
|
||||
hashVal &= 0x0000FFFF;
|
||||
|
||||
float fHash = hashVal / 1000000.0f;
|
||||
|
||||
//Apply the hash and return
|
||||
hVal += fHash;
|
||||
|
||||
return hVal;
|
||||
}
|
||||
}
|
@ -45,6 +45,13 @@ freely, subject to the following restrictions:
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#define polyvox_shared_ptr boost::shared_ptr
|
||||
|
||||
#include <boost/functional.hpp>
|
||||
#define polyvox_function boost::function
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#define polyvox_hash boost::hash
|
||||
|
||||
|
||||
//As long as we're requiring boost, we'll use it to compensate
|
||||
//for the missing cstdint header too.
|
||||
#include <boost/cstdint.hpp>
|
||||
@ -57,8 +64,11 @@ freely, subject to the following restrictions:
|
||||
#else
|
||||
//We have a decent compiler - use real C++0x features
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#define polyvox_shared_ptr std::shared_ptr
|
||||
#define polyvox_function std::function
|
||||
#define polyvox_hash std::hash
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user