Removed redundant hasMaterial and hasDensity traits.
Changed AStar default validator.
This commit is contained in:
@ -31,6 +31,24 @@ freely, subject to the following restrictions:
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
bool testVoxelValidator(const VolumeType<VoxelType>* volData, const Vector3DInt32& v3dPos)
|
||||
{
|
||||
//Voxels are considered valid candidates for the path if they are inside the volume...
|
||||
if(volData->getEnclosingRegion().containsPoint(v3dPos) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
VoxelType voxel = volData->getVoxelAt(v3dPos);
|
||||
if(voxel != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestAStarPathfinder::testExecute()
|
||||
{
|
||||
//The expected path
|
||||
@ -97,8 +115,23 @@ void TestAStarPathfinder::testExecute()
|
||||
};
|
||||
#endif //_MSC_VER
|
||||
|
||||
//Create an empty volume
|
||||
RawVolume<Material8> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(15, 15, 15)));
|
||||
const int32_t uVolumeSideLength = 16;
|
||||
|
||||
//Create a volume
|
||||
RawVolume<uint8_t> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(uVolumeSideLength-1, uVolumeSideLength-1, uVolumeSideLength-1)));
|
||||
|
||||
//Clear the volume
|
||||
for(int z = 0; z < uVolumeSideLength; z++)
|
||||
{
|
||||
for(int y = 0; y < uVolumeSideLength; y++)
|
||||
{
|
||||
for(int x = 0; x < uVolumeSideLength; x++)
|
||||
{
|
||||
uint8_t solidVoxel(0);
|
||||
volData.setVoxelAt(x,y,z,solidVoxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Place a solid cube in the middle of it
|
||||
for(int z = 4; z < 12; z++)
|
||||
@ -107,7 +140,7 @@ void TestAStarPathfinder::testExecute()
|
||||
{
|
||||
for(int x = 4; x < 12; x++)
|
||||
{
|
||||
Material8 solidVoxel(1);
|
||||
uint8_t solidVoxel(1);
|
||||
volData.setVoxelAt(x,y,z,solidVoxel);
|
||||
}
|
||||
}
|
||||
@ -117,8 +150,8 @@ void TestAStarPathfinder::testExecute()
|
||||
std::list<Vector3DInt32> result;
|
||||
|
||||
//Create an AStarPathfinder
|
||||
AStarPathfinderParams<RawVolume, Material8> params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(15,15,15), &result);
|
||||
AStarPathfinder<RawVolume, Material8> pathfinder(params);
|
||||
AStarPathfinderParams<RawVolume, uint8_t> params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(15,15,15), &result, 1.0f, 10000, TwentySixConnected, &testVoxelValidator<RawVolume, uint8_t>);
|
||||
AStarPathfinder<RawVolume, uint8_t> pathfinder(params);
|
||||
|
||||
//Execute the pathfinder.
|
||||
pathfinder.execute();
|
||||
|
Reference in New Issue
Block a user