forked from mirror/DotRecast
for unity3d
This commit is contained in:
parent
bbb9c7816f
commit
70dc963563
|
@ -324,23 +324,9 @@ public class TestNavmeshTool : IRcTool
|
|||
randomPoints.Clear();
|
||||
if (m_sposSet && m_startRef != 0 && m_eposSet)
|
||||
{
|
||||
float dx = m_epos.x - m_spos.x;
|
||||
float dz = m_epos.z - m_spos.z;
|
||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
IPolygonByCircleConstraint constraint = option.constrainByCircle
|
||||
? StrictPolygonByCircleConstraint.Strict
|
||||
: NoOpPolygonByCircleConstraint.Noop;
|
||||
|
||||
var frand = new FRand();
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
var status = m_navQuery.FindRandomPointAroundCircle(m_startRef, m_spos, dist, m_filter, frand, constraint,
|
||||
out var randomRef, out var randomPt);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
randomPoints.Add(randomPt);
|
||||
}
|
||||
}
|
||||
var points = new List<RcVec3f>();
|
||||
_impl.FindRandomPointAroundCircle(m_startRef, m_spos, m_epos, m_filter, option.constrainByCircle, 500, ref points);
|
||||
randomPoints.AddRange(points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,5 +291,34 @@ namespace DotRecast.Recast.DemoTool.Tools
|
|||
var navQuery = _sample.GetNavMeshQuery();
|
||||
return navQuery.FindPolysAroundShape(startRef, queryPoly, filter, ref resultRef, ref resultParent, ref costs);
|
||||
}
|
||||
|
||||
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, bool constrainByCircle, int count, ref List<RcVec3f> points)
|
||||
{
|
||||
float dx = epos.x - spos.x;
|
||||
float dz = epos.z - spos.z;
|
||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
|
||||
IPolygonByCircleConstraint constraint = constrainByCircle
|
||||
? StrictPolygonByCircleConstraint.Strict
|
||||
: NoOpPolygonByCircleConstraint.Noop;
|
||||
|
||||
var frand = new FRand();
|
||||
var navQuery = _sample.GetNavMeshQuery();
|
||||
|
||||
int prevCnt = points.Count;
|
||||
|
||||
while (0 < count && points.Count < prevCnt + count)
|
||||
{
|
||||
var status = navQuery.FindRandomPointAroundCircle(startRef, spos, dist, filter, frand, constraint,
|
||||
out var randomRef, out var randomPt);
|
||||
|
||||
if (status.Succeeded())
|
||||
{
|
||||
points.Add(randomPt);
|
||||
}
|
||||
}
|
||||
|
||||
return DtStatus.DT_SUCCSESS;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue