22#include "DetourNavMeshQuery.h"
23#include "DetourObstacleAvoidance.h"
24#include "DetourLocalBoundary.h"
25#include "DetourPathCorridor.h"
26#include "DetourProximityGrid.h"
27#include "DetourPathQueue.h"
32static const int DT_CROWDAGENT_MAX_NEIGHBOURS = 6;
39static const int DT_CROWDAGENT_MAX_CORNERS = 4;
46static const int DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS = 8;
52static const int DT_CROWD_MAX_QUERY_FILTER_TYPE = 16;
105 DT_CROWDAGENT_TARGET_NONE = 0,
106 DT_CROWDAGENT_TARGET_FAILED,
107 DT_CROWDAGENT_TARGET_VALID,
108 DT_CROWDAGENT_TARGET_REQUESTING,
109 DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE,
110 DT_CROWDAGENT_TARGET_WAITING_FOR_PATH,
111 DT_CROWDAGENT_TARGET_VELOCITY,
171 float targetReplanTime;
177 float initPos[3], startPos[3], endPos[3];
187 DT_CROWD_ANTICIPATE_TURNS = 1,
188 DT_CROWD_OBSTACLE_AVOIDANCE = 2,
189 DT_CROWD_SEPARATION = 4,
197 float optStart[3], optEnd[3];
220 float m_agentPlacementHalfExtents[3];
224 float m_maxAgentRadius;
226 int m_velocitySampleCount;
230 void updateTopologyOptimization(
dtCrowdAgent** agents,
const int nagents,
const float dt);
231 void updateMoveRequest(
const float dt);
232 void checkPathValidity(
dtCrowdAgent** agents,
const int nagents,
const float dt);
234 inline int getAgentIndex(
const dtCrowdAgent* agent)
const {
return (
int)(agent - m_agents); }
236 bool requestMoveTargetReplan(
const int idx,
dtPolyRef ref,
const float* pos);
249 bool init(
const int maxAgents,
const float maxAgentRadius,
dtNavMesh* nav);
322 inline const dtQueryFilter*
getFilter(
const int i)
const {
return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : 0; }
Definition DetourCrowd.h:204
const dtProximityGrid * getGrid() const
Definition DetourCrowd.h:342
int getActiveAgents(dtCrowdAgent **agents, const int maxAgents)
Definition DetourCrowd.cpp:665
int getVelocitySampleCount() const
Definition DetourCrowd.h:338
bool init(const int maxAgents, const float maxAgentRadius, dtNavMesh *nav)
Definition DetourCrowd.cpp:382
const dtObstacleAvoidanceParams * getObstacleAvoidanceParams(const int idx) const
Definition DetourCrowd.cpp:471
bool requestMoveVelocity(const int idx, const float *vel)
Definition DetourCrowd.cpp:630
void updateAgentParameters(const int idx, const dtCrowdAgentParams *params)
Definition DetourCrowd.cpp:502
const dtQueryFilter * getFilter(const int i) const
Definition DetourCrowd.h:322
dtQueryFilter * getEditableFilter(const int i)
Definition DetourCrowd.h:326
bool resetMoveTarget(const int idx)
Definition DetourCrowd.cpp:647
int getAgentCount() const
Definition DetourCrowd.cpp:478
const float * getQueryExtents() const
Definition DetourCrowd.h:334
void setObstacleAvoidanceParams(const int idx, const dtObstacleAvoidanceParams *params)
Definition DetourCrowd.cpp:465
const float * getQueryHalfExtents() const
Definition DetourCrowd.h:330
bool requestMoveTarget(const int idx, dtPolyRef ref, const float *pos)
Definition DetourCrowd.cpp:608
dtCrowdAgent * getEditableAgent(const int idx)
Definition DetourCrowd.cpp:495
const dtPathQueue * getPathQueue() const
Definition DetourCrowd.h:346
const dtNavMeshQuery * getNavMeshQuery() const
Gets the query object used by the crowd.
Definition DetourCrowd.h:349
void update(const float dt, dtCrowdAgentDebugInfo *debug)
Definition DetourCrowd.cpp:1047
int addAgent(const float *pos, const dtCrowdAgentParams *params)
Definition DetourCrowd.cpp:512
void removeAgent(const int idx)
Definition DetourCrowd.cpp:573
const dtCrowdAgent * getAgent(const int idx)
Definition DetourCrowd.cpp:486
Definition DetourLocalBoundary.h:26
Definition DetourNavMeshQuery.h:166
Definition DetourNavMesh.h:339
Definition DetourObstacleAvoidance.h:39
Definition DetourObstacleAvoidance.h:98
Definition DetourPathCorridor.h:27
Definition DetourPathQueue.h:30
Definition DetourProximityGrid.h:23
Definition DetourNavMeshQuery.h:36
CrowdAgentState
Definition DetourCrowd.h:66
void dtFreeCrowd(dtCrowd *ptr)
Definition DetourCrowd.cpp:41
UpdateFlags
Definition DetourCrowd.h:186
dtCrowd * dtAllocCrowd()
Definition DetourCrowd.cpp:34
@ DT_CROWDAGENT_STATE_OFFMESH
The agent is traversing an off-mesh connection.
Definition DetourCrowd.h:69
@ DT_CROWDAGENT_STATE_WALKING
The agent is traversing a normal navigation mesh polygon.
Definition DetourCrowd.h:68
@ DT_CROWDAGENT_STATE_INVALID
The agent is not in a valid state.
Definition DetourCrowd.h:67
@ DT_CROWD_OPTIMIZE_TOPO
Use dtPathCorridor::optimizePathTopology() to optimize the agent path.
Definition DetourCrowd.h:191
@ DT_CROWD_OPTIMIZE_VIS
Use dtPathCorridor::optimizePathVisibility() to optimize the agent path.
Definition DetourCrowd.h:190
unsigned int dtPolyRef
Definition DetourNavMesh.h:48
Definition DetourCrowd.h:175
Definition DetourCrowd.h:195
Definition DetourCrowd.h:75
void * userData
User defined data attached to the agent.
Definition DetourCrowd.h:100
float maxSpeed
Maximum allowed speed. [Limit: >= 0].
Definition DetourCrowd.h:79
float maxAcceleration
Maximum allowed acceleration. [Limit: >= 0].
Definition DetourCrowd.h:78
float collisionQueryRange
Defines how close a collision element must be before it is considered for steering behaviors....
Definition DetourCrowd.h:82
float separationWeight
How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0].
Definition DetourCrowd.h:87
unsigned char updateFlags
Flags that impact steering behavior. (See: UpdateFlags)
Definition DetourCrowd.h:90
float height
Agent height. [Limit: > 0].
Definition DetourCrowd.h:77
float radius
Agent radius. [Limit: >= 0].
Definition DetourCrowd.h:76
float pathOptimizationRange
The path visibility optimization range. [Limit: > 0].
Definition DetourCrowd.h:84
unsigned char obstacleAvoidanceType
Definition DetourCrowd.h:94
unsigned char queryFilterType
The index of the query filter used by this agent.
Definition DetourCrowd.h:97
Definition DetourCrowd.h:117
unsigned char state
The type of mesh polygon the agent is traversing. (See: CrowdAgentState)
Definition DetourCrowd.h:122
unsigned char cornerFlags[DT_CROWDAGENT_MAX_CORNERS]
The local path corridor corner flags. (See: dtStraightPathFlags) [(flags) * ncorners].
Definition DetourCrowd.h:158
dtPolyRef targetRef
Target polyref of the movement request.
Definition DetourCrowd.h:167
float targetPos[3]
Target position of the movement request (or velocity in case of DT_CROWDAGENT_TARGET_VELOCITY).
Definition DetourCrowd.h:168
dtPathQueueRef targetPathqRef
Path finder ref.
Definition DetourCrowd.h:169
unsigned char targetState
State of the movement request.
Definition DetourCrowd.h:166
int nneis
The number of neighbors.
Definition DetourCrowd.h:140
float vel[3]
The actual velocity of the agent. The change from nvel -> vel is constrained by max acceleration....
Definition DetourCrowd.h:149
bool targetReplan
Flag indicating that the current path is being replanned.
Definition DetourCrowd.h:170
bool active
True if the agent is active, false if the agent is in an unused slot in the agent pool.
Definition DetourCrowd.h:119
dtPathCorridor corridor
The path corridor the agent is using.
Definition DetourCrowd.h:128
dtLocalBoundary boundary
The local boundary data for the agent.
Definition DetourCrowd.h:131
float disp[3]
A temporary value used to accumulate agent displacement during iterative collision resolution....
Definition DetourCrowd.h:146
float topologyOptTime
Time since the agent's path corridor was optimized.
Definition DetourCrowd.h:134
int ncorners
The number of corners.
Definition DetourCrowd.h:164
dtCrowdNeighbour neis[DT_CROWDAGENT_MAX_NEIGHBOURS]
The known neighbors of the agent.
Definition DetourCrowd.h:137
float nvel[3]
The desired velocity adjusted by obstacle avoidance, calculated from scratch each frame....
Definition DetourCrowd.h:148
dtPolyRef cornerPolys[DT_CROWDAGENT_MAX_CORNERS]
The reference id of the polygon being entered at the corner. [(polyRef) * ncorners].
Definition DetourCrowd.h:161
float cornerVerts[DT_CROWDAGENT_MAX_CORNERS *3]
The local path corridor corners for the agent. (Staight path.) [(x, y, z) * ncorners].
Definition DetourCrowd.h:155
float npos[3]
The current agent position. [(x, y, z)].
Definition DetourCrowd.h:145
float desiredSpeed
The desired speed.
Definition DetourCrowd.h:143
dtCrowdAgentParams params
The agent's configuration parameters.
Definition DetourCrowd.h:152
float dvel[3]
The desired velocity of the agent. Based on the current path, calculated from scratch each frame....
Definition DetourCrowd.h:147
bool partial
True if the agent has valid path (targetState == DT_CROWDAGENT_TARGET_VALID) and the path does not le...
Definition DetourCrowd.h:125
Definition DetourCrowd.h:58
int idx
The index of the neighbor in the crowd.
Definition DetourCrowd.h:59
float dist
The distance between the current agent and the neighbor.
Definition DetourCrowd.h:60
Definition DetourObstacleAvoidance.h:84