Menge
Modular Pedestrian Simulation Framework for Research and Development

The navigation mesh adjacency graph edge. More...
#include <NavMeshEdge.h>
Public Member Functions  
NavMeshEdge ()  
Constructor.  
~NavMeshEdge ()  
Destructor.  
Vector2  getP0 () const 
Returns the first edge point. More...  
Vector2  getP0 (float dist) const 
Returns a point inset from the first end point. More...  
Vector2  getP1 () const 
Returns the second edge point. More...  
Vector2  getP1 (float dist) const 
Returns a point inset from the second end point. More...  
Vector2  getDirection () const 
Returns the direction of the edge. More...  
NavMeshNode *  getFirstNode () const 
Returns the first attached NavMeshNode. More...  
NavMeshNode *  getOtherByID (unsigned int id) const 
Returns a pointer to the node on the opposite end of the edge from the given node (by id). More...  
NavMeshNode *  getOtherByPtr (const NavMeshNode *node) 
Returns a pointer to the node on the opposite end of the edge from the given node (by pointer). More...  
const NavMeshNode *  getOtherByPtr (const NavMeshNode *node) const 
Returns a const pointer to the node on the opposite end of the edge from the given node (by pointer). More...  
void  setPoint (const Vector2 &p) 
Sets the edge's point value. More...  
void  setDirection (const Vector2 &d) 
Sets the edge's direction value. More...  
void  setWidth (float w) 
Sets the edge's width value. More...  
float  getWidth () const 
Reports the width of the edge. More...  
void  setNodes (NavMeshNode *n0, NavMeshNode *n1) 
Sets the connected node pointers. More...  
Vector2  getPoint (float t) const 
Selects a point along the edge. More...  
bool  pointClear (const Vector2 &pos, float radius, float param) const 
Reports if the point q = _point + param * _dir is clear for an agent with the given radius positioned at pos. "Clear" means a straightline path will not cause it to intersect the ends of the edge. More...  
Vector2  targetPoint (const Vector2 &pos, float radius) const 
Computes a target point with respect to this edge. The target point is a point along the line of the edge to which the agent with the given radius can head straight towards and be guaranteed NOT to intersect with the end points of the edge. It also leads the agent to get closer to crossing the edge. More...  
Vector2  getClearDirection (const Vector2 &pos, float radius, const Vector2 &dir) const 
Computes the collisionfree velocity towards the portal based on the agent radius and the preferred direction. If the preferred direction is collision free, it is returned. Otherwise, the "best" collisionfree approximation of that direction is returned. More...  
void  setClearDirections (const Vector2 &pos, float radius, const Vector2 &dir, Agents::PrefVelocity &pVel) const 
Sets the directions of a preferred velocity that passes through the edge biased towards the indicated direction. More...  
float  getSqDist (const Vector2 &pt) const 
Reports the squared distance to the edge from the given point. More...  
float  getSqDist (const Vector2 &pt, Vector2 &nearPt) const 
Reports the squared distance to the edge from the given point and gives the nearest point. More...  
float  getDist (const Vector2 &pt) const 
Reports the distance to the edge from the given point. More...  
float  getNodeDistance (float minWidth) 
Computes the widthdependent distance between the two nodes connected by this edge. If the edge width is narrower than the given minimum width the distance is "infinite" (indicated by 1). Otherwise it is the distance between node centers. More...  
float  getNodeDistance () const 
Return the Euclidian distance between the two nodes this edge connects. More...  
bool  loadFromAscii (std::ifstream &f, Vector2 *vertices) 
Sets the edge properties from an edge definition in the given ascii file stream. More...  
bool  pointOnLeft (unsigned int id) const 
Reports if _point in this edge is on the left for the node with the given id. More...  
bool  pointOnLeft (const NavMeshNode *node) const 
Reports if _point in this edge is on the left when looked at from within the given node. More...  
Protected Attributes  
Vector2  _point 
The point that defines the portal geometry. The portal is defined as p(t) = _point + t * _dir, t in the range [0, _width].  
Vector2  _dir 
The unitlength direction of the portal. See _point for how the portal is defined w.r.t. this field member.  
float  _width 
The width of the portal.  
float  _distance 
The "distance" between the two nodes connected by this edge. Used to estimate the cost of a path (the length of the path).  
NavMeshNode *  _node0 
A pointer to the first nav mesh node connected by this edge. When standing in this node, the edge's _point is on the left.  
NavMeshNode *  _node1 
A pointer to the second nav mesh node connected by this edge. When standing in this node, the edge's _point is on the right.  
Friends  
class  NavMesh 
The navigation mesh adjacency graph edge.
It is comprised of two parts: the portal geometry and the logical graph connectivity. A NavMeshEdge exists because two navigation mesh polygons share a common edge. The portal geometry is the edge. The graph connectivity indicates that the two mesh polygons (nodes) are connected in the logical graph.
Vector2 Menge::NavMeshEdge::getClearDirection  (  const Vector2 &  pos, 
float  radius,  
const Vector2 &  dir  
)  const 
Computes the collisionfree velocity towards the portal based on the agent radius and the preferred direction. If the preferred direction is collision free, it is returned. Otherwise, the "best" collisionfree approximation of that direction is returned.
pos  The position of the agent. 
radius  The radius of the agent. 
dir  Preferred direction of the agent. Direction is NOT assumed to be of unitlength. 

inline 
Returns the direction of the edge.

inline 
Reports the distance to the edge from the given point.
pt  The point to compute from. 

inline 
Returns the first attached NavMeshNode.
float Menge::NavMeshEdge::getNodeDistance  (  float  minWidth  ) 
Computes the widthdependent distance between the two nodes connected by this edge. If the edge width is narrower than the given minimum width the distance is "infinite" (indicated by 1). Otherwise it is the distance between node centers.
minWidth  The minimum required width. 

inline 
Return the Euclidian distance between the two nodes this edge connects.
NavMeshNode * Menge::NavMeshEdge::getOtherByID  (  unsigned int  id  )  const 
Returns a pointer to the node on the opposite end of the edge from the given node (by id).
If the given node is not actually adjacent to the edge, then the first adjacent node is returned.
id  The identifier of the operand node. 
NavMeshNode * Menge::NavMeshEdge::getOtherByPtr  (  const NavMeshNode *  node  ) 
Returns a pointer to the node on the opposite end of the edge from the given node (by pointer).
If the given node is not actually adjacent to the edge, then the first adjacent node is returned.
node  A pointer to the operand node. 
const NavMeshNode * Menge::NavMeshEdge::getOtherByPtr  (  const NavMeshNode *  node  )  const 
Returns a const pointer to the node on the opposite end of the edge from the given node (by pointer).
If the given node is not actually adjacent to the edge, then the first adjacent node is returned.
node  A pointer to the operand node. 

inline 
Returns the first edge point.

inline 
Returns a point inset from the first end point.
dist  The inset distance. 

inline 
Returns the second edge point.

inline 
Returns a point inset from the second end point.
dist  The inset distance. 

inline 
Selects a point along the edge.
t  The parameter from _point in the edge direction. 
float Menge::NavMeshEdge::getSqDist  (  const Vector2 &  pt  )  const 
Reports the squared distance to the edge from the given point.
pt  The point to compute from. 
Reports the squared distance to the edge from the given point and gives the nearest point.
pt  The point to compute from. 
nearPt  The nearest point to pt on the edge. The values of this vector will be changed by the function 

inline 
Reports the width of the edge.
bool Menge::NavMeshEdge::loadFromAscii  (  std::ifstream &  f, 
Vector2 *  vertices  
) 
Sets the edge properties from an edge definition in the given ascii file stream.
f  The input file stream. 
vertices  The array of vertices into which the definition indexes. 
bool Menge::NavMeshEdge::pointClear  (  const Vector2 &  pos, 
float  radius,  
float  param  
)  const 
Reports if the point q = _point + param * _dir is clear for an agent with the given radius positioned at pos. "Clear" means a straightline path will not cause it to intersect the ends of the edge.
pos  The position of the agent. 
radius  The radius of the agent. 
param  The parameter, along the edge's direction, of the desired goal point. 
bool Menge::NavMeshEdge::pointOnLeft  (  unsigned int  id  )  const 
Reports if _point in this edge is on the left for the node with the given id.
id  The id of the node to test. (The id is assumed to be connected. It is only checked in debug mode.) 
bool Menge::NavMeshEdge::pointOnLeft  (  const NavMeshNode *  node  )  const 
Reports if _point in this edge is on the left when looked at from within the given node.
node  The pointer to the node to test. (The id is assumed to be connected. It is only checked in debug mode.) 
void Menge::NavMeshEdge::setClearDirections  (  const Vector2 &  pos, 
float  radius,  
const Vector2 &  dir,  
Agents::PrefVelocity &  pVel  
)  const 
Sets the directions of a preferred velocity that passes through the edge biased towards the indicated direction.
If approaching the portal obliquely, the preferred direction may not provide sufficient clearance. In this case, the direction is changed so the agent makes progress toward the portal without colliding with the portal limits.
At the same time, sets the limits of the preferred velocity based on the actual clearance.
pos  The position of the agent. 
radius  The radius of the agent. 
dir  Preferred direction of the agent. Direction is NOT assumed to be of unitlength. 
pVel  The preferred velocity whose directions are set. 

inline 
Sets the edge's direction value.
d  The direction value to set. It is assumed to be normalized and is not tested. 

inline 
Sets the connected node pointers.
n0  The pointer to the first connected node. 
n1  The pointer to the second connected node. 

inline 
Sets the edge's point value.
p  The point value to set. 

inline 
Sets the edge's width value.
w  The width value to set. 
Computes a target point with respect to this edge. The target point is a point along the line of the edge to which the agent with the given radius can head straight towards and be guaranteed NOT to intersect with the end points of the edge. It also leads the agent to get closer to crossing the edge.
pos  The position from which to compute nearest point. 
radius  The radius of the agent – required clearance. 