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