forked from bit/DotRecastNetSim
ready obstacle tool
This commit is contained in:
parent
e98ff8bec7
commit
356a4c4e0d
|
@ -436,7 +436,7 @@ namespace DotRecast.Detour.TileCache
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<long> QueryTiles(RcVec3f bmin, RcVec3f bmax)
|
private List<long> QueryTiles(RcVec3f bmin, RcVec3f bmax)
|
||||||
{
|
{
|
||||||
List<long> results = new List<long>();
|
List<long> results = new List<long>();
|
||||||
float tw = m_params.width * m_params.cs;
|
float tw = m_params.width * m_params.cs;
|
||||||
|
@ -468,12 +468,12 @@ namespace DotRecast.Detour.TileCache
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
|
* Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
|
||||||
*
|
*
|
||||||
* @return Returns true if the tile cache is fully up to date with obstacle requests and tile rebuilds. If the tile
|
* @return Returns true if the tile cache is fully up to date with obstacle requests and tile rebuilds. If the tile
|
||||||
* cache is up to date another (immediate) call to update will have no effect; otherwise another call will
|
* cache is up to date another (immediate) call to update will have no effect; otherwise another call will
|
||||||
* continue processing obstacle requests and tile rebuilds.
|
* continue processing obstacle requests and tile rebuilds.
|
||||||
*/
|
*/
|
||||||
public bool Update()
|
public bool Update()
|
||||||
{
|
{
|
||||||
if (0 == m_update.Count)
|
if (0 == m_update.Count)
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class ConvexVolumeSampleTool : ISampleTool
|
||||||
private static readonly ILogger Logger = Log.ForContext<ConvexVolumeSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<ConvexVolumeSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcConvexVolumeTool _impl;
|
private readonly RcConvexVolumeTool _tool;
|
||||||
|
|
||||||
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
||||||
private RcAreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
private RcAreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
||||||
|
@ -51,12 +51,12 @@ public class ConvexVolumeSampleTool : ISampleTool
|
||||||
|
|
||||||
public ConvexVolumeSampleTool()
|
public ConvexVolumeSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new RcConvexVolumeTool();
|
_tool = new RcConvexVolumeTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
@ -78,7 +78,7 @@ public class ConvexVolumeSampleTool : ISampleTool
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
_impl.RemoveByPos(geom, p);
|
_tool.RemoveByPos(geom, p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ public class ConvexVolumeSampleTool : ISampleTool
|
||||||
var vol = RcConvexVolumeTool.CreateConvexVolume(pts, hull, areaType, boxDescent, boxHeight, polyOffset);
|
var vol = RcConvexVolumeTool.CreateConvexVolume(pts, hull, areaType, boxDescent, boxHeight, polyOffset);
|
||||||
if (null != vol)
|
if (null != vol)
|
||||||
{
|
{
|
||||||
_impl.Add(geom, vol);
|
_tool.Add(geom, vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
pts.Clear();
|
pts.Clear();
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class CrowdSampleTool : ISampleTool
|
||||||
private static readonly ILogger Logger = Log.ForContext<CrowdSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<CrowdSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcCrowdTool _impl;
|
private readonly RcCrowdTool _tool;
|
||||||
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
||||||
private DtNavMesh m_nav;
|
private DtNavMesh m_nav;
|
||||||
private DtCrowd crowd;
|
private DtCrowd crowd;
|
||||||
|
@ -58,12 +58,12 @@ public class CrowdSampleTool : ISampleTool
|
||||||
{
|
{
|
||||||
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
||||||
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
||||||
_impl = new();
|
_tool = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class DynamicUpdateSampleTool : ISampleTool
|
||||||
private static readonly ILogger Logger = Log.ForContext<DynamicUpdateSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<DynamicUpdateSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcDynamicUpdateTool _impl;
|
private readonly RcDynamicUpdateTool _tool;
|
||||||
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
||||||
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
||||||
private float cellSize = 0.3f;
|
private float cellSize = 0.3f;
|
||||||
|
@ -91,7 +91,7 @@ public class DynamicUpdateSampleTool : ISampleTool
|
||||||
|
|
||||||
public DynamicUpdateSampleTool()
|
public DynamicUpdateSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_tool = new();
|
||||||
executor = Task.Factory;
|
executor = Task.Factory;
|
||||||
bridgeGeom = DemoObjImporter.Load(Loader.ToBytes("bridge.obj"));
|
bridgeGeom = DemoObjImporter.Load(Loader.ToBytes("bridge.obj"));
|
||||||
houseGeom = DemoObjImporter.Load(Loader.ToBytes("house.obj"));
|
houseGeom = DemoObjImporter.Load(Loader.ToBytes("house.obj"));
|
||||||
|
@ -100,7 +100,7 @@ public class DynamicUpdateSampleTool : ISampleTool
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
|
|
@ -33,18 +33,18 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
private static readonly ILogger Logger = Log.ForContext<JumpLinkBuilderSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<JumpLinkBuilderSampleTool>();
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
|
|
||||||
private readonly RcJumpLinkBuilderTool _impl;
|
private readonly RcJumpLinkBuilderTool _tool;
|
||||||
private readonly RcJumpLinkBuilderToolOption _option;
|
private readonly RcJumpLinkBuilderToolOption _option;
|
||||||
|
|
||||||
public JumpLinkBuilderSampleTool()
|
public JumpLinkBuilderSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_tool = new();
|
||||||
_option = new();
|
_option = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
@ -54,7 +54,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
|
|
||||||
public void OnSampleChanged()
|
public void OnSampleChanged()
|
||||||
{
|
{
|
||||||
_impl.Clear();
|
_tool.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,13 +69,13 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
RecastDebugDraw dd = renderer.GetDebugDraw();
|
RecastDebugDraw dd = renderer.GetDebugDraw();
|
||||||
dd.DepthMask(false);
|
dd.DepthMask(false);
|
||||||
|
|
||||||
var annotationBuilder = _impl.GetAnnotationBuilder();
|
var annotationBuilder = _tool.GetAnnotationBuilder();
|
||||||
|
|
||||||
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER) != 0)
|
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER) != 0)
|
||||||
{
|
{
|
||||||
if (annotationBuilder != null)
|
if (annotationBuilder != null)
|
||||||
{
|
{
|
||||||
var selEdge = _impl.GetSelEdge();
|
var selEdge = _tool.GetSelEdge();
|
||||||
|
|
||||||
foreach (JumpEdge[] edges in annotationBuilder.GetEdges())
|
foreach (JumpEdge[] edges in annotationBuilder.GetEdges())
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_ANNOTATIONS) != 0)
|
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_ANNOTATIONS) != 0)
|
||||||
{
|
{
|
||||||
dd.Begin(QUADS);
|
dd.Begin(QUADS);
|
||||||
foreach (JumpLink link in _impl.GetLinks())
|
foreach (JumpLink link in _tool.GetLinks())
|
||||||
{
|
{
|
||||||
for (int j = 0; j < link.nspine - 1; ++j)
|
for (int j = 0; j < link.nspine - 1; ++j)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
|
|
||||||
dd.End();
|
dd.End();
|
||||||
dd.Begin(LINES, 3.0f);
|
dd.Begin(LINES, 3.0f);
|
||||||
foreach (JumpLink link in _impl.GetLinks())
|
foreach (JumpLink link in _tool.GetLinks())
|
||||||
{
|
{
|
||||||
for (int j = 0; j < link.nspine - 1; ++j)
|
for (int j = 0; j < link.nspine - 1; ++j)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
|
|
||||||
if (annotationBuilder != null)
|
if (annotationBuilder != null)
|
||||||
{
|
{
|
||||||
foreach (JumpLink link in _impl.GetLinks())
|
foreach (JumpLink link in _tool.GetLinks())
|
||||||
{
|
{
|
||||||
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY) != 0)
|
if ((_option.flags & RcJumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY) != 0)
|
||||||
{
|
{
|
||||||
|
@ -389,7 +389,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
|
||||||
var geom = _sample.GetInputGeom();
|
var geom = _sample.GetInputGeom();
|
||||||
var settings = _sample.GetSettings();
|
var settings = _sample.GetSettings();
|
||||||
|
|
||||||
_impl.Build(
|
_tool.Build(
|
||||||
geom, settings, _sample.GetRecastResults(),
|
geom, settings, _sample.GetRecastResults(),
|
||||||
buildOffMeshConnections,
|
buildOffMeshConnections,
|
||||||
_option.buildTypes,
|
_option.buildTypes,
|
||||||
|
|
|
@ -11,23 +11,23 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
public class ObstacleSampleTool : ISampleTool
|
public class ObstacleSampleTool : ISampleTool
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Log.ForContext<ObstacleSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<ObstacleSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
|
|
||||||
private readonly RcObstacleTool _impl;
|
private readonly RcObstacleTool _tool;
|
||||||
private bool _hitPosSet;
|
private bool _hitPosSet;
|
||||||
private RcVec3f _hitPos;
|
private RcVec3f _hitPos;
|
||||||
|
|
||||||
public ObstacleSampleTool()
|
public ObstacleSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new(DtTileCacheCompressorFactory.Shared);
|
_tool = new(DtTileCacheCompressorFactory.Shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -39,9 +39,17 @@ public class ObstacleSampleTool : ISampleTool
|
||||||
|
|
||||||
public void Layout()
|
public void Layout()
|
||||||
{
|
{
|
||||||
|
if (ImGui.Button("Build Tile Cache"))
|
||||||
|
{
|
||||||
|
var geom = _sample.GetInputGeom();
|
||||||
|
var settings = _sample.GetSettings();
|
||||||
|
|
||||||
|
_tool.Build(geom, settings, RcByteOrder.LITTLE_ENDIAN, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui.Button("Remove All Temp Obstacles"))
|
if (ImGui.Button("Remove All Temp Obstacles"))
|
||||||
{
|
{
|
||||||
_impl.ClearAllTempObstacles();
|
_tool.ClearAllTempObstacles();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
@ -57,11 +65,11 @@ public class ObstacleSampleTool : ISampleTool
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
_impl.RemoveTempObstacle(s, p);
|
_tool.RemoveTempObstacle(s, p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_impl.AddTempObstacle(_hitPos);
|
_tool.AddTempObstacle(_hitPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,18 +36,18 @@ public class OffMeshConnectionSampleTool : ISampleTool
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
|
|
||||||
private readonly RcOffMeshConnectionTool _impl;
|
private readonly RcOffMeshConnectionTool _tool;
|
||||||
private bool hitPosSet;
|
private bool hitPosSet;
|
||||||
private RcVec3f hitPos;
|
private RcVec3f hitPos;
|
||||||
|
|
||||||
public OffMeshConnectionSampleTool()
|
public OffMeshConnectionSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_tool = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
@ -72,7 +72,7 @@ public class OffMeshConnectionSampleTool : ISampleTool
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
_impl.Remove(geom, settings, p);
|
_tool.Remove(geom, settings, p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ public class OffMeshConnectionSampleTool : ISampleTool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_impl.Add(geom, settings, hitPos, p);
|
_tool.Add(geom, settings, hitPos, p);
|
||||||
hitPosSet = false;
|
hitPosSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class OffMeshConnectionSampleTool : ISampleTool
|
||||||
|
|
||||||
public void Layout()
|
public void Layout()
|
||||||
{
|
{
|
||||||
var options = _impl.GetOption();
|
var options = _tool.GetOption();
|
||||||
ImGui.RadioButton("One Way", ref options.bidir, 0);
|
ImGui.RadioButton("One Way", ref options.bidir, 0);
|
||||||
ImGui.RadioButton("Bidirectional", ref options.bidir, 1);
|
ImGui.RadioButton("Bidirectional", ref options.bidir, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
private const int MAX_POLYS = 256;
|
private const int MAX_POLYS = 256;
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcTestNavMeshTool _impl;
|
private readonly RcTestNavMeshTool _tool;
|
||||||
|
|
||||||
private bool m_sposSet;
|
private bool m_sposSet;
|
||||||
private bool m_eposSet;
|
private bool m_eposSet;
|
||||||
|
@ -49,7 +49,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
public TestNavmeshSampleTool()
|
public TestNavmeshSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_tool = new();
|
||||||
m_filter = new DtQueryDefaultFilter(
|
m_filter = new DtQueryDefaultFilter(
|
||||||
SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
||||||
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED,
|
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED,
|
||||||
|
@ -59,7 +59,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
@ -91,7 +91,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
public void Layout()
|
public void Layout()
|
||||||
{
|
{
|
||||||
var option = _impl.GetOption();
|
var option = _tool.GetOption();
|
||||||
var previousToolMode = option.mode;
|
var previousToolMode = option.mode;
|
||||||
int previousStraightPathOptions = option.straightPathOptions;
|
int previousStraightPathOptions = option.straightPathOptions;
|
||||||
int previousIncludeFlags = m_filter.GetIncludeFlags();
|
int previousIncludeFlags = m_filter.GetIncludeFlags();
|
||||||
|
@ -197,7 +197,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
m_endRef = 0;
|
m_endRef = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var option = _impl.GetOption();
|
var option = _tool.GetOption();
|
||||||
|
|
||||||
if (option.mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
if (option.mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
||||||
{
|
{
|
||||||
|
@ -206,7 +206,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
var polys = new List<long>();
|
var polys = new List<long>();
|
||||||
var smoothPath = new List<RcVec3f>();
|
var smoothPath = new List<RcVec3f>();
|
||||||
|
|
||||||
var status = _impl.FindFollowPath(navMesh, navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast,
|
var status = _tool.FindFollowPath(navMesh, navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast,
|
||||||
ref polys, ref smoothPath);
|
ref polys, ref smoothPath);
|
||||||
|
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
|
@ -227,7 +227,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
{
|
{
|
||||||
var polys = new List<long>();
|
var polys = new List<long>();
|
||||||
var straightPath = new List<StraightPathItem>();
|
var straightPath = new List<StraightPathItem>();
|
||||||
var status = _impl.FindStraightPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast,
|
var status = _tool.FindStraightPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast,
|
||||||
ref polys, ref straightPath, option.straightPathOptions);
|
ref polys, ref straightPath, option.straightPathOptions);
|
||||||
|
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
|
@ -248,7 +248,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
|
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
|
||||||
{
|
{
|
||||||
m_pathFindStatus = _impl.InitSlicedFindPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast);
|
m_pathFindStatus = _tool.InitSlicedFindPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, option.enableRaycast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (option.mode == RcTestNavmeshToolMode.RAYCAST)
|
else if (option.mode == RcTestNavmeshToolMode.RAYCAST)
|
||||||
|
@ -258,7 +258,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
{
|
{
|
||||||
var polys = new List<long>();
|
var polys = new List<long>();
|
||||||
var straightPath = new List<StraightPathItem>();
|
var straightPath = new List<StraightPathItem>();
|
||||||
var status = _impl.Raycast(navQuery, m_startRef, m_spos, m_epos, m_filter,
|
var status = _tool.Raycast(navQuery, m_startRef, m_spos, m_epos, m_filter,
|
||||||
ref polys, ref straightPath, out var hitPos, out var hitNormal, out var hitResult);
|
ref polys, ref straightPath, out var hitPos, out var hitNormal, out var hitResult);
|
||||||
|
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
|
@ -292,7 +292,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
List<long> refs = new();
|
List<long> refs = new();
|
||||||
List<long> parentRefs = new();
|
List<long> parentRefs = new();
|
||||||
|
|
||||||
var status = _impl.FindPolysAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs);
|
var status = _tool.FindPolysAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs);
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
{
|
{
|
||||||
m_polys = refs;
|
m_polys = refs;
|
||||||
|
@ -307,7 +307,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 = _impl.FindPolysAroundShape(navQuery, settings, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs, out var queryPoly);
|
var status = _tool.FindPolysAroundShape(navQuery, settings, 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;
|
||||||
|
@ -337,7 +337,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>();
|
||||||
_impl.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, option.constrainByCircle, 500, ref points);
|
_tool.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, option.constrainByCircle, 500, ref points);
|
||||||
randomPoints.AddRange(points);
|
randomPoints.AddRange(points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var option = _impl.GetOption();
|
var option = _tool.GetOption();
|
||||||
if (option.mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
if (option.mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
||||||
{
|
{
|
||||||
dd.DebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
|
dd.DebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||||
|
@ -791,7 +791,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
public void HandleUpdate(float dt)
|
public void HandleUpdate(float dt)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
var option = _impl.GetOption();
|
var option = _tool.GetOption();
|
||||||
if (option.mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
|
if (option.mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
|
||||||
{
|
{
|
||||||
DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery();
|
DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery();
|
||||||
|
|
|
@ -15,19 +15,19 @@ public class TileSampleTool : ISampleTool
|
||||||
private static readonly ILogger Logger = Log.ForContext<TileSampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<TileSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcTileTool _impl;
|
private readonly RcTileTool _tool;
|
||||||
|
|
||||||
private bool _hitPosSet;
|
private bool _hitPosSet;
|
||||||
private RcVec3f _hitPos;
|
private RcVec3f _hitPos;
|
||||||
|
|
||||||
public TileSampleTool()
|
public TileSampleTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_tool = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _impl;
|
return _tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(DemoSample sample)
|
public void SetSample(DemoSample sample)
|
||||||
|
@ -47,12 +47,12 @@ public class TileSampleTool : ISampleTool
|
||||||
|
|
||||||
if (ImGui.Button("Create All Tile"))
|
if (ImGui.Button("Create All Tile"))
|
||||||
{
|
{
|
||||||
_impl.BuildAllTiles(geom, settings, navMesh);
|
_tool.BuildAllTiles(geom, settings, navMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.Button("Remove All Tile"))
|
if (ImGui.Button("Remove All Tile"))
|
||||||
{
|
{
|
||||||
_impl.RemoveAllTiles(geom, settings, navMesh);
|
_tool.RemoveAllTiles(geom, settings, navMesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ public class TileSampleTool : ISampleTool
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
_impl.RemoveTile(geom, settings, navMesh, _hitPos);
|
_tool.RemoveTile(geom, settings, navMesh, _hitPos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool built = _impl.BuildTile(geom, settings, navMesh, _hitPos, out var tileBuildTicks, out var tileTriCount, out var tileMemUsage);
|
bool built = _tool.BuildTile(geom, settings, navMesh, _hitPos, out var tileBuildTicks, out var tileTriCount, out var tileMemUsage);
|
||||||
if (!built)
|
if (!built)
|
||||||
{
|
{
|
||||||
Logger.Error($"failed to build tile - check!");
|
Logger.Error($"failed to build tile - check!");
|
||||||
|
|
|
@ -24,19 +24,33 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
return "Create Temp Obstacles";
|
return "Create Temp Obstacles";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Build(IInputGeomProvider geom, RcNavMeshBuildSettings setting, RcByteOrder order, bool cCompatibility)
|
||||||
|
{
|
||||||
|
_tc = CreateTileCache(geom, setting, order, cCompatibility);
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearAllTempObstacles()
|
public void ClearAllTempObstacles()
|
||||||
{
|
{
|
||||||
|
if (null == _tc)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveTempObstacle(RcVec3f sp, RcVec3f sq)
|
public void RemoveTempObstacle(RcVec3f sp, RcVec3f sq)
|
||||||
{
|
{
|
||||||
// ..
|
if (null == _tc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//DtObstacleRef refs = hitTestObstacle(m_tileCache, sp, sq);
|
||||||
|
//_tc.RemoveObstacle(refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTempObstacle(RcVec3f pos)
|
public void AddTempObstacle(RcVec3f p)
|
||||||
{
|
{
|
||||||
//p[1] -= 0.5f;
|
if (null == _tc)
|
||||||
//m_tileCache->addObstacle(p, 1.0f, 2.0f, 0);
|
return;
|
||||||
|
|
||||||
|
p.y -= 0.5f;
|
||||||
|
_tc.AddObstacle(p, 1.0f, 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtTileCache CreateTileCache(IInputGeomProvider geom, RcNavMeshBuildSettings setting, RcByteOrder order, bool cCompatibility)
|
public DtTileCache CreateTileCache(IInputGeomProvider geom, RcNavMeshBuildSettings setting, RcByteOrder order, bool cCompatibility)
|
||||||
|
|
Loading…
Reference in New Issue