| 404 | } |
| 405 | |
| 406 | bool NavPath::visitNext() |
| 407 | { |
| 408 | U32 s = mVisitPoints.size(); |
| 409 | if(s < 2) |
| 410 | return false; |
| 411 | |
| 412 | // Current leg of journey. |
| 413 | Point3F &start = mVisitPoints[s-1]; |
| 414 | Point3F &end = mVisitPoints[s-2]; |
| 415 | |
| 416 | // Drop to height of statics. |
| 417 | RayInfo info; |
| 418 | if(getContainer()->castRay(start, start - Point3F(0, 0, mMesh->mWalkableHeight * 2.0f), StaticObjectType, &info)) |
| 419 | start = info.point; |
| 420 | if(getContainer()->castRay(end + Point3F(0, 0, 0.1f), end - Point3F(0, 0, mMesh->mWalkableHeight * 2.0f), StaticObjectType, &info)) |
| 421 | end = info.point; |
| 422 | |
| 423 | // Convert to Detour-friendly coordinates and data structures. |
| 424 | F32 from[] = {start.x, start.z, -start.y}; |
| 425 | F32 to[] = {end.x, end.z, -end.y}; |
| 426 | F32 extx = mMesh->mWalkableRadius * 4.0f; |
| 427 | F32 extz = mMesh->mWalkableHeight; |
| 428 | F32 extents[] = {extx, extz, extx}; |
| 429 | dtPolyRef startRef, endRef; |
| 430 | |
| 431 | if(dtStatusFailed(mQuery->findNearestPoly(from, extents, &mFilter, &startRef, NULL)) || !startRef) |
| 432 | { |
| 433 | Con::errorf("No NavMesh polygon near visit point (%g, %g, %g) of NavPath %s", |
| 434 | start.x, start.y, start.z, getIdString()); |
| 435 | return false; |
| 436 | } |
| 437 | |
| 438 | if(dtStatusFailed(mQuery->findNearestPoly(to, extents, &mFilter, &endRef, NULL)) || !endRef) |
| 439 | { |
| 440 | Con::errorf("No NavMesh polygon near visit point (%g, %g, %g) of NavPath %s", |
| 441 | end.x, end.y, end.z, getIdString()); |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | // Init sliced pathfind. |
| 446 | mStatus = mQuery->initSlicedFindPath(startRef, endRef, from, to, &mFilter); |
| 447 | if(dtStatusFailed(mStatus)) |
| 448 | return false; |
| 449 | |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | bool NavPath::update() |
| 454 | { |
nothing calls this directly
no test coverage detected