| 675 | |
| 676 | |
| 677 | void 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 | } |
nothing calls this directly
no test coverage detected