forked from bit/DotRecastNetSim
feat: add random point count
This commit is contained in:
parent
fccc6fa2e7
commit
54e8835cb7
|
@ -35,6 +35,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
private int _straightPathOption;
|
private int _straightPathOption;
|
||||||
|
|
||||||
// for random point in circle mode
|
// for random point in circle mode
|
||||||
|
private int _randomPointCount = 300;
|
||||||
private bool _constrainByCircle;
|
private bool _constrainByCircle;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -126,6 +127,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
if (_mode == RcTestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE)
|
if (_mode == RcTestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE)
|
||||||
{
|
{
|
||||||
|
ImGui.SliderInt("Random point count", ref _randomPointCount, 0, 10000);
|
||||||
ImGui.Checkbox("Constrained", ref _constrainByCircle);
|
ImGui.Checkbox("Constrained", ref _constrainByCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +763,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
var refs = new List<long>();
|
var refs = new List<long>();
|
||||||
var parentRefs = new List<long>();
|
var parentRefs = new List<long>();
|
||||||
|
|
||||||
var status = _tool.FindPolysAroundShape(navQuery, settings, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs, out var queryPoly);
|
var status = _tool.FindPolysAroundShape(navQuery, settings.agentHeight, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs, out var queryPoly);
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
{
|
{
|
||||||
m_queryPoly = queryPoly;
|
m_queryPoly = queryPoly;
|
||||||
|
@ -791,7 +793,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
if (m_sposSet && m_startRef != 0 && m_eposSet)
|
if (m_sposSet && m_startRef != 0 && m_eposSet)
|
||||||
{
|
{
|
||||||
var points = new List<RcVec3f>();
|
var points = new List<RcVec3f>();
|
||||||
_tool.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, _constrainByCircle, 500, ref points);
|
_tool.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, _constrainByCircle, _randomPointCount, ref points);
|
||||||
randomPoints.AddRange(points);
|
randomPoints.AddRange(points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,11 +269,10 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
return navQuery.FindPolysAroundCircle(startRef, spos, dist, filter, ref resultRef, ref resultParent, ref costs);
|
return navQuery.FindPolysAroundCircle(startRef, spos, dist, filter, ref resultRef, ref resultParent, ref costs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtStatus FindPolysAroundShape(DtNavMeshQuery navQuery, RcNavMeshBuildSettings settings, long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List<long> resultRef, ref List<long> resultParent, out RcVec3f[] queryPoly)
|
public DtStatus FindPolysAroundShape(DtNavMeshQuery navQuery, float agentHeight, long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List<long> resultRef, ref List<long> resultParent, out RcVec3f[] queryPoly)
|
||||||
{
|
{
|
||||||
float nx = (epos.z - spos.z) * 0.25f;
|
float nx = (epos.z - spos.z) * 0.25f;
|
||||||
float nz = -(epos.x - spos.x) * 0.25f;
|
float nz = -(epos.x - spos.x) * 0.25f;
|
||||||
float agentHeight = settings != null ? settings.agentHeight : 0;
|
|
||||||
|
|
||||||
queryPoly = new RcVec3f[4];
|
queryPoly = new RcVec3f[4];
|
||||||
queryPoly[0].x = spos.x + nx * 1.2f;
|
queryPoly[0].x = spos.x + nx * 1.2f;
|
||||||
|
|
Loading…
Reference in New Issue