forked from mirror/DotRecast
change GetNodeMap to AsEnumerable in DtNodePool
This commit is contained in:
parent
3ce4f59002
commit
b26847d90f
|
@ -19,6 +19,7 @@ freely, subject to the following restrictions:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,11 @@ namespace DotRecast.Detour
|
||||||
m_nodeCount = 0;
|
m_nodeCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetNodeCount()
|
||||||
|
{
|
||||||
|
return m_nodeCount;
|
||||||
|
}
|
||||||
|
|
||||||
public int FindNodes(long id, out List<DtNode> nodes)
|
public int FindNodes(long id, out List<DtNode> nodes)
|
||||||
{
|
{
|
||||||
var hasNode = m_map.TryGetValue(id, out nodes);
|
var hasNode = m_map.TryGetValue(id, out nodes);
|
||||||
|
@ -127,9 +133,9 @@ namespace DotRecast.Detour
|
||||||
return GetNode(refs, 0);
|
return GetNode(refs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<long, List<DtNode>> GetNodeMap()
|
public IEnumerable<DtNode> AsEnumerable()
|
||||||
{
|
{
|
||||||
return m_map;
|
return m_nodes.Take(m_nodeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1200,9 +1200,7 @@ public class RecastDebugDraw : DebugDraw
|
||||||
float off = 0.5f;
|
float off = 0.5f;
|
||||||
Begin(DebugDrawPrimitives.POINTS, 4.0f);
|
Begin(DebugDrawPrimitives.POINTS, 4.0f);
|
||||||
|
|
||||||
foreach (List<DtNode> nodes in pool.GetNodeMap().Values)
|
foreach (DtNode node in pool.AsEnumerable())
|
||||||
{
|
|
||||||
foreach (DtNode node in nodes)
|
|
||||||
{
|
{
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
|
@ -1211,14 +1209,11 @@ public class RecastDebugDraw : DebugDraw
|
||||||
|
|
||||||
Vertex(node.pos.X, node.pos.Y + off, node.pos.Z, DuRGBA(255, 192, 0, 255));
|
Vertex(node.pos.X, node.pos.Y + off, node.pos.Z, DuRGBA(255, 192, 0, 255));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
End();
|
End();
|
||||||
|
|
||||||
Begin(DebugDrawPrimitives.LINES, 2.0f);
|
Begin(DebugDrawPrimitives.LINES, 2.0f);
|
||||||
foreach (List<DtNode> nodes in pool.GetNodeMap().Values)
|
foreach (DtNode node in pool.AsEnumerable())
|
||||||
{
|
|
||||||
foreach (DtNode node in nodes)
|
|
||||||
{
|
{
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
|
@ -1239,7 +1234,6 @@ public class RecastDebugDraw : DebugDraw
|
||||||
Vertex(node.pos.X, node.pos.Y + off, node.pos.Z, DuRGBA(255, 192, 0, 128));
|
Vertex(node.pos.X, node.pos.Y + off, node.pos.Z, DuRGBA(255, 192, 0, 128));
|
||||||
Vertex(parent.pos.X, parent.pos.Y + off, parent.pos.Z, DuRGBA(255, 192, 0, 128));
|
Vertex(parent.pos.X, parent.pos.Y + off, parent.pos.Z, DuRGBA(255, 192, 0, 128));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class DtNodePoolTest
|
||||||
Assert.That(nodes, Is.Null);
|
Assert.That(nodes, Is.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalCount = pool.GetNodeMap().Sum(x => x.Value.Count);
|
var totalCount = pool.GetNodeCount();
|
||||||
Assert.That(totalCount, Is.EqualTo(sum));
|
Assert.That(totalCount, Is.EqualTo(sum));
|
||||||
|
|
||||||
pool.Clear();
|
pool.Clear();
|
||||||
totalCount = pool.GetNodeMap().Sum(x => x.Value.Count);
|
totalCount = pool.GetNodeCount();
|
||||||
Assert.That(totalCount, Is.EqualTo(0));
|
Assert.That(totalCount, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue