|
|
|
|
@@ -3,7 +3,7 @@
|
|
|
|
|
|
|
|
|
|
#include "NavMeshWalkParams.h"
|
|
|
|
|
#include "../NavMeshLocation.h"
|
|
|
|
|
#include "../../math/Distributions.h"
|
|
|
|
|
#include "../../math/distribution/Normal.h"
|
|
|
|
|
#include "../../misc/PerfCheck.h"
|
|
|
|
|
#include "../../Assertions.h"
|
|
|
|
|
#include "../meta/NavMeshDijkstra.h"
|
|
|
|
|
@@ -44,40 +44,40 @@ namespace NM {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* evaluate the difference between head(start,end) and the requested heading
|
|
|
|
|
*/
|
|
|
|
|
template <typename Tria> class WalkEvalHeadingStartEndVonMises : public NavMeshWalkEval<Tria> {
|
|
|
|
|
// /**
|
|
|
|
|
// * evaluate the difference between head(start,end) and the requested heading
|
|
|
|
|
// */
|
|
|
|
|
// template <typename Tria> class WalkEvalHeadingStartEndVonMises : public NavMeshWalkEval<Tria> {
|
|
|
|
|
|
|
|
|
|
const double sigma_rad;
|
|
|
|
|
const double kappa;
|
|
|
|
|
Distribution::VonMises<double> _dist;
|
|
|
|
|
Distribution::LUT<double> dist;
|
|
|
|
|
// const double sigma_rad;
|
|
|
|
|
// const double kappa;
|
|
|
|
|
// Distribution::VonMises<double> _dist;
|
|
|
|
|
// Distribution::LUT<double> dist;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// public:
|
|
|
|
|
|
|
|
|
|
// kappa = 1/var = 1/sigma^2
|
|
|
|
|
// https://en.wikipedia.org/wiki/Von_Mises_distribution
|
|
|
|
|
WalkEvalHeadingStartEndVonMises(const double sigma_rad = 0.04) :
|
|
|
|
|
sigma_rad(sigma_rad), kappa(1.0/(sigma_rad*sigma_rad)), _dist(0, kappa), dist(_dist.getLUT()) {
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
// // kappa = 1/var = 1/sigma^2
|
|
|
|
|
// // https://en.wikipedia.org/wiki/Von_Mises_distribution
|
|
|
|
|
// WalkEvalHeadingStartEndVonMises(const double sigma_rad = 0.04) :
|
|
|
|
|
// sigma_rad(sigma_rad), kappa(1.0/(sigma_rad*sigma_rad)), _dist(0, kappa), dist(_dist.getLUT()) {
|
|
|
|
|
// ;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
virtual double getProbability(const NavMeshPotentialWalk<Tria>& walk) const override {
|
|
|
|
|
// virtual double getProbability(const NavMeshPotentialWalk<Tria>& walk) const override {
|
|
|
|
|
|
|
|
|
|
PERF_REGION(4, "WalkEvalHeadingStartEnd");
|
|
|
|
|
// PERF_REGION(4, "WalkEvalHeadingStartEnd");
|
|
|
|
|
|
|
|
|
|
Assert::notEqual(walk.requested.start.pos, walk.end.pos, "start equals end position");
|
|
|
|
|
// Assert::notEqual(walk.requested.start.pos, walk.end.pos, "start equals end position");
|
|
|
|
|
|
|
|
|
|
const Heading head(walk.requested.start.pos.xy(), walk.end.pos.xy());
|
|
|
|
|
const float diff = head.getDiffHalfRAD(walk.requested.heading);
|
|
|
|
|
//const float diff = Heading::getSignedDiff(params.heading, head);
|
|
|
|
|
//return Distribution::Normal<double>::getProbability(0, sigma, diff);
|
|
|
|
|
return dist.getProbability(diff);
|
|
|
|
|
// const Heading head(walk.requested.start.pos.xy(), walk.end.pos.xy());
|
|
|
|
|
// const float diff = head.getDiffHalfRAD(walk.requested.heading);
|
|
|
|
|
// //const float diff = Heading::getSignedDiff(params.heading, head);
|
|
|
|
|
// //return Distribution::Normal<double>::getProbability(0, sigma, diff);
|
|
|
|
|
// return dist.getProbability(diff);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* evaluate the difference between head(start,end) and the requested heading
|
|
|
|
|
|