45 #ifndef __NAV_MESH_LOCALIZER_H__
46 #define __NAV_MESH_LOCALIZER_H__
50 #include "mengeCommon.h"
102 void setNode(
unsigned int nodeID );
209 virtual const std::string &
getLabel()
const {
return LABEL; }
228 unsigned int getNode(
const Vector2 & p )
const;
253 void setPath(
size_t agentID,
PortalPath * path );
260 void clearPath(
size_t agentID );
268 void setNode(
size_t agentID,
unsigned int nodeID );
289 unsigned int updateLocation(
const Agents::BaseAgent * agent,
bool force=
false )
const;
311 const OccupantSet *
getNodeOccupants(
unsigned int nodeID )
const {
return &_nodeOccupants[ nodeID ]; }
343 static Resource * load(
const std::string & fileName );
403 unsigned int findNodeBlind(
const Vector2 & p,
float tgtElev=1e5f )
const;
437 #endif // __NAV_MESH_LOCALIZER_H__
Class responsible for tracking agent relatinoships to the navigation mesh: its current location and i...
Definition: NavMeshLocalizer.h:186
void setTrackAll()
Sets the tracking status of the localizer to all agents.
Definition: NavMeshLocalizer.h:278
NavMeshLocation(unsigned int nodeID)
Constructor Initializes the location to being a node id.
Definition: NavMeshLocalizer.h:83
NavMeshLocalizerPtr loadNavMeshLocalizer(const std::string &fileName, bool usePlanner)
Loads the navigation mesh of the given name.
Definition: NavMeshLocalizer.cpp:292
void setNode(unsigned int nodeID)
Sets the current position to being a node.
Definition: NavMeshLocalizer.cpp:56
OccupantSet * _nodeOccupants
A mapping from node id to agent ids, specifying the population of each agent.
Definition: NavMeshLocalizer.h:388
bool _hasPath
Determines interpretation of the location union. If true, _path contains a pointer. Otherwise, _nodeID is an index in the navigation mesh.
Definition: NavMeshLocalizer.h:155
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
PathPlanner * _planner
Optional planner. This is only non-NULL if there is a PathPlanner created either by a NavMeshGoalGene...
Definition: NavMeshLocalizer.h:369
bool isPath() const
Reports if the location is a path.
Definition: NavMeshLocalizer.h:131
NavMeshLocation()
Default constructor.
Definition: NavMeshLocalizer.h:75
NavMeshPtr getNavMesh()
Returns a pointer to the underlying navigation mesh.
Definition: NavMeshLocalizer.h:325
Class for indicating how the location of the agent is defined. Either by a portal path or a node...
Definition: NavMeshLocalizer.h:70
ReadersWriterLock _locLock
Lock for location map (_locations).
Definition: NavMeshLocalizer.h:382
std::set< size_t > OccupantSet
A collection of agent ids. It represents the population of each nav mesh node.
Definition: NavMeshLocalizer.h:170
unsigned int getNode() const
Reports the node the agent is currently in.
Definition: NavMeshLocalizer.cpp:77
virtual const std::string & getLabel() const
Returns a unique resource label to be used to identify different resource types which use the same un...
Definition: NavMeshLocalizer.h:209
The navigation mesh adjacency graph node. It corresponds to a convex polygon in the navigation mesh...
Definition: NavMeshNode.h:64
The definition of a readers-writer lock.
Definition: ReadersWriterLock.h:62
Basic class for managing on-disk resources.
Definition: Resource.h:98
const OccupantSet * getNodeOccupants(unsigned int nodeID) const
Returns the occupant set for the given node.
Definition: NavMeshLocalizer.h:311
void setPlanner(PathPlanner *planner)
Set the path planner for the localizer.
Definition: NavMeshLocalizer.h:296
A base exception for resources to throw.
Definition: Resource.h:58
bool isNode() const
Reports if the location is a node.
Definition: NavMeshLocalizer.h:138
OccupantSet::iterator OccupantSetItr
Iterator for an OccupantSet.
Definition: NavMeshLocalizer.h:175
Class for computing paths through a navigation mesh.
Definition: PathPlanner.h:133
OccupantSet::const_iterator OccupantSetCItr
Const iterator for an OccupantSet.
Definition: NavMeshLocalizer.h:180
NavMeshLocation(PortalPath *path)
Constructor Initializes the location to being a path. The NavMeshLocation takes responsibility for de...
Definition: NavMeshLocalizer.h:93
The definition of a readers-writer lock.
ResourcePtr< NavMeshLocalizer > NavMeshLocalizerPtr
forward declaration. See NavMeshLocalizer for more details
Definition: NavMeshLocalizerTask.h:56
PathPlanner * getPlanner()
Get the planner for the localizer.
Definition: NavMeshLocalizer.h:303
HASH_MAP< size_t, NavMeshLocation > _locations
A mapping from agent id to the agent's location w.r.t. the navigation mesh.
Definition: NavMeshLocalizer.h:377
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
bool _trackAll
Determines if just the position of agents on paths is tracked (true) or the position of all agents (f...
Definition: NavMeshLocalizer.h:363
The basic class for all on-disk resources.
void clearPath()
Clears the path (if any), maintaining the node location.
Definition: NavMeshLocalizer.cpp:66
The definition of a path through space comprising of a sequence of portals.
Definition: PortalPath.h:70
Defines the classes which maintain the navigation mesh data.
The namespace that contains the basic simulation mechanisms.
void setPath(PortalPath *path)
Sets the current position to being the given path.
Definition: NavMeshLocalizer.cpp:88
static const std::string LABEL
The unique label for this data type to be used with resource management.
Definition: NavMeshLocalizer.h:349
static const unsigned int NO_NODE
Signal for indicating that the position is NOT on the navigation mesh.
Definition: NavMeshLocalizer.h:161
const NavMeshNode getNode(unsigned int i)
Returns the NavMeshNode of the given id.
Definition: NavMeshLocalizer.h:236
NavMeshPtr _navMesh
The underlying navigation mesh to perform operations on.
Definition: NavMeshLocalizer.h:357
Defines the "node" of the adjacency graph in a navigation mesh. The node corresponds to a polygon in ...
const NavMeshPtr getNavMesh() const
Returns a const pointer to the underlying navigation mesh.
Definition: NavMeshLocalizer.h:318