![]() |
Menge
Modular Pedestrian Simulation Framework for Research and Development
|
The definition of a path through space comprising of a sequence of portals. More...
#include <PortalPath.h>
Public Member Functions | |
PortalPath (const Vector2 &startPos, const BFSM::Goal *goal, const PortalRoute *route, float agentRadius) | |
Constructor. More... | |
~PortalPath () | |
Destructor. | |
void | setPreferredDirection (const Agents::BaseAgent *agent, float headingCos, Agents::PrefVelocity &pVel) |
Sets the directions in the preferred velocity from the path. More... | |
unsigned int | updateLocation (const Agents::BaseAgent *agent, const NavMeshPtr &navMesh, const NavMeshLocalizer *localizer, PathPlanner *planner) |
Updates the location of the agent relative to the nav mesh. More... | |
unsigned int | getNode () const |
Reports the node the agent is currently in. More... | |
size_t | getWayPointCount () const |
Reports the number of way points in the path (not including the goal) More... | |
Vector2 | getWayPoint (size_t i) const |
Returns the position of the ith way point. More... | |
const BFSM::Goal * | getGoal () const |
Returns the goal. More... | |
Vector2 | getGoalCentroid () const |
Returns the centroid of the goal. More... | |
unsigned int | getEndNode () const |
Returns the identifier for the destination node on the path. More... | |
unsigned int | getNode (size_t i) const |
Returns the id of the node traveled for the ith way point. More... | |
size_t | getCurrentPortal () const |
Returns the index of the current portal (the portal the agent is currently headed towards. More... | |
size_t | getPortalCount () const |
Reports the number of portals in the path) More... | |
const WayPortal * | getPortal (size_t i) const |
Returns the ith portal. More... | |
void | setWaypoints (size_t start, size_t end, const Vector2 &p0, const Vector2 &dir) |
Set the waypoints for all of the indicated way portals. More... | |
Protected Member Functions | |
void | computeCrossing (const Vector2 &startPos, float agentRadius) |
Computes the crossing values for each portal. More... | |
void | replan (const Vector2 &startPos, unsigned int startNode, unsigned int endNode, float minWidth, PathPlanner *planner) |
Something has changed and the path has to replan. More... | |
Protected Attributes | |
const PortalRoute * | _route |
The route to follow. | |
const BFSM::Goal * | _goal |
The ultimate goal. | |
size_t | _currPortal |
The index of the way portal currently serving as immediate goal. -1 means it's at the end. | |
Vector2 * | _waypoints |
The sequence of way points. Some way points will be duplicated. | |
Vector2 * | _headings |
The original direction to the way point. | |
The definition of a path through space comprising of a sequence of portals.
The path is repsonsible for computing instantaneous preferred velocity for an agent based on a PortalRoute and an optimized path through the portals.
Menge::PortalPath::PortalPath | ( | const Vector2 & | startPos, |
const BFSM::Goal * | goal, | ||
const PortalRoute * | route, | ||
float | agentRadius | ||
) |
Constructor.
startPos | The 2D position where the path starts |
goal | The goal (whose centroid lies in the final polygon). |
route | The route the path follows |
agentRadius | The radius of the given agent. |
|
protected |
Computes the crossing values for each portal.
startPos | The 2D position where the path starts |
agentRadius | The radius of the given agent. |
|
inline |
Returns the index of the current portal (the portal the agent is currently headed towards.
|
inline |
Returns the identifier for the destination node on the path.
|
inline |
Returns the goal.
|
inline |
Returns the centroid of the goal.
unsigned int Menge::PortalPath::getNode | ( | ) | const |
Reports the node the agent is currently in.
unsigned int Menge::PortalPath::getNode | ( | size_t | i | ) | const |
Returns the id of the node traveled for the ith way point.
i | The index of the ith way point. |
|
inline |
Returns the ith portal.
i | The index of the desired portal |
|
inline |
Reports the number of portals in the path)
Vector2 Menge::PortalPath::getWayPoint | ( | size_t | i | ) | const |
Returns the position of the ith way point.
i | The index of the desired way point. |
|
inline |
Reports the number of way points in the path (not including the goal)
|
protected |
Something has changed and the path has to replan.
startPos | The starting position. |
startNode | The starting node (startPos should lie on this node.) |
endNode | The ending node. |
minWidth | The minimum width required for clearance. |
planner | The planner. ?? Extra stuff to do the funnel computation. |
void Menge::PortalPath::setPreferredDirection | ( | const Agents::BaseAgent * | agent, |
float | headingCos, | ||
Agents::PrefVelocity & | pVel | ||
) |
Sets the directions in the preferred velocity from the path.
agent | The agent for which the preferred direction should be computed. |
headingCos | The cosine of the maximum allowable angular deviation of heading (between planned and realized) before a new funnel algorithm is triggered to improve the path. |
pVel | The preferred velocity whose directions are to be set. |
void Menge::PortalPath::setWaypoints | ( | size_t | start, |
size_t | end, | ||
const Vector2 & | p0, | ||
const Vector2 & | dir | ||
) |
Set the waypoints for all of the indicated way portals.
start | The index of the first portal to set the crossing point. |
end | The index of the first portal to stop at. In other words, portals in the open interval [start, end) will receive crossing values. end will not be included. |
p0 | The way point. |
dir | The expected direction toward the way point along the path. |
unsigned int Menge::PortalPath::updateLocation | ( | const Agents::BaseAgent * | agent, |
const NavMeshPtr & | navMesh, | ||
const NavMeshLocalizer * | localizer, | ||
PathPlanner * | planner | ||
) |
Updates the location of the agent relative to the nav mesh.
agent | The agent whose location is updated. |
navMesh | The navmesh for making queries. |
localizer | The nav mesh localizer for identifying locations. |
planner | The nav mesh path planner for creating new routes. |