Add partial path result status for dtCrowdAgent
This commit is contained in:
parent
9e1bbf9482
commit
5290c8aac4
@ -121,6 +121,9 @@ struct dtCrowdAgent
|
|||||||
/// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState)
|
/// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState)
|
||||||
unsigned char state;
|
unsigned char state;
|
||||||
|
|
||||||
|
/// 1 if the path is a partial path (the path does not lead to the target)
|
||||||
|
unsigned char partial;
|
||||||
|
|
||||||
/// The path corridor the agent is using.
|
/// The path corridor the agent is using.
|
||||||
dtPathCorridor corridor;
|
dtPathCorridor corridor;
|
||||||
|
|
||||||
|
@ -538,6 +538,7 @@ int dtCrowd::addAgent(const float* pos, const dtCrowdAgentParams* params)
|
|||||||
|
|
||||||
ag->corridor.reset(ref, nearest);
|
ag->corridor.reset(ref, nearest);
|
||||||
ag->boundary.reset();
|
ag->boundary.reset();
|
||||||
|
ag->partial = 0;
|
||||||
|
|
||||||
updateAgentParameters(idx, params);
|
updateAgentParameters(idx, params);
|
||||||
|
|
||||||
@ -716,6 +717,11 @@ void dtCrowd::updateMoveRequest(const float /*dt*/)
|
|||||||
status = m_navquery->finalizeSlicedFindPath(reqPath, &reqPathCount, MAX_RES);
|
status = m_navquery->finalizeSlicedFindPath(reqPath, &reqPathCount, MAX_RES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dtStatusDetail(status, DT_PARTIAL_RESULT))
|
||||||
|
ag->partial = 1;
|
||||||
|
else
|
||||||
|
ag->partial = 0;
|
||||||
|
|
||||||
if (!dtStatusFailed(status) && reqPathCount > 0)
|
if (!dtStatusFailed(status) && reqPathCount > 0)
|
||||||
{
|
{
|
||||||
// In progress or succeed.
|
// In progress or succeed.
|
||||||
@ -819,7 +825,12 @@ void dtCrowd::updateMoveRequest(const float /*dt*/)
|
|||||||
status = m_pathq.getPathResult(ag->targetPathqRef, res, &nres, m_maxPathResult);
|
status = m_pathq.getPathResult(ag->targetPathqRef, res, &nres, m_maxPathResult);
|
||||||
if (dtStatusFailed(status) || !nres)
|
if (dtStatusFailed(status) || !nres)
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
|
if (dtStatusDetail(status, DT_PARTIAL_RESULT))
|
||||||
|
ag->partial = 1;
|
||||||
|
else
|
||||||
|
ag->partial = 0;
|
||||||
|
|
||||||
// Merge result and existing path.
|
// Merge result and existing path.
|
||||||
// The agent might have moved whilst the request is
|
// The agent might have moved whilst the request is
|
||||||
// being processed, so the path may have changed.
|
// being processed, so the path may have changed.
|
||||||
|
@ -185,6 +185,7 @@ dtStatus dtPathQueue::getPathResult(dtPathQueueRef ref, dtPolyRef* path, int* pa
|
|||||||
if (m_queue[i].ref == ref)
|
if (m_queue[i].ref == ref)
|
||||||
{
|
{
|
||||||
PathQuery& q = m_queue[i];
|
PathQuery& q = m_queue[i];
|
||||||
|
dtStatus details = q.status;
|
||||||
// Free request for reuse.
|
// Free request for reuse.
|
||||||
q.ref = DT_PATHQ_INVALID;
|
q.ref = DT_PATHQ_INVALID;
|
||||||
q.status = 0;
|
q.status = 0;
|
||||||
@ -192,7 +193,7 @@ dtStatus dtPathQueue::getPathResult(dtPathQueueRef ref, dtPolyRef* path, int* pa
|
|||||||
int n = dtMin(q.npath, maxPath);
|
int n = dtMin(q.npath, maxPath);
|
||||||
memcpy(path, q.path, sizeof(dtPolyRef)*n);
|
memcpy(path, q.path, sizeof(dtPolyRef)*n);
|
||||||
*pathSize = n;
|
*pathSize = n;
|
||||||
return DT_SUCCESS;
|
return details | DT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DT_FAILURE;
|
return DT_FAILURE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user