#ifndef NAVMESHWALKPARAMS_H #define NAVMESHWALKPARAMS_H #include "../../geo/Heading.h" #include "../NavMeshLocation.h" #include "../NavMeshType.h" namespace NM { /** configure pedestrian StepSizes */ struct StepSizes { float stepSizeFloor_m = NAN; float stepSizeStair_m = NAN; bool isValid() const { return (stepSizeFloor_m==stepSizeFloor_m) && (stepSizeStair_m==stepSizeStair_m); } template float inMeter(const int steps, const NavMeshLocation& start) const { Assert::isTrue(isValid(), "invalid step-sizes given"); if (start.tria->getType() == (int) NM::NavMeshType::STAIR_SKEWED) { return stepSizeStair_m * steps; } else { return stepSizeFloor_m * steps; } // if (start.tria->isPlain()) { // return stepSizeFloor_m * steps; // } else { // return stepSizeStair_m * steps; // } } }; /** configure walking from -> to */ template struct NavMeshWalkParams { /** walk starts here (pos/tria) */ NavMeshLocation start; /** direction to walk to */ Heading heading; /** number of steps to walk */ int numSteps; /** configuration for pedestrian's step-sizes */ StepSizes stepSizes; /** empty ctor */ NavMeshWalkParams() : heading(0) {;} /** get the to-be-walked distance (steps vs. current location [stair/floor/..]) */ float getToBeWalkedDistance() const { if (_toBeWalkedDistance != _toBeWalkedDistance) { _toBeWalkedDistance = stepSizes.inMeter(numSteps, start); } return _toBeWalkedDistance; } private: // precalc mutable float _toBeWalkedDistance = NAN; }; } #endif // NAVMESHWALKPARAMS_H