forked from mirror/DotRecast
rename for unity3d
This commit is contained in:
parent
74cbb2ee29
commit
94e1922e02
|
@ -268,14 +268,14 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
if (refs != 0)
|
if (refs != 0)
|
||||||
{
|
{
|
||||||
ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_WALKING;
|
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_INVALID;
|
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
||||||
|
|
||||||
return ag;
|
return ag;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
agent.targetPos = vel;
|
agent.targetPos = vel;
|
||||||
agent.targetPathQueryResult = null;
|
agent.targetPathQueryResult = null;
|
||||||
agent.targetReplan = false;
|
agent.targetReplan = false;
|
||||||
agent.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY;
|
agent.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
agent.dvel = RcVec3f.Zero;
|
agent.dvel = RcVec3f.Zero;
|
||||||
agent.targetPathQueryResult = null;
|
agent.targetPathQueryResult = null;
|
||||||
agent.targetReplan = false;
|
agent.targetReplan = false;
|
||||||
agent.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
agent.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
ag.corridor.Reset(0, agentPos);
|
ag.corridor.Reset(0, agentPos);
|
||||||
ag.partial = false;
|
ag.partial = false;
|
||||||
ag.boundary.Reset();
|
ag.boundary.Reset();
|
||||||
ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_INVALID;
|
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_INVALID;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,15 +492,15 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
// If the agent does not have move target or is controlled by
|
// If the agent does not have move target or is controlled by
|
||||||
// velocity, no need to recover the target nor replan.
|
// velocity, no need to recover the target nor replan.
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to recover move request position.
|
// Try to recover move request position.
|
||||||
if (ag.targetState != MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState != DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
&& ag.targetState != MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
&& ag.targetState != DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
||||||
{
|
{
|
||||||
if (!_navQuery.IsValidPolyRef(ag.targetRef, _filters[ag.option.queryFilterType]))
|
if (!_navQuery.IsValidPolyRef(ag.targetRef, _filters[ag.option.queryFilterType]))
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Failed to reposition target, fail moverequest.
|
// Failed to reposition target, fail moverequest.
|
||||||
ag.corridor.Reset(agentRef, agentPos);
|
ag.corridor.Reset(agentRef, agentPos);
|
||||||
ag.partial = false;
|
ag.partial = false;
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
// If the end of the path is near and it is not the requested
|
// If the end of the path is near and it is not the requested
|
||||||
// location, replan.
|
// location, replan.
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VALID)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VALID)
|
||||||
{
|
{
|
||||||
if (ag.targetReplanTime > _config.targetReplanDelay && ag.corridor.GetPathCount() < _config.checkLookAhead
|
if (ag.targetReplanTime > _config.targetReplanDelay && ag.corridor.GetPathCount() < _config.checkLookAhead
|
||||||
&& ag.corridor.GetLastPoly() != ag.targetRef)
|
&& ag.corridor.GetLastPoly() != ag.targetRef)
|
||||||
|
@ -543,7 +543,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Try to replan path to goal.
|
// Try to replan path to goal.
|
||||||
if (replan)
|
if (replan)
|
||||||
{
|
{
|
||||||
if (ag.targetState != MoveRequestState.DT_CROWDAGENT_TARGET_NONE)
|
if (ag.targetState != DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE)
|
||||||
{
|
{
|
||||||
RequestMoveTargetReplan(ag, ag.targetRef, ag.targetPos);
|
RequestMoveTargetReplan(ag, ag.targetRef, ag.targetPos);
|
||||||
}
|
}
|
||||||
|
@ -561,18 +561,18 @@ namespace DotRecast.Detour.Crowd
|
||||||
List<long> reqPath = new List<long>();
|
List<long> reqPath = new List<long>();
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state == CrowdAgentState.DT_CROWDAGENT_STATE_INVALID)
|
if (ag.state == DtCrowdAgentState.DT_CROWDAGENT_STATE_INVALID)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING)
|
||||||
{
|
{
|
||||||
List<long> path = ag.corridor.GetPath();
|
List<long> path = ag.corridor.GetPath();
|
||||||
if (0 == path.Count)
|
if (0 == path.Count)
|
||||||
|
@ -632,19 +632,19 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
if (reqPath[reqPath.Count - 1] == ag.targetRef)
|
if (reqPath[reqPath.Count - 1] == ag.targetRef)
|
||||||
{
|
{
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_VALID;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_VALID;
|
||||||
ag.targetReplanTime = 0;
|
ag.targetReplanTime = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The path is longer or potentially unreachable, full plan.
|
// The path is longer or potentially unreachable, full plan.
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ag.targetReplanWaitTime = 0;
|
ag.targetReplanWaitTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
||||||
{
|
{
|
||||||
queue.Enqueue(ag);
|
queue.Enqueue(ag);
|
||||||
}
|
}
|
||||||
|
@ -656,7 +656,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
ag.targetPathQueryResult = _pathQ.Request(ag.corridor.GetLastPoly(), ag.targetRef, ag.corridor.GetTarget(), ag.targetPos, _filters[ag.option.queryFilterType]);
|
ag.targetPathQueryResult = _pathQ.Request(ag.corridor.GetLastPoly(), ag.targetRef, ag.corridor.GetTarget(), ag.targetPos, _filters[ag.option.queryFilterType]);
|
||||||
if (ag.targetPathQueryResult != null)
|
if (ag.targetPathQueryResult != null)
|
||||||
{
|
{
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -674,13 +674,13 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Process path results.
|
// Process path results.
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
||||||
{
|
{
|
||||||
// _telemetry.RecordPathWaitTime(ag.targetReplanTime);
|
// _telemetry.RecordPathWaitTime(ag.targetReplanTime);
|
||||||
// Poll path queue.
|
// Poll path queue.
|
||||||
|
@ -692,11 +692,11 @@ namespace DotRecast.Detour.Crowd
|
||||||
ag.targetPathQueryResult = null;
|
ag.targetPathQueryResult = null;
|
||||||
if (ag.targetRef != 0)
|
if (ag.targetRef != 0)
|
||||||
{
|
{
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ag.targetReplanTime = 0;
|
ag.targetReplanTime = 0;
|
||||||
|
@ -788,12 +788,12 @@ namespace DotRecast.Detour.Crowd
|
||||||
ag.corridor.SetCorridor(targetPos, res);
|
ag.corridor.SetCorridor(targetPos, res);
|
||||||
// Force to update boundary.
|
// Force to update boundary.
|
||||||
ag.boundary.Reset();
|
ag.boundary.Reset();
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_VALID;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_VALID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Something went wrong.
|
// Something went wrong.
|
||||||
ag.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
ag.targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ag.targetReplanTime = 0;
|
ag.targetReplanTime = 0;
|
||||||
|
@ -813,13 +813,13 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -926,13 +926,13 @@ namespace DotRecast.Detour.Crowd
|
||||||
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
|
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -973,13 +973,13 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1002,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
anim.t = 0.0f;
|
anim.t = 0.0f;
|
||||||
anim.tmax = (RcVec3f.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * 0.5f;
|
anim.tmax = (RcVec3f.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * 0.5f;
|
||||||
|
|
||||||
ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH;
|
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH;
|
||||||
ag.corners.Clear();
|
ag.corners.Clear();
|
||||||
ag.neis.Clear();
|
ag.neis.Clear();
|
||||||
continue;
|
continue;
|
||||||
|
@ -1021,19 +1021,19 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RcVec3f dvel = new RcVec3f();
|
RcVec3f dvel = new RcVec3f();
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
dvel = ag.targetPos;
|
dvel = ag.targetPos;
|
||||||
ag.desiredSpeed = ag.targetPos.Length();
|
ag.desiredSpeed = ag.targetPos.Length();
|
||||||
|
@ -1119,7 +1119,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
|
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1188,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1206,7 +1206,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
long idx0 = ag.idx;
|
long idx0 = ag.idx;
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1263,7 +1263,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1279,7 +1279,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
foreach (DtCrowdAgent ag in agents)
|
foreach (DtCrowdAgent ag in agents)
|
||||||
{
|
{
|
||||||
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
if (ag.state != DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1290,8 +1290,8 @@ namespace DotRecast.Detour.Crowd
|
||||||
ag.npos = ag.corridor.GetPos();
|
ag.npos = ag.corridor.GetPos();
|
||||||
|
|
||||||
// If not using path, truncate the corridor to just one poly.
|
// If not using path, truncate the corridor to just one poly.
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
{
|
{
|
||||||
ag.corridor.Reset(ag.corridor.GetFirstPoly(), ag.npos);
|
ag.corridor.Reset(ag.corridor.GetFirstPoly(), ag.npos);
|
||||||
ag.partial = false;
|
ag.partial = false;
|
||||||
|
@ -1317,7 +1317,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Reset animation
|
// Reset animation
|
||||||
anim.active = false;
|
anim.active = false;
|
||||||
// Prepare agent for walking.
|
// Prepare agent for walking.
|
||||||
ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_WALKING;
|
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_WALKING;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
public readonly long idx;
|
public readonly long idx;
|
||||||
|
|
||||||
/// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState)
|
/// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState)
|
||||||
public CrowdAgentState state;
|
public DtCrowdAgentState state;
|
||||||
|
|
||||||
/// True if the agent has valid path (targetState == DT_CROWDAGENT_TARGET_VALID) and the path does not lead to the
|
/// True if the agent has valid path (targetState == DT_CROWDAGENT_TARGET_VALID) and the path does not lead to the
|
||||||
/// requested position, else false.
|
/// requested position, else false.
|
||||||
|
@ -78,7 +78,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
/// The local path corridor corners for the agent.
|
/// The local path corridor corners for the agent.
|
||||||
public List<StraightPathItem> corners = new List<StraightPathItem>();
|
public List<StraightPathItem> corners = new List<StraightPathItem>();
|
||||||
|
|
||||||
public MoveRequestState targetState;
|
public DtMoveRequestState targetState;
|
||||||
|
|
||||||
/// < State of the movement request.
|
/// < State of the movement request.
|
||||||
public long targetRef;
|
public long targetRef;
|
||||||
|
@ -206,11 +206,11 @@ namespace DotRecast.Detour.Crowd
|
||||||
targetPathQueryResult = null;
|
targetPathQueryResult = null;
|
||||||
if (targetRef != 0)
|
if (targetRef != 0)
|
||||||
{
|
{
|
||||||
targetState = MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING;
|
targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetState = MoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
targetState = DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
/// The type of navigation mesh polygon the agent is currently traversing.
|
/// The type of navigation mesh polygon the agent is currently traversing.
|
||||||
/// @ingroup crowd
|
/// @ingroup crowd
|
||||||
public enum CrowdAgentState
|
public enum DtCrowdAgentState
|
||||||
{
|
{
|
||||||
DT_CROWDAGENT_STATE_INVALID,
|
DT_CROWDAGENT_STATE_INVALID,
|
||||||
|
|
|
@ -75,12 +75,12 @@ namespace DotRecast.Detour.Crowd
|
||||||
return new RcAnonymousDisposable(() => Stop(label));
|
return new RcAnonymousDisposable(() => Stop(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(DtCrowdTimerLabel name)
|
private void Start(DtCrowdTimerLabel name)
|
||||||
{
|
{
|
||||||
_executionTimings.Add(name, RcFrequency.Ticks);
|
_executionTimings.Add(name, RcFrequency.Ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop(DtCrowdTimerLabel name)
|
private void Stop(DtCrowdTimerLabel name)
|
||||||
{
|
{
|
||||||
long duration = RcFrequency.Ticks - _executionTimings[name];
|
long duration = RcFrequency.Ticks - _executionTimings[name];
|
||||||
if (!_executionTimingSamples.TryGetValue(name, out var s))
|
if (!_executionTimingSamples.TryGetValue(name, out var s))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace DotRecast.Detour.Crowd
|
namespace DotRecast.Detour.Crowd
|
||||||
{
|
{
|
||||||
public enum MoveRequestState
|
public enum DtMoveRequestState
|
||||||
{
|
{
|
||||||
DT_CROWDAGENT_TARGET_NONE,
|
DT_CROWDAGENT_TARGET_NONE,
|
||||||
DT_CROWDAGENT_TARGET_FAILED,
|
DT_CROWDAGENT_TARGET_FAILED,
|
|
@ -315,13 +315,13 @@ public class CrowdProfilingTool
|
||||||
|
|
||||||
private bool NeedsNewTarget(DtCrowdAgent ag)
|
private bool NeedsNewTarget(DtCrowdAgent ag)
|
||||||
{
|
{
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VALID)
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VALID)
|
||||||
{
|
{
|
||||||
float dx = ag.targetPos.x - ag.npos.x;
|
float dx = ag.targetPos.x - ag.npos.x;
|
||||||
float dy = ag.targetPos.y - ag.npos.y;
|
float dy = ag.targetPos.y - ag.npos.y;
|
||||||
|
@ -373,14 +373,14 @@ public class CrowdProfilingTool
|
||||||
col = DuRGBA(120, 80, 160, 128);
|
col = DuRGBA(120, 80, 160, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
||||||
col = DuLerpCol(col, DuRGBA(255, 255, 32, 128), 128);
|
col = DuLerpCol(col, DuRGBA(255, 255, 32, 128), 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
||||||
col = DuLerpCol(col, DuRGBA(255, 64, 32, 128), 128);
|
col = DuLerpCol(col, DuRGBA(255, 64, 32, 128), 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
||||||
col = DuRGBA(255, 32, 16, 128);
|
col = DuRGBA(255, 32, 16, 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
col = DuLerpCol(col, DuRGBA(64, 255, 0, 128), 128);
|
col = DuLerpCol(col, DuRGBA(64, 255, 0, 128), 128);
|
||||||
|
|
||||||
dd.DebugDrawCylinder(pos.x - radius, pos.y + radius * 0.1f, pos.z - radius, pos.x + radius, pos.y + height,
|
dd.DebugDrawCylinder(pos.x - radius, pos.y + radius * 0.1f, pos.z - radius, pos.x + radius, pos.y + height,
|
||||||
|
|
|
@ -538,14 +538,14 @@ public class CrowdTool : IRcTool
|
||||||
RcVec3f pos = ag.npos;
|
RcVec3f pos = ag.npos;
|
||||||
|
|
||||||
int col = DuRGBA(220, 220, 220, 128);
|
int col = DuRGBA(220, 220, 220, 128);
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
||||||
col = DuLerpCol(col, DuRGBA(128, 0, 255, 128), 32);
|
col = DuLerpCol(col, DuRGBA(128, 0, 255, 128), 32);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
||||||
col = DuLerpCol(col, DuRGBA(128, 0, 255, 128), 128);
|
col = DuLerpCol(col, DuRGBA(128, 0, 255, 128), 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
||||||
col = DuRGBA(255, 32, 16, 128);
|
col = DuRGBA(255, 32, 16, 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
col = DuLerpCol(col, DuRGBA(64, 255, 0, 128), 128);
|
col = DuLerpCol(col, DuRGBA(64, 255, 0, 128), 128);
|
||||||
|
|
||||||
dd.DebugDrawCylinder(pos.x - radius, pos.y + radius * 0.1f, pos.z - radius, pos.x + radius, pos.y + height,
|
dd.DebugDrawCylinder(pos.x - radius, pos.y + radius * 0.1f, pos.z - radius, pos.x + radius, pos.y + height,
|
||||||
|
@ -597,14 +597,14 @@ public class CrowdTool : IRcTool
|
||||||
RcVec3f dvel = ag.dvel;
|
RcVec3f dvel = ag.dvel;
|
||||||
|
|
||||||
int col = DuRGBA(220, 220, 220, 192);
|
int col = DuRGBA(220, 220, 220, 192);
|
||||||
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
|
||||||
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
|| ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
|
||||||
col = DuLerpCol(col, DuRGBA(128, 0, 255, 192), 48);
|
col = DuLerpCol(col, DuRGBA(128, 0, 255, 192), 48);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
|
||||||
col = DuLerpCol(col, DuRGBA(128, 0, 255, 192), 128);
|
col = DuLerpCol(col, DuRGBA(128, 0, 255, 192), 128);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
|
||||||
col = DuRGBA(255, 32, 16, 192);
|
col = DuRGBA(255, 32, 16, 192);
|
||||||
else if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
else if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
|
||||||
col = DuLerpCol(col, DuRGBA(64, 255, 0, 192), 128);
|
col = DuLerpCol(col, DuRGBA(64, 255, 0, 192), 128);
|
||||||
|
|
||||||
dd.DebugDrawCircle(pos.x, pos.y + height, pos.z, radius, col, 2.0f);
|
dd.DebugDrawCircle(pos.x, pos.y + height, pos.z, radius, col, 2.0f);
|
||||||
|
|
Loading…
Reference in New Issue