| 315 | } |
| 316 | |
| 317 | dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const float* centerPos, const float maxRadius, |
| 318 | const dtQueryFilter* filter, float (*frand)(), |
| 319 | dtPolyRef* randomRef, float* randomPt) const |
| 320 | { |
| 321 | dtAssert(m_nav); |
| 322 | dtAssert(m_nodePool); |
| 323 | dtAssert(m_openList); |
| 324 | |
| 325 | // Validate input |
| 326 | if (!m_nav->isValidPolyRef(startRef) || |
| 327 | !centerPos || !dtVisfinite(centerPos) || |
| 328 | maxRadius < 0 || !dtMathIsfinite(maxRadius) || |
| 329 | !filter || !frand || !randomRef || !randomPt) |
| 330 | { |
| 331 | return DT_FAILURE | DT_INVALID_PARAM; |
| 332 | } |
| 333 | |
| 334 | const dtMeshTile* startTile = 0; |
| 335 | const dtPoly* startPoly = 0; |
| 336 | m_nav->getTileAndPolyByRefUnsafe(startRef, &startTile, &startPoly); |
| 337 | if (!filter->passFilter(startRef, startTile, startPoly)) |
| 338 | return DT_FAILURE | DT_INVALID_PARAM; |
| 339 | |
| 340 | m_nodePool->clear(); |
| 341 | m_openList->clear(); |
| 342 | |
| 343 | dtNode* startNode = m_nodePool->getNode(startRef); |
| 344 | dtVcopy(startNode->pos, centerPos); |
| 345 | startNode->pidx = 0; |
| 346 | startNode->cost = 0; |
| 347 | startNode->total = 0; |
| 348 | startNode->id = startRef; |
| 349 | startNode->flags = DT_NODE_OPEN; |
| 350 | m_openList->push(startNode); |
| 351 | |
| 352 | dtStatus status = DT_SUCCESS; |
| 353 | |
| 354 | const float radiusSqr = dtSqr(maxRadius); |
| 355 | float areaSum = 0.0f; |
| 356 | |
| 357 | const dtMeshTile* randomTile = 0; |
| 358 | const dtPoly* randomPoly = 0; |
| 359 | dtPolyRef randomPolyRef = 0; |
| 360 | |
| 361 | while (!m_openList->empty()) |
| 362 | { |
| 363 | dtNode* bestNode = m_openList->pop(); |
| 364 | bestNode->flags &= ~DT_NODE_OPEN; |
| 365 | bestNode->flags |= DT_NODE_CLOSED; |
| 366 | |
| 367 | // Get poly and tile. |
| 368 | // The API input has been cheked already, skip checking internal data. |
| 369 | const dtPolyRef bestRef = bestNode->id; |
| 370 | const dtMeshTile* bestTile = 0; |
| 371 | const dtPoly* bestPoly = 0; |
| 372 | m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); |
| 373 | |
| 374 | // Place random locations on on ground. |
nothing calls this directly
no test coverage detected