class
#include <esp/nav/PathFinder.h>
PathFinder Contents
Loads and/or builds a navigation mesh and then performs path finding and collision queries on that navmesh
Constructors, destructors, conversion operators
- PathFinder()
- Constructor.
- ~PathFinder() defaulted
- ESP_SMART_POINTERS_WITH_UNIQUE_PIMPL(PathFinder)
Public functions
- auto build(const NavMeshSettings& bs, const float* verts, const int nverts, const int* tris, const int ntris, const float* bmin, const float* bmax) -> bool
-
auto build(const NavMeshSettings& bs,
const esp::
assets:: MeshData& mesh) -> bool - auto getRandomNavigablePoint() -> vec3f
- Returns a random navigable point.
- auto findPath(ShortestPath& path) -> bool
- Finds the shortest path between two points on the navigation mesh.
- auto findPath(MultiGoalShortestPath& path) -> bool
- Finds the shortest path from a start point to the closest (by geoddesic distance) end point.
-
template<typename T>auto tryStep(const T& start, const T& end) -> T
- Attempts to move from start to end and returns the navigable point closest to end that is feasibly reachable from start.
-
template<typename T>auto tryStepNoSliding(const T& start, const T& end) -> T
- Same as tryStep but does not allow for sliding along walls.
-
template<typename T>auto snapPoint(const T& pt) -> T
- Snaps a point to the navigation mesh.
-
auto loadNavMesh(const std::
string& path) -> bool - Loads a navigation meshed saved by saveNavMesh.
-
auto saveNavMesh(const std::
string& path) -> bool - Saves a navigation mesh to later be loaded by loadNavMesh.
- auto isLoaded() const -> bool
-
void seed(uint32_
t newSeed) - Seed the pathfinder. Useful for getRandomNavigablePoint.
- auto islandRadius(const vec3f& pt) const -> float
- returns the size of the connected component @ ref pt belongs to.
- auto distanceToClosestObstacle(const vec3f& pt, const float maxSearchRadius = 2.0) const -> float
- Finds the distance to the closest non-navigable location.
- auto closestObstacleSurfacePoint(const vec3f& pt, const float maxSearchRadius = 2.0) const -> HitRecord
- Same as distanceToClosestObstacle but returns additional information.
- auto isNavigable(const vec3f& pt, const float maxYDelta = 0.5) const -> bool
- Query whether or not a given location is navigable.
- auto getNavigableArea() const -> float
-
auto bounds() const -> std::
pair<vec3f, vec3f> - auto getTopDownView(const float metersPerPixel, const float height) -> Eigen::Matrix<bool, Eigen::Dynamic, Eigen::Dynamic>
-
auto getNavMeshData() -> const std::
shared_ptr<assets:: MeshData> - Returns a MeshData object containing triangulated NavMesh polys. The object is generated and stored if this is the first query.
Function documentation
vec3f esp:: nav:: PathFinder:: getRandomNavigablePoint()
Returns a random navigable point.
Returns | A random navigable point. |
---|
bool esp:: nav:: PathFinder:: findPath(ShortestPath& path)
Finds the shortest path between two points on the navigation mesh.
Parameters | |
---|---|
path in/out | The ShortestPath structure contain the starting and end point. This method will populate the ShortestPath:: |
Returns | Whether or not a path exists between ShortestPath:: |
bool esp:: nav:: PathFinder:: findPath(MultiGoalShortestPath& path)
Finds the shortest path from a start point to the closest (by geoddesic distance) end point.
Parameters | |
---|---|
path in/out | The MultiGoalShortestPath structure contain the start point and list of possible end points. This method will populate the MultiGoalShortestPath:: |
Returns | Whether or not a path exists between MultiGoalShortestPath:: |
template<typename T>
T esp:: nav:: PathFinder:: tryStep(const T& start,
const T& end)
Attempts to move from start to end and returns the navigable point closest to end that is feasibly reachable from start.
Parameters | |
---|---|
start in | The starting location |
end out | The desired end location |
Returns | The found end location |
template<typename T>
T esp:: nav:: PathFinder:: snapPoint(const T& pt)
Snaps a point to the navigation mesh.
Parameters | |
---|---|
pt in | The point to snap to the navigation mesh |
Returns | The closest navigation point to pt. Will be {inf, inf, inf} if no navigable point was within a reasonable distance |
bool esp:: nav:: PathFinder:: loadNavMesh(const std:: string& path)
Loads a navigation meshed saved by saveNavMesh.
Parameters | |
---|---|
path in | The saved navigation mesh file, generally has extension .navmesh |
Returns | Whether or not the navmesh was successfully loaded |
bool esp:: nav:: PathFinder:: saveNavMesh(const std:: string& path)
Saves a navigation mesh to later be loaded by loadNavMesh.
Parameters | |
---|---|
path in | The name of the file, generally has extension .navmesh |
Returns | Whether or not the navmesh was successfully saved |
bool esp:: nav:: PathFinder:: isLoaded() const
Returns | If a navigation mesh is current loaded or not |
---|
void esp:: nav:: PathFinder:: seed(uint32_ t newSeed)
Seed the pathfinder. Useful for getRandomNavigablePoint.
Parameters | |
---|---|
newSeed in | The random seed |
float esp:: nav:: PathFinder:: islandRadius(const vec3f& pt) const
returns the size of the connected component @ ref pt belongs to.
Parameters | |
---|---|
pt in | The point to specify the connected component |
Returns | Size of the connected component |
float esp:: nav:: PathFinder:: distanceToClosestObstacle(const vec3f& pt,
const float maxSearchRadius = 2.0) const
Finds the distance to the closest non-navigable location.
Parameters | |
---|---|
pt in | The radius to search in |
maxSearchRadius | |
Returns | The distance to the closest non-navigable location or maxSearchRadius if all locations within maxSearchRadius are navigable |
bool esp:: nav:: PathFinder:: isNavigable(const vec3f& pt,
const float maxYDelta = 0.5) const
Query whether or not a given location is navigable.
Parameters | |
---|---|
pt in | The location to check whether or not it is navigable |
maxYDelta in | The maximum y displacement. This tolerance is useful for computing a top-down occupancy grid as the floor is not perfectly level |
Returns | Whether or not pt is navigable |
This method works by snapping pt to the navigation mesh with snapPoint and then checking to see if there was no displacement in the x-z plane and at most maxYDelta displacement in the y direction.
float esp:: nav:: PathFinder:: getNavigableArea() const
Compute and return the total area of all NavMesh polygons
const std:: shared_ptr<assets:: MeshData> esp:: nav:: PathFinder:: getNavMeshData()
Returns a MeshData object containing triangulated NavMesh polys. The object is generated and stored if this is the first query.
Returns | The object containing triangulated NavMesh polys. |
---|
Does nothing if the PathFinder is not loaded.