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

Function getNeighbours

Source/ThirdParty/recastnavigation/DetourCrowd.cpp:187–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static int getNeighbours(const float* pos, const float height, const float range,
188 const dtCrowdAgent* skip, dtCrowdNeighbour* result, const int maxResult,
189 dtCrowdAgent** agents, const int /*nagents*/, dtProximityGrid* grid)
190{
191 int n = 0;
192
193 static const int MAX_NEIS = 32;
194 unsigned short ids[MAX_NEIS];
195 int nids = grid->queryItems(pos[0]-range, pos[2]-range,
196 pos[0]+range, pos[2]+range,
197 ids, MAX_NEIS);
198
199 for (int i = 0; i < nids; ++i)
200 {
201 const dtCrowdAgent* ag = agents[ids[i]];
202
203 if (ag == skip) continue;
204
205 // Check for overlap.
206 float diff[3];
207 dtVsub(diff, pos, ag->npos);
208 if (dtMathFabsf(diff[1]) >= (height+ag->params.height)/2.0f)
209 continue;
210 diff[1] = 0;
211 const float distSqr = dtVlenSqr(diff);
212 if (distSqr > dtSqr(range))
213 continue;
214
215 n = addNeighbour(ids[i], distSqr, result, n, maxResult);
216 }
217 return n;
218}
219
220static int addToOptQueue(dtCrowdAgent* newag, dtCrowdAgent** agents, const int nagents, const int maxAgents)
221{

Callers 1

updateMethod · 0.85

Calls 6

dtVsubFunction · 0.85
dtMathFabsfFunction · 0.85
dtVlenSqrFunction · 0.85
dtSqrFunction · 0.85
addNeighbourFunction · 0.85
queryItemsMethod · 0.80

Tested by

no test coverage detected