Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Menge::PortalPath Class Reference

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::GoalgetGoal () 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 WayPortalgetPortal (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

Menge::PortalPath::PortalPath ( const Vector2 startPos,
const BFSM::Goal goal,
const PortalRoute route,
float  agentRadius 
)

Constructor.

Parameters
startPosThe 2D position where the path starts
goalThe goal (whose centroid lies in the final polygon).
routeThe route the path follows
agentRadiusThe radius of the given agent.

Member Function Documentation

void Menge::PortalPath::computeCrossing ( const Vector2 startPos,
float  agentRadius 
)
protected

Computes the crossing values for each portal.

Parameters
startPosThe 2D position where the path starts
agentRadiusThe radius of the given agent.
size_t Menge::PortalPath::getCurrentPortal ( ) const
inline

Returns the index of the current portal (the portal the agent is currently headed towards.

Returns
The index of the current portal.
unsigned int Menge::PortalPath::getEndNode ( ) const
inline

Returns the identifier for the destination node on the path.

Returns
The destination node's index.
const BFSM::Goal* Menge::PortalPath::getGoal ( ) const
inline

Returns the goal.

Returns
The goal.
Vector2 Menge::PortalPath::getGoalCentroid ( ) const
inline

Returns the centroid of the goal.

Returns
The goal's centroid.
unsigned int Menge::PortalPath::getNode ( ) const

Reports the node the agent is currently in.

Returns
The index of the node associated with this location. If the location is not on a node, PortalPath::NO_NODE is returned.
unsigned int Menge::PortalPath::getNode ( size_t  i) const

Returns the id of the node traveled for the ith way point.

Parameters
iThe index of the ith way point.
Returns
The identifier of the node the agent would be travelling on while making progress toward the ith point.
const WayPortal* Menge::PortalPath::getPortal ( size_t  i) const
inline

Returns the ith portal.

Parameters
iThe index of the desired portal
Returns
A pointer to the ith portal.
size_t Menge::PortalPath::getPortalCount ( ) const
inline

Reports the number of portals in the path)

Returns
The number of portals.
Vector2 Menge::PortalPath::getWayPoint ( size_t  i) const

Returns the position of the ith way point.

Parameters
iThe index of the desired way point.
Returns
The 2d position of the desired way point.
size_t Menge::PortalPath::getWayPointCount ( ) const
inline

Reports the number of way points in the path (not including the goal)

Returns
The number of points (not including the goal).
void Menge::PortalPath::replan ( const Vector2 startPos,
unsigned int  startNode,
unsigned int  endNode,
float  minWidth,
PathPlanner planner 
)
protected

Something has changed and the path has to replan.

Parameters
startPosThe starting position.
startNodeThe starting node (startPos should lie on this node.)
endNodeThe ending node.
minWidthThe minimum width required for clearance.
plannerThe 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.

Parameters
agentThe agent for which the preferred direction should be computed.
headingCosThe cosine of the maximum allowable angular deviation of heading (between planned and realized) before a new funnel algorithm is triggered to improve the path.
pVelThe 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.

Parameters
startThe index of the first portal to set the crossing point.
endThe 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.
p0The way point.
dirThe 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.

Parameters
agentThe agent whose location is updated.
navMeshThe navmesh for making queries.
localizerThe nav mesh localizer for identifying locations.
plannerThe nav mesh path planner for creating new routes.
Returns
The index of the node the agent is in.

The documentation for this class was generated from the following files: