forked from mirror/DotRecast
add ISampleTool Idiom
This commit is contained in:
parent
51de2c88f9
commit
a8aafc8491
|
@ -25,6 +25,7 @@ using DotRecast.Recast.DemoTool.Builder;
|
||||||
using DotRecast.Recast.Demo.Draw;
|
using DotRecast.Recast.Demo.Draw;
|
||||||
using DotRecast.Recast.DemoTool;
|
using DotRecast.Recast.DemoTool;
|
||||||
using DotRecast.Recast.DemoTool.Geom;
|
using DotRecast.Recast.DemoTool.Geom;
|
||||||
|
using DotRecast.Recast.DemoTool.Tools;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
||||||
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
||||||
|
@ -33,6 +34,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class ConvexVolumeTool : IRcTool
|
public class ConvexVolumeTool : IRcTool
|
||||||
{
|
{
|
||||||
|
private readonly ConvexVolumeToolImpl _impl;
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
||||||
private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
||||||
|
@ -42,6 +44,16 @@ public class ConvexVolumeTool : IRcTool
|
||||||
private readonly List<float> pts = new();
|
private readonly List<float> pts = new();
|
||||||
private readonly List<int> hull = new();
|
private readonly List<int> hull = new();
|
||||||
|
|
||||||
|
public ConvexVolumeTool()
|
||||||
|
{
|
||||||
|
_impl = new ConvexVolumeToolImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -225,19 +237,12 @@ public class ConvexVolumeTool : IRcTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Create Convex Volumes";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleUpdate(float dt)
|
public void HandleUpdate(float dt)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,6 +37,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class CrowdTool : IRcTool
|
public class CrowdTool : IRcTool
|
||||||
{
|
{
|
||||||
|
private readonly CrowdToolImpl _impl;
|
||||||
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
private DtNavMesh m_nav;
|
private DtNavMesh m_nav;
|
||||||
|
@ -55,6 +56,12 @@ public class CrowdTool : IRcTool
|
||||||
{
|
{
|
||||||
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
||||||
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
||||||
|
_impl = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
|
@ -788,10 +795,6 @@ public class CrowdTool : IRcTool
|
||||||
return updateFlags;
|
return updateFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Crowd";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class DynamicUpdateTool : IRcTool
|
public class DynamicUpdateTool : IRcTool
|
||||||
{
|
{
|
||||||
|
private readonly DynamicUpdateToolImpl _impl;
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
||||||
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
||||||
|
@ -87,12 +88,18 @@ public class DynamicUpdateTool : IRcTool
|
||||||
|
|
||||||
public DynamicUpdateTool()
|
public DynamicUpdateTool()
|
||||||
{
|
{
|
||||||
|
_impl = 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"));
|
||||||
convexGeom = DemoObjImporter.Load(Loader.ToBytes("convex.obj"));
|
convexGeom = DemoObjImporter.Load(Loader.ToBytes("convex.obj"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -744,9 +751,4 @@ public class DynamicUpdateTool : IRcTool
|
||||||
filterLedgeSpans = dynaMesh.config.filterLedgeSpans;
|
filterLedgeSpans = dynaMesh.config.filterLedgeSpans;
|
||||||
filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans;
|
filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Dynamic Updates";
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public interface IRcTool
|
public interface IRcTool
|
||||||
{
|
{
|
||||||
string GetName();
|
ISampleTool GetTool();
|
||||||
void Layout();
|
void Layout();
|
||||||
|
|
||||||
void SetSample(Sample sample);
|
void SetSample(Sample sample);
|
||||||
|
|
|
@ -32,12 +32,24 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class JumpLinkBuilderTool : IRcTool
|
public class JumpLinkBuilderTool : IRcTool
|
||||||
{
|
{
|
||||||
|
private readonly JumpLinkBuilderToolImpl _impl;
|
||||||
private readonly List<JumpLink> links = new();
|
private readonly List<JumpLink> links = new();
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
private JumpLinkBuilder annotationBuilder;
|
private JumpLinkBuilder annotationBuilder;
|
||||||
private readonly int selEdge = -1;
|
private readonly int selEdge = -1;
|
||||||
private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams();
|
private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams();
|
||||||
|
|
||||||
|
|
||||||
|
public JumpLinkBuilderTool()
|
||||||
|
{
|
||||||
|
_impl = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -385,7 +397,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
float agentRadius = settings.agentRadius;
|
float agentRadius = settings.agentRadius;
|
||||||
float agentClimb = settings.agentMaxClimb;
|
float agentClimb = settings.agentMaxClimb;
|
||||||
float cellHeight = settings.cellHeight;
|
float cellHeight = settings.cellHeight;
|
||||||
|
|
||||||
if ((option.buildTypes & JumpLinkType.EDGE_CLIMB_DOWN.Bit) != 0)
|
if ((option.buildTypes & JumpLinkType.EDGE_CLIMB_DOWN.Bit) != 0)
|
||||||
{
|
{
|
||||||
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(cellSize, cellHeight, agentRadius,
|
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(cellSize, cellHeight, agentRadius,
|
||||||
|
@ -445,10 +457,6 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Annotation Builder";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ using DotRecast.Recast.DemoTool.Builder;
|
||||||
using DotRecast.Recast.Demo.Draw;
|
using DotRecast.Recast.Demo.Draw;
|
||||||
using DotRecast.Recast.DemoTool;
|
using DotRecast.Recast.DemoTool;
|
||||||
using DotRecast.Recast.DemoTool.Geom;
|
using DotRecast.Recast.DemoTool.Geom;
|
||||||
|
using DotRecast.Recast.DemoTool.Tools;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
||||||
|
|
||||||
|
@ -31,11 +32,22 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class OffMeshConnectionTool : IRcTool
|
public class OffMeshConnectionTool : IRcTool
|
||||||
{
|
{
|
||||||
|
private readonly OffMeshConnectionToolImpl _impl;
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
private bool hitPosSet;
|
private bool hitPosSet;
|
||||||
private RcVec3f hitPos;
|
private RcVec3f hitPos;
|
||||||
private int bidir;
|
private int bidir;
|
||||||
|
|
||||||
|
public OffMeshConnectionTool()
|
||||||
|
{
|
||||||
|
_impl = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -116,19 +128,13 @@ public class OffMeshConnectionTool : IRcTool
|
||||||
ImGui.RadioButton("Bidirectional", ref bidir, 1);
|
ImGui.RadioButton("Bidirectional", ref bidir, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Create Off-Mesh Links";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleUpdate(float dt)
|
public void HandleUpdate(float dt)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,11 +13,14 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
||||||
|
|
||||||
namespace DotRecast.Recast.Demo.Tools;
|
namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class TestNavmeshTool : IRcTool
|
public class TestNavmeshTool : IRcTool
|
||||||
{
|
{
|
||||||
private const int MAX_POLYS = 256;
|
private const int MAX_POLYS = 256;
|
||||||
private const int MAX_SMOOTH = 2048;
|
private const int MAX_SMOOTH = 2048;
|
||||||
|
|
||||||
|
private readonly TestNavmeshToolImpl _impl;
|
||||||
private Sample _sample;
|
private Sample _sample;
|
||||||
|
|
||||||
private int m_toolModeIdx = TestNavmeshToolMode.PATHFIND_FOLLOW.Idx;
|
private int m_toolModeIdx = TestNavmeshToolMode.PATHFIND_FOLLOW.Idx;
|
||||||
|
@ -51,6 +54,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
public TestNavmeshTool()
|
public TestNavmeshTool()
|
||||||
{
|
{
|
||||||
|
_impl = 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,
|
||||||
|
@ -58,6 +62,11 @@ public class TestNavmeshTool : IRcTool
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISampleTool GetTool()
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
@ -157,10 +166,6 @@ public class TestNavmeshTool : IRcTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return "Test Navmesh";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Recalc()
|
private void Recalc()
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class RcToolsetView : IRcView
|
||||||
for (int i = 0; i < tools.Length; ++i)
|
for (int i = 0; i < tools.Length; ++i)
|
||||||
{
|
{
|
||||||
var tool = tools[i];
|
var tool = tools[i];
|
||||||
ImGui.RadioButton(tool.GetName(), ref _currentToolIdx, i);
|
ImGui.RadioButton(tool.GetTool().GetName(), ref _currentToolIdx, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
|
@ -76,7 +76,7 @@ public class RcToolsetView : IRcView
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTool = tools[_currentToolIdx];
|
currentTool = tools[_currentToolIdx];
|
||||||
ImGui.Text(currentTool.GetName());
|
ImGui.Text(currentTool.GetTool().GetName());
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
currentTool.Layout();
|
currentTool.Layout();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool
|
||||||
|
{
|
||||||
|
public interface ISampleTool
|
||||||
|
{
|
||||||
|
string GetName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class ConvexVolumeToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Create Convex Volumes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class CrowdToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Crowd";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class DynamicUpdateToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Dynamic Updates";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class JumpLinkBuilderToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Annotation Builder";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class OffMeshConnectionToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Create Off-Mesh Links";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace DotRecast.Recast.DemoTool.Tools
|
||||||
|
{
|
||||||
|
public class TestNavmeshToolImpl : ISampleTool
|
||||||
|
{
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "Test Navmesh";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue