worked on navMesh stuff
- creation - walking - helper
This commit is contained in:
64
navMesh/walk/NavMeshWalkParams.h
Normal file
64
navMesh/walk/NavMeshWalkParams.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef NAVMESHWALKPARAMS_H
|
||||
#define NAVMESHWALKPARAMS_H
|
||||
|
||||
#include "../../geo/Heading.h"
|
||||
#include "../NavMeshLocation.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 <typename Tria> float inMeter(const int steps, const NavMeshLocation<Tria>& start) const {
|
||||
|
||||
Assert::isTrue(isValid(), "invalid step-sizes given");
|
||||
|
||||
if (start.tria->isPlain()) {
|
||||
return stepSizeFloor_m * steps;
|
||||
} else {
|
||||
return stepSizeStair_m * steps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** configure walking from -> to */
|
||||
template <typename Tria> struct NavMeshWalkParams {
|
||||
|
||||
/** walk starts here (pos/tria) */
|
||||
NavMeshLocation<Tria> start;
|
||||
|
||||
// /** to-be-walked distance */
|
||||
// float distance_m;
|
||||
|
||||
/** 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 {
|
||||
return stepSizes.inMeter(numSteps, start);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NAVMESHWALKPARAMS_H
|
||||
Reference in New Issue
Block a user