forked from bit/DotRecastNetSim
[Upstream] Performance optimizations based on discussion by recast4j #149
This commit is contained in:
parent
9a4ed56eed
commit
971e07fde4
|
@ -3407,7 +3407,7 @@ namespace DotRecast.Detour
|
||||||
DtNode curNode = endNode;
|
DtNode curNode = endNode;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
path.Insert(0, curNode.id);
|
path.Add(curNode.id);
|
||||||
DtNode nextNode = m_nodePool.GetNodeAtIdx(curNode.pidx);
|
DtNode nextNode = m_nodePool.GetNodeAtIdx(curNode.pidx);
|
||||||
if (curNode.shortcut != null)
|
if (curNode.shortcut != null)
|
||||||
{
|
{
|
||||||
|
@ -3417,14 +3417,14 @@ namespace DotRecast.Detour
|
||||||
long id = curNode.shortcut[i];
|
long id = curNode.shortcut[i];
|
||||||
if (id != curNode.id && id != nextNode.id)
|
if (id != curNode.id && id != nextNode.id)
|
||||||
{
|
{
|
||||||
path.Insert(0, id);
|
path.Add(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
curNode = nextNode;
|
curNode = nextNode;
|
||||||
} while (curNode != null);
|
} while (curNode != null);
|
||||||
|
path.Reverse();
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,23 +74,21 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodes = new List<DtNode>();
|
||||||
|
m_map.Add(id, nodes);
|
||||||
|
}
|
||||||
|
|
||||||
return Create(id, state);
|
return Create(id, state, nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DtNode Create(long id, int state)
|
private DtNode Create(long id, int state, List<DtNode> nodes)
|
||||||
{
|
{
|
||||||
DtNode node = new DtNode(m_nodes.Count + 1);
|
DtNode node = new DtNode(m_nodes.Count + 1);
|
||||||
node.id = id;
|
node.id = id;
|
||||||
node.state = state;
|
node.state = state;
|
||||||
m_nodes.Add(node);
|
m_nodes.Add(node);
|
||||||
var hasNode = m_map.TryGetValue(id, out var nodes);
|
|
||||||
;
|
|
||||||
if (nodes == null)
|
|
||||||
{
|
|
||||||
nodes = new List<DtNode>();
|
|
||||||
m_map.Add(id, nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.Add(node);
|
nodes.Add(node);
|
||||||
return node;
|
return node;
|
||||||
|
|
Loading…
Reference in New Issue