Class responsible for tracking agent relatinoships to the navigation mesh: its current location and its path.
More...
#include <NavMeshLocalizer.h>
|
static Resource * | load (const std::string &fileName) |
| Parses a navigation mesh localizer definition and returns a pointer to it. More...
|
|
|
static const std::string | LABEL |
| The unique label for this data type to be used with resource management.
|
|
|
NavMeshPtr | _navMesh |
| The underlying navigation mesh to perform operations on.
|
|
bool | _trackAll |
| Determines if just the position of agents on paths is tracked (true) or the position of all agents (false).
|
|
PathPlanner * | _planner |
| Optional planner. This is only non-NULL if there is a PathPlanner created either by a NavMeshGoalGenerator or NavMeshVelComponent.
|
|
HASH_MAP< size_t, NavMeshLocation > | _locations |
| A mapping from agent id to the agent's location w.r.t. the navigation mesh.
|
|
ReadersWriterLock | _locLock |
| Lock for location map (_locations).
|
|
OccupantSet * | _nodeOccupants |
| A mapping from node id to agent ids, specifying the population of each agent.
|
|
const std::string | _fileName |
| The file which contains the resource's data.
|
|
int | _refCount |
| The number of data wrappers using this managed data.
|
|
SimpleLock | _lock |
| Simple lock to handle reference counts safely.
|
|
Class responsible for tracking agent relatinoships to the navigation mesh: its current location and its path.
Menge::NavMeshLocalizer::NavMeshLocalizer |
( |
const std::string & |
name | ) |
|
Constructor.
- Parameters
-
name | The name of the underlying navigation mesh. |
void Menge::NavMeshLocalizer::clearPath |
( |
size_t |
agentID | ) |
|
Clears the path for the given agent.
- Parameters
-
agentID | The index of the agent whose path is to be cleared. |
unsigned int Menge::NavMeshLocalizer::findNodeBlind |
( |
const Vector2 & |
p, |
|
|
float |
tgtElev = 1e5f |
|
) |
| const |
|
protected |
Determines which node an agent is in without previous knowledge.
- Parameters
-
p | Given the initial position, returns the node this point lies on (with the highest elevation). |
tgtElev | The target elevation for the agent. The default value leads to the highest node being selected. But giving an alternative value will change it to select a node nearest the current elevation. |
- Returns
- The index of the node on which the point lies closest in elevation. to the tgtElev value. If the point does not lie on any mesh node, NavMeshLocation::NO_NODE is returned.
const NavMeshPtr Menge::NavMeshLocalizer::getNavMesh |
( |
| ) |
const |
|
inline |
Returns a const pointer to the underlying navigation mesh.
- Returns
- The pointer to the navigation mesh.
NavMeshPtr Menge::NavMeshLocalizer::getNavMesh |
( |
| ) |
|
|
inline |
Returns a pointer to the underlying navigation mesh.
- Returns
- The pointer to the navigation mesh.
unsigned int Menge::NavMeshLocalizer::getNode |
( |
const Agents::BaseAgent * |
agent | ) |
const |
Reports the node the agent is currently in.
- Parameters
-
agent | The agent whose position relative to the nav mesh is returned. |
- Returns
- The index of the node associated with this location. If the location is not on a node, NavMeshLocation::NO_NODE is returned.
unsigned int Menge::NavMeshLocalizer::getNode |
( |
const Vector2 & |
p | ) |
const |
Reports the node with the highest elevation for the given point.
- Parameters
-
p | The point to test against the mesh. |
- Returns
- The index of the node associated with this location. If the location is not on a node, NavMeshLocation::NO_NODE is returned.
const NavMeshNode Menge::NavMeshLocalizer::getNode |
( |
unsigned int |
i | ) |
|
|
inline |
Returns the NavMeshNode of the given id.
- Parameters
-
i | The index of the desired mesh node. |
- Returns
- A copy the specified mesh node.
const OccupantSet* Menge::NavMeshLocalizer::getNodeOccupants |
( |
unsigned int |
nodeID | ) |
const |
|
inline |
Returns the occupant set for the given node.
- Parameters
-
nodeID | The index of the desired node. |
- Returns
- A pointer to the OccupantSet of the given node.
PortalPath * Menge::NavMeshLocalizer::getPath |
( |
size_t |
id | ) |
|
Retrieves the path for the given agent.
- Parameters
-
id | The identifier for the agent. |
- Returns
- A pointer to the PortalPath for the agent. If the agent is not currently following a path, NULL is returned.
Get the planner for the localizer.
- Returns
- A pointer to the planner
Resource * Menge::NavMeshLocalizer::load |
( |
const std::string & |
fileName | ) |
|
|
static |
void Menge::NavMeshLocalizer::setNode |
( |
size_t |
agentID, |
|
|
unsigned int |
nodeID |
|
) |
| |
Sets the location of the agent to be anode.
- Parameters
-
agentID | The index of the agent to update. |
nodeID | The index of the node. |
void Menge::NavMeshLocalizer::setPath |
( |
size_t |
agentID, |
|
|
PortalPath * |
path |
|
) |
| |
Sets the path for the given agent.
- Parameters
-
agentID | The index of the agent for whom the path is set. |
path | The path for the agent. |
void Menge::NavMeshLocalizer::setPlanner |
( |
PathPlanner * |
planner | ) |
|
|
inline |
Set the path planner for the localizer.
- Parameters
-
void Menge::NavMeshLocalizer::setTrackAll |
( |
| ) |
|
|
inline |
Sets the tracking status of the localizer to all agents.
By default, the localizer only tracks agents on paths. Calling this function will cause all agents to be tracked, even if they are not currently following navigation mesh paths. However, it can't be set back.
unsigned int Menge::NavMeshLocalizer::testNeighbors |
( |
const NavMeshNode & |
node, |
|
|
const Vector2 & |
p |
|
) |
| const |
|
protected |
Determines if the point is in a neighboring node to the given node.
- Parameters
-
node | The navigation mesh node whose neighbors need to be tested. |
p | The point to test against the neighboring nodes. |
- Returns
- The index of the neighboring node which contains p. If p does not lie on any neighboring mesh node, NavMeshLocation::NO_NODE is returned.
unsigned int Menge::NavMeshLocalizer::updateLocation |
( |
const Agents::BaseAgent * |
agent, |
|
|
bool |
force = false |
|
) |
| const |
Updates the location of the agent relative to the nav mesh.
- Parameters
-
agent | The agent whose location is updated. |
force | Force causes the update regardless of whether the localizer is set to track all or not. |
- Returns
- The index of the node in which the agent is found. If it is not on the navigation mesh, NavMeshLocation::NO_NODE is returned.
The documentation for this class was generated from the following files:
- src/menge/MengeCore/resources/NavMeshLocalizer.h
- src/menge/MengeCore/resources/NavMeshLocalizer.cpp