| 454 | } |
| 455 | |
| 456 | bool NavPath::update() |
| 457 | { |
| 458 | PROFILE_SCOPE(NavPath_update); |
| 459 | if(dtStatusInProgress(mStatus)) |
| 460 | mStatus = mQuery->updateSlicedFindPath(mMaxIterations, NULL); |
| 461 | if(dtStatusSucceed(mStatus)) |
| 462 | { |
| 463 | // Add points from this leg. |
| 464 | dtPolyRef path[MaxPathLen]; |
| 465 | S32 pathLen; |
| 466 | mStatus = mQuery->finalizeSlicedFindPath(path, &pathLen, MaxPathLen); |
| 467 | if(dtStatusSucceed(mStatus) && pathLen) |
| 468 | { |
| 469 | F32 straightPath[MaxPathLen * 3]; |
| 470 | S32 straightPathLen; |
| 471 | dtPolyRef straightPathPolys[MaxPathLen]; |
| 472 | U8 straightPathFlags[MaxPathLen]; |
| 473 | |
| 474 | U32 s = mVisitPoints.size(); |
| 475 | Point3F start = mVisitPoints[s-1]; |
| 476 | Point3F end = mVisitPoints[s-2]; |
| 477 | F32 from[] = {start.x, start.z, -start.y}; |
| 478 | F32 to[] = {end.x, end.z, -end.y}; |
| 479 | |
| 480 | mQuery->findStraightPath(from, to, path, pathLen, |
| 481 | straightPath, straightPathFlags, |
| 482 | straightPathPolys, &straightPathLen, MaxPathLen); |
| 483 | |
| 484 | s = mPoints.size(); |
| 485 | mPoints.increment(straightPathLen); |
| 486 | mFlags.increment(straightPathLen); |
| 487 | for(U32 i = 0; i < straightPathLen; i++) |
| 488 | { |
| 489 | F32 *f = straightPath + i * 3; |
| 490 | mPoints[s + i] = RCtoDTS(f); |
| 491 | mMesh->getNavMesh()->getPolyFlags(straightPathPolys[i], &mFlags[s + i]); |
| 492 | // Add to length |
| 493 | if(s > 0 || i > 0) |
| 494 | mLength += (mPoints[s+i] - mPoints[s+i-1]).len(); |
| 495 | } |
| 496 | |
| 497 | if(isServerObject()) |
| 498 | setMaskBits(PathMask); |
| 499 | } |
| 500 | else |
| 501 | return false; |
| 502 | // Check to see where we still need to visit. |
| 503 | if(mVisitPoints.size() > 1) |
| 504 | { |
| 505 | //Next leg of the journey. |
| 506 | mVisitPoints.pop_back(); |
| 507 | return visitNext(); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | // Finished! |
| 512 | return false; |
| 513 | } |
nothing calls this directly
no test coverage detected