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