| 185 | } |
| 186 | |
| 187 | static 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 | |
| 220 | static int addToOptQueue(dtCrowdAgent* newag, dtCrowdAgent** agents, const int nagents, const int maxAgents) |
| 221 | { |
no test coverage detected