MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / updateMoveRequest

Method updateMoveRequest

Source/ThirdParty/recastnavigation/DetourCrowd.cpp:677–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675
676
677void dtCrowd::updateMoveRequest(const float /*dt*/)
678{
679 const int PATH_MAX_AGENTS = 8;
680 dtCrowdAgent* queue[PATH_MAX_AGENTS];
681 int nqueue = 0;
682
683 // Fire off new requests.
684 for (int i = 0; i < m_maxAgents; ++i)
685 {
686 dtCrowdAgent* ag = &m_agents[i];
687 if (!ag->active)
688 continue;
689 if (ag->state == DT_CROWDAGENT_STATE_INVALID)
690 continue;
691 if (ag->targetState == DT_CROWDAGENT_TARGET_NONE || ag->targetState == DT_CROWDAGENT_TARGET_VELOCITY)
692 continue;
693
694 if (ag->targetState == DT_CROWDAGENT_TARGET_REQUESTING)
695 {
696 const dtPolyRef* path = ag->corridor.getPath();
697 const int npath = ag->corridor.getPathCount();
698 dtAssert(npath);
699
700 static const int MAX_RES = 32;
701 float reqPos[3];
702 dtPolyRef reqPath[MAX_RES]; // The path to the request location
703 int reqPathCount = 0;
704
705 // Quick search towards the goal.
706 static const int MAX_ITER = 20;
707 m_navquery->initSlicedFindPath(path[0], ag->targetRef, ag->npos, ag->targetPos, &m_filters[ag->params.queryFilterType]);
708 m_navquery->updateSlicedFindPath(MAX_ITER, 0);
709 dtStatus status = 0;
710 if (ag->targetReplan) // && npath > 10)
711 {
712 // Try to use existing steady path during replan if possible.
713 status = m_navquery->finalizeSlicedFindPathPartial(path, npath, reqPath, &reqPathCount, MAX_RES);
714 }
715 else
716 {
717 // Try to move towards target when goal changes.
718 status = m_navquery->finalizeSlicedFindPath(reqPath, &reqPathCount, MAX_RES);
719 }
720
721 if (!dtStatusFailed(status) && reqPathCount > 0)
722 {
723 // In progress or succeed.
724 if (reqPath[reqPathCount-1] != ag->targetRef)
725 {
726 // Partial path, constrain target position inside the last polygon.
727 status = m_navquery->closestPointOnPoly(reqPath[reqPathCount-1], ag->targetPos, reqPos, 0);
728 if (dtStatusFailed(status))
729 reqPathCount = 0;
730 }
731 else
732 {
733 dtVcopy(reqPos, ag->targetPos);
734 }

Callers

nothing calls this directly

Calls 15

dtStatusFailedFunction · 0.85
dtVcopyFunction · 0.85
addToPathQueueFunction · 0.85
dtStatusSucceedFunction · 0.85
dtStatusDetailFunction · 0.85
memmoveFunction · 0.85
memcpyFunction · 0.85
getPathMethod · 0.80
getPathCountMethod · 0.80
initSlicedFindPathMethod · 0.80
updateSlicedFindPathMethod · 0.80

Tested by

no test coverage detected