|
| dtCrowd () |
|
| ~dtCrowd () |
|
bool | init (const int maxAgents, const float maxAgentRadius, dtNavMesh *nav) |
| Initializes the crowd. More...
|
|
void | setObstacleAvoidanceParams (const int idx, const dtObstacleAvoidanceParams *params) |
| Sets the shared avoidance configuration for the specified index. More...
|
|
const dtObstacleAvoidanceParams * | getObstacleAvoidanceParams (const int idx) const |
| Gets the shared avoidance configuration for the specified index. More...
|
|
const dtCrowdAgent * | getAgent (const int idx) |
| Gets the specified agent from the pool. More...
|
|
dtCrowdAgent * | getEditableAgent (const int idx) |
| Gets the specified agent from the pool. More...
|
|
int | getAgentCount () const |
| The maximum number of agents that can be managed by the object. More...
|
|
int | addAgent (const float *pos, const dtCrowdAgentParams *params) |
| Adds a new agent to the crowd. More...
|
|
void | updateAgentParameters (const int idx, const dtCrowdAgentParams *params) |
| Updates the specified agent's configuration. More...
|
|
void | removeAgent (const int idx) |
| Removes the agent from the crowd. More...
|
|
bool | requestMoveTarget (const int idx, dtPolyRef ref, const float *pos) |
| Submits a new move request for the specified agent. More...
|
|
bool | requestMoveVelocity (const int idx, const float *vel) |
| Submits a new move request for the specified agent. More...
|
|
bool | resetMoveTarget (const int idx) |
| Resets any request for the specified agent. More...
|
|
int | getActiveAgents (dtCrowdAgent **agents, const int maxAgents) |
| Gets the active agents int the agent pool. More...
|
|
void | update (const float dt, dtCrowdAgentDebugInfo *debug) |
| Updates the steering and positions of all agents. More...
|
|
const dtQueryFilter * | getFilter (const int i) const |
| Gets the filter used by the crowd. More...
|
|
dtQueryFilter * | getEditableFilter (const int i) |
| Gets the filter used by the crowd. More...
|
|
const float * | getQueryHalfExtents () const |
| Gets the search halfExtents [(x, y, z)] used by the crowd for query operations. More...
|
|
const float * | getQueryExtents () const |
| Same as getQueryHalfExtents. More...
|
|
int | getVelocitySampleCount () const |
| Gets the velocity sample count. More...
|
|
const dtProximityGrid * | getGrid () const |
| Gets the crowd's proximity grid. More...
|
|
const dtPathQueue * | getPathQueue () const |
| Gets the crowd's path request queue. More...
|
|
const dtNavMeshQuery * | getNavMeshQuery () const |
| Gets the query object used by the crowd. More...
|
|
Provides local steering behaviors for a group of agents.
This is the core class of the Crowd module. See the Crowd documentation for a summary of the crowd features.
A common method for setting up the crowd is as follows:
- Allocate the crowd using dtAllocCrowd.
- Initialize the crowd using init().
- Set the avoidance configurations using setObstacleAvoidanceParams().
- Add agents using addAgent() and make an initial movement request using requestMoveTarget().
A common process for managing the crowd is as follows:
- Call update() to allow the crowd to manage its agents.
- Retrieve agent information using getActiveAgents().
- Make movement requests using requestMoveTarget() when movement goal changes.
- Repeat every frame.
Some agent configuration settings can be updated using updateAgentParameters(). But the crowd owns the agent position. So it is not possible to update an active agent's position. If agent position must be fed back into the crowd, the agent must be removed and re-added.
Notes:
- Path related information is available for newly added agents only after an update() has been performed.
- Agent objects are kept in a pool and re-used. So it is important when using agent objects to check the value of dtCrowdAgent::active to determine if the agent is actually in use or not.
- This class is meant to provide 'local' movement. There is a limit of 256 polygons in the path corridor.
So it is not meant to provide automatic pathfinding services over long distances.
- See also
- dtAllocCrowd(), dtFreeCrowd(), init(), dtCrowdAgent