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