forked from bit/DotRecastNetSim
refactor: DtNodeFlags
This commit is contained in:
parent
78d4591c3c
commit
6416374f94
|
@ -4,12 +4,8 @@
|
||||||
/// @ingroup crowd
|
/// @ingroup crowd
|
||||||
public enum DtCrowdAgentState
|
public enum DtCrowdAgentState
|
||||||
{
|
{
|
||||||
DT_CROWDAGENT_STATE_INVALID,
|
DT_CROWDAGENT_STATE_INVALID, // < The agent is not in a valid state.
|
||||||
|
DT_CROWDAGENT_STATE_WALKING, // < The agent is traversing a normal navigation mesh polygon.
|
||||||
/// < The agent is not in a valid state.
|
DT_CROWDAGENT_STATE_OFFMESH, // < The agent is traversing an off-mesh connection.
|
||||||
DT_CROWDAGENT_STATE_WALKING,
|
|
||||||
|
|
||||||
/// < The agent is traversing a normal navigation mesh polygon.
|
|
||||||
DT_CROWDAGENT_STATE_OFFMESH, /// < The agent is traversing an off-mesh connection.
|
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -226,7 +226,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = 0;
|
startNode.total = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
DtStatus status = DtStatus.DT_SUCCSESS;
|
DtStatus status = DtStatus.DT_SUCCSESS;
|
||||||
|
@ -241,8 +241,8 @@ namespace DotRecast.Detour
|
||||||
while (!m_openList.IsEmpty())
|
while (!m_openList.IsEmpty())
|
||||||
{
|
{
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
// Get poly and tile.
|
// Get poly and tile.
|
||||||
// The API input has been checked already, skip checking internal data.
|
// The API input has been checked already, skip checking internal data.
|
||||||
long bestRef = bestNode.id;
|
long bestRef = bestNode.id;
|
||||||
|
@ -331,7 +331,7 @@ namespace DotRecast.Detour
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -345,23 +345,23 @@ namespace DotRecast.Detour
|
||||||
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
||||||
|
|
||||||
// The node is already in open list and the new result is worse, skip.
|
// The node is already in open list and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
neighbourNode.id = neighbourRef;
|
neighbourNode.id = neighbourRef;
|
||||||
neighbourNode.flags = (neighbourNode.flags & ~DtNode.DT_NODE_CLOSED);
|
neighbourNode.flags = (neighbourNode.flags & ~DtNodeFlags.DT_NODE_CLOSED);
|
||||||
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbourNode.flags = DtNode.DT_NODE_OPEN;
|
neighbourNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = heuristic.GetCost(startPos, endPos);
|
startNode.total = heuristic.GetCost(startPos, endPos);
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
DtNode lastBestNode = startNode;
|
DtNode lastBestNode = startNode;
|
||||||
|
@ -791,8 +791,8 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
// Remove node from open list and put it in closed list.
|
// Remove node from open list and put it in closed list.
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DtNode.DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
|
|
||||||
// Reached the goal, stop searching.
|
// Reached the goal, stop searching.
|
||||||
if (bestNode.id == endRef)
|
if (bestNode.id == endRef)
|
||||||
|
@ -925,13 +925,13 @@ namespace DotRecast.Detour
|
||||||
float total = cost + heuristicCost;
|
float total = cost + heuristicCost;
|
||||||
|
|
||||||
// The node is already in open list and the new result is worse, skip.
|
// The node is already in open list and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The node is already visited and process, and the new result is worse, skip.
|
// The node is already visited and process, and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -939,13 +939,13 @@ namespace DotRecast.Detour
|
||||||
// Add or update the node.
|
// Add or update the node.
|
||||||
neighbourNode.pidx = foundShortCut ? bestNode.pidx : m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = foundShortCut ? bestNode.pidx : m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.id = neighbourRef;
|
neighbourNode.id = neighbourRef;
|
||||||
neighbourNode.flags = (neighbourNode.flags & ~DtNode.DT_NODE_CLOSED);
|
neighbourNode.flags = (neighbourNode.flags & ~DtNodeFlags.DT_NODE_CLOSED);
|
||||||
neighbourNode.cost = cost;
|
neighbourNode.cost = cost;
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
neighbourNode.pos = neighbourPos;
|
neighbourNode.pos = neighbourPos;
|
||||||
neighbourNode.shortcut = shortcut;
|
neighbourNode.shortcut = shortcut;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
// Already in open, update node location.
|
// Already in open, update node location.
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
|
@ -953,7 +953,7 @@ namespace DotRecast.Detour
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Put the node in open list.
|
// Put the node in open list.
|
||||||
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
|
neighbourNode.flags |= DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1050,7 +1050,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = heuristic.GetCost(startPos, endPos);
|
startNode.total = heuristic.GetCost(startPos, endPos);
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
m_query.status = DtStatus.DT_IN_PROGRESS;
|
m_query.status = DtStatus.DT_IN_PROGRESS;
|
||||||
|
@ -1089,8 +1089,8 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// Remove node from open list and put it in closed list.
|
// Remove node from open list and put it in closed list.
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DtNode.DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
|
|
||||||
// Reached the goal, stop searching.
|
// Reached the goal, stop searching.
|
||||||
if (bestNode.id == m_query.endRef)
|
if (bestNode.id == m_query.endRef)
|
||||||
|
@ -1249,14 +1249,14 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// The node is already in open list and the new result is worse,
|
// The node is already in open list and the new result is worse,
|
||||||
// skip.
|
// skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The node is already visited and process, and the new result
|
// The node is already visited and process, and the new result
|
||||||
// is worse, skip.
|
// is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1264,13 +1264,13 @@ namespace DotRecast.Detour
|
||||||
// Add or update the node.
|
// Add or update the node.
|
||||||
neighbourNode.pidx = foundShortCut ? bestNode.pidx : m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = foundShortCut ? bestNode.pidx : m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.id = neighbourRef;
|
neighbourNode.id = neighbourRef;
|
||||||
neighbourNode.flags = (neighbourNode.flags & ~DT_NODE_CLOSED);
|
neighbourNode.flags = (neighbourNode.flags & ~DtNodeFlags.DT_NODE_CLOSED);
|
||||||
neighbourNode.cost = cost;
|
neighbourNode.cost = cost;
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
neighbourNode.pos = neighbourPos;
|
neighbourNode.pos = neighbourPos;
|
||||||
neighbourNode.shortcut = shortcut;
|
neighbourNode.shortcut = shortcut;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
// Already in open, update node location.
|
// Already in open, update node location.
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
|
@ -1278,7 +1278,7 @@ namespace DotRecast.Detour
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Put the node in open list.
|
// Put the node in open list.
|
||||||
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
|
neighbourNode.flags |= DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1792,7 +1792,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = 0;
|
startNode.total = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_CLOSED;
|
startNode.flags = DtNodeFlags.DT_NODE_CLOSED;
|
||||||
LinkedList<DtNode> stack = new LinkedList<DtNode>();
|
LinkedList<DtNode> stack = new LinkedList<DtNode>();
|
||||||
stack.AddLast(startNode);
|
stack.AddLast(startNode);
|
||||||
|
|
||||||
|
@ -1894,7 +1894,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
DtNode neighbourNode = tinyNodePool.GetNode(neis[k]);
|
DtNode neighbourNode = tinyNodePool.GetNode(neis[k]);
|
||||||
// Skip if already visited.
|
// Skip if already visited.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1911,7 +1911,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// Mark as the node as visited and push to queue.
|
// Mark as the node as visited and push to queue.
|
||||||
neighbourNode.pidx = tinyNodePool.GetNodeIdx(curNode);
|
neighbourNode.pidx = tinyNodePool.GetNodeIdx(curNode);
|
||||||
neighbourNode.flags |= DtNode.DT_NODE_CLOSED;
|
neighbourNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
stack.AddLast(neighbourNode);
|
stack.AddLast(neighbourNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2452,7 +2452,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = 0;
|
startNode.total = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
float radiusSqr = RcMath.Sqr(radius);
|
float radiusSqr = RcMath.Sqr(radius);
|
||||||
|
@ -2460,8 +2460,8 @@ namespace DotRecast.Detour
|
||||||
while (!m_openList.IsEmpty())
|
while (!m_openList.IsEmpty())
|
||||||
{
|
{
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DtNode.DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
|
|
||||||
// Get poly and tile.
|
// Get poly and tile.
|
||||||
// The API input has been checked already, skip checking internal data.
|
// The API input has been checked already, skip checking internal data.
|
||||||
|
@ -2522,7 +2522,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef);
|
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef);
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2538,7 +2538,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
float total = bestNode.total + cost;
|
float total = bestNode.total + cost;
|
||||||
// The node is already in open list and the new result is worse, skip.
|
// The node is already in open list and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2547,13 +2547,13 @@ namespace DotRecast.Detour
|
||||||
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbourNode.flags = DtNode.DT_NODE_OPEN;
|
neighbourNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2631,14 +2631,14 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = 0;
|
startNode.total = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
while (!m_openList.IsEmpty())
|
while (!m_openList.IsEmpty())
|
||||||
{
|
{
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DtNode.DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
|
|
||||||
// Get poly and tile.
|
// Get poly and tile.
|
||||||
// The API input has been checked already, skip checking internal data.
|
// The API input has been checked already, skip checking internal data.
|
||||||
|
@ -2704,7 +2704,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef);
|
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef);
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2721,7 +2721,7 @@ namespace DotRecast.Detour
|
||||||
float total = bestNode.total + cost;
|
float total = bestNode.total + cost;
|
||||||
|
|
||||||
// The node is already in open list and the new result is worse, skip.
|
// The node is already in open list and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2730,13 +2730,13 @@ namespace DotRecast.Detour
|
||||||
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbourNode.flags = DtNode.DT_NODE_OPEN;
|
neighbourNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2795,7 +2795,7 @@ namespace DotRecast.Detour
|
||||||
DtNode startNode = tinyNodePool.GetNode(startRef);
|
DtNode startNode = tinyNodePool.GetNode(startRef);
|
||||||
startNode.pidx = 0;
|
startNode.pidx = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_CLOSED;
|
startNode.flags = DtNodeFlags.DT_NODE_CLOSED;
|
||||||
LinkedList<DtNode> stack = new LinkedList<DtNode>();
|
LinkedList<DtNode> stack = new LinkedList<DtNode>();
|
||||||
stack.AddLast(startNode);
|
stack.AddLast(startNode);
|
||||||
|
|
||||||
|
@ -2830,7 +2830,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
DtNode neighbourNode = tinyNodePool.GetNode(neighbourRef);
|
DtNode neighbourNode = tinyNodePool.GetNode(neighbourRef);
|
||||||
// Skip visited.
|
// Skip visited.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2867,7 +2867,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// Mark node visited, this is done before the overlap test so that
|
// Mark node visited, this is done before the overlap test so that
|
||||||
// we will not visit the poly again if the test fails.
|
// we will not visit the poly again if the test fails.
|
||||||
neighbourNode.flags |= DtNode.DT_NODE_CLOSED;
|
neighbourNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
neighbourNode.pidx = tinyNodePool.GetNodeIdx(curNode);
|
neighbourNode.pidx = tinyNodePool.GetNodeIdx(curNode);
|
||||||
|
|
||||||
// Check that the polygon does not collide with existing polygons.
|
// Check that the polygon does not collide with existing polygons.
|
||||||
|
@ -3127,7 +3127,7 @@ namespace DotRecast.Detour
|
||||||
startNode.cost = 0;
|
startNode.cost = 0;
|
||||||
startNode.total = 0;
|
startNode.total = 0;
|
||||||
startNode.id = startRef;
|
startNode.id = startRef;
|
||||||
startNode.flags = DtNode.DT_NODE_OPEN;
|
startNode.flags = DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(startNode);
|
m_openList.Push(startNode);
|
||||||
|
|
||||||
float radiusSqr = RcMath.Sqr(maxRadius);
|
float radiusSqr = RcMath.Sqr(maxRadius);
|
||||||
|
@ -3140,8 +3140,8 @@ namespace DotRecast.Detour
|
||||||
while (!m_openList.IsEmpty())
|
while (!m_openList.IsEmpty())
|
||||||
{
|
{
|
||||||
DtNode bestNode = m_openList.Pop();
|
DtNode bestNode = m_openList.Pop();
|
||||||
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
|
bestNode.flags &= ~DtNodeFlags.DT_NODE_OPEN;
|
||||||
bestNode.flags |= DtNode.DT_NODE_CLOSED;
|
bestNode.flags |= DtNodeFlags.DT_NODE_CLOSED;
|
||||||
|
|
||||||
// Get poly and tile.
|
// Get poly and tile.
|
||||||
// The API input has been checked already, skip checking internal data.
|
// The API input has been checked already, skip checking internal data.
|
||||||
|
@ -3260,7 +3260,7 @@ namespace DotRecast.Detour
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3276,23 +3276,23 @@ namespace DotRecast.Detour
|
||||||
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
||||||
|
|
||||||
// The node is already in open list and the new result is worse, skip.
|
// The node is already in open list and the new result is worse, skip.
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
neighbourNode.id = neighbourRef;
|
neighbourNode.id = neighbourRef;
|
||||||
neighbourNode.flags = (neighbourNode.flags & ~DtNode.DT_NODE_CLOSED);
|
neighbourNode.flags = (neighbourNode.flags & ~DtNodeFlags.DT_NODE_CLOSED);
|
||||||
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
|
||||||
neighbourNode.total = total;
|
neighbourNode.total = total;
|
||||||
|
|
||||||
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
|
if ((neighbourNode.flags & DtNodeFlags.DT_NODE_OPEN) != 0)
|
||||||
{
|
{
|
||||||
m_openList.Modify(neighbourNode);
|
m_openList.Modify(neighbourNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
|
neighbourNode.flags |= DtNodeFlags.DT_NODE_OPEN;
|
||||||
m_openList.Push(neighbourNode);
|
m_openList.Push(neighbourNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3365,7 +3365,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
DtNode endNode = nodes[0];
|
DtNode endNode = nodes[0];
|
||||||
if ((endNode.flags & DT_NODE_CLOSED) == 0)
|
if ((endNode.flags & DtNodeFlags.DT_NODE_CLOSED) == 0)
|
||||||
{
|
{
|
||||||
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
@ -3415,7 +3415,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
foreach (DtNode n in m_nodePool.FindNodes(refs))
|
foreach (DtNode n in m_nodePool.FindNodes(refs))
|
||||||
{
|
{
|
||||||
if ((n.flags & DT_NODE_CLOSED) != 0)
|
if ((n.flags & DtNodeFlags.DT_NODE_CLOSED) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,6 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public class DtNode
|
public class DtNode
|
||||||
{
|
{
|
||||||
public const int DT_NODE_OPEN = 0x01;
|
|
||||||
public const int DT_NODE_CLOSED = 0x02;
|
|
||||||
|
|
||||||
/** parent of the node is not adjacent. Found using raycast. */
|
|
||||||
public const int DT_NODE_PARENT_DETACHED = 0x04;
|
|
||||||
|
|
||||||
public readonly int index;
|
public readonly int index;
|
||||||
|
|
||||||
/** Position of the node. */
|
/** Position of the node. */
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace DotRecast.Detour
|
||||||
|
{
|
||||||
|
public static class DtNodeFlags
|
||||||
|
{
|
||||||
|
public const int DT_NODE_OPEN = 0x01;
|
||||||
|
public const int DT_NODE_CLOSED = 0x02;
|
||||||
|
public const int DT_NODE_PARENT_DETACHED = 0x04; // parent of the node is not adjacent. Found using raycast.
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue