MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / update

Method update

Source/ThirdParty/recastnavigation/DetourCrowd.cpp:1046–1449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044}
1045
1046void dtCrowd::update(const float dt, dtCrowdAgentDebugInfo* debug)
1047{
1048 m_velocitySampleCount = 0;
1049
1050 const int debugIdx = debug ? debug->idx : -1;
1051
1052 dtCrowdAgent** agents = m_activeAgents;
1053 int nagents = getActiveAgents(agents, m_maxAgents);
1054
1055 // Check that all agents still have valid paths.
1056 checkPathValidity(agents, nagents, dt);
1057
1058 // Update async move request and path finder.
1059 updateMoveRequest(dt);
1060
1061 // Optimize path topology.
1062 updateTopologyOptimization(agents, nagents, dt);
1063
1064 // Register agents to proximity grid.
1065 m_grid->clear();
1066 for (int i = 0; i < nagents; ++i)
1067 {
1068 dtCrowdAgent* ag = agents[i];
1069 const float* p = ag->npos;
1070 const float r = ag->params.radius;
1071 m_grid->addItem((unsigned short)i, p[0]-r, p[2]-r, p[0]+r, p[2]+r);
1072 }
1073
1074 // Get nearby navmesh segments and agents to collide with.
1075 for (int i = 0; i < nagents; ++i)
1076 {
1077 dtCrowdAgent* ag = agents[i];
1078 if (ag->state != DT_CROWDAGENT_STATE_WALKING)
1079 continue;
1080
1081 // Update the collision boundary after certain distance has been passed or
1082 // if it has become invalid.
1083 const float updateThr = ag->params.collisionQueryRange*0.25f;
1084 if (dtVdist2DSqr(ag->npos, ag->boundary.getCenter()) > dtSqr(updateThr) ||
1085 !ag->boundary.isValid(m_navquery, &m_filters[ag->params.queryFilterType]))
1086 {
1087 ag->boundary.update(ag->corridor.getFirstPoly(), ag->npos, ag->params.collisionQueryRange,
1088 m_navquery, &m_filters[ag->params.queryFilterType]);
1089 }
1090 // Query neighbour agents
1091 ag->nneis = getNeighbours(ag->npos, ag->params.height, ag->params.collisionQueryRange,
1092 ag, ag->neis, DT_CROWDAGENT_MAX_NEIGHBOURS,
1093 agents, nagents, m_grid);
1094 for (int j = 0; j < ag->nneis; j++)
1095 ag->neis[j].idx = getAgentIndex(agents[ag->neis[j].idx]);
1096 }
1097
1098 // Find next corner to steer to.
1099 for (int i = 0; i < nagents; ++i)
1100 {
1101 dtCrowdAgent* ag = agents[i];
1102
1103 if (ag->state != DT_CROWDAGENT_STATE_WALKING)

Callers 2

updateMoveRequestMethod · 0.45
UpdateMethod · 0.45

Calls 15

dtVdist2DSqrFunction · 0.85
dtSqrFunction · 0.85
getNeighboursFunction · 0.85
dtMinFunction · 0.85
dtVcopyFunction · 0.85
dtVsetFunction · 0.85
overOffmeshConnectionFunction · 0.85
dtVdist2DFunction · 0.85
dtVlenFunction · 0.85
calcSmoothSteerDirectionFunction · 0.85
getDistanceToGoalFunction · 0.85

Tested by

no test coverage detected