added dijkstra support to navmesh
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
#include "../NavMeshLocation.h"
|
||||
#include "../../math/Distributions.h"
|
||||
#include "../../misc/PerfCheck.h"
|
||||
#include "../../Assertions.h"
|
||||
#include "../meta/NavMeshDijkstra.h"
|
||||
|
||||
|
||||
namespace NM {
|
||||
|
||||
@@ -136,6 +139,32 @@ namespace NM {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* higher probability for potints that approach the target location
|
||||
*/
|
||||
template <typename Tria> class WalkEvalApproachesTarget : public NavMeshWalkEval<Tria> {
|
||||
|
||||
const double p = 0.65;
|
||||
|
||||
public:
|
||||
|
||||
virtual double getProbability(const NavMeshPotentialWalk<Tria>& walk) const override {
|
||||
|
||||
// sanity check
|
||||
StaticAssert::AinheritsB<Tria, NavMeshTriangleDijkstra>();
|
||||
|
||||
const NavMeshLocation<Tria> locStart = walk.requested.start;
|
||||
const NavMeshLocation<Tria> locEnd = walk.end;
|
||||
|
||||
const float distFromNew = locEnd.tria->getDistanceToDestination<Tria>(locEnd.pos);
|
||||
const float distFromOld = locStart.tria->getDistanceToDestination<Tria>(locStart.pos);
|
||||
|
||||
return (distFromNew <= distFromOld) ? (p) : (1.0 - p);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NAVMESHWALKEVAL_H
|
||||
|
||||
Reference in New Issue
Block a user