MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / visitNext

Method visitNext

Engine/source/navigation/navPath.cpp:406–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406bool 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
453bool NavPath::update()
454{

Callers

nothing calls this directly

Calls 8

dtStatusFailedFunction · 0.85
errorfFunction · 0.85
findNearestPolyMethod · 0.80
initSlicedFindPathMethod · 0.80
getContainerFunction · 0.50
Point3FClass · 0.50
sizeMethod · 0.45
castRayMethod · 0.45

Tested by

no test coverage detected