forked from bit/DotRecastNetSim
mvvm
This commit is contained in:
parent
846e1a9b65
commit
6b30d99651
|
@ -33,10 +33,12 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
public class JumpLinkBuilderTool : IRcTool
|
public class JumpLinkBuilderTool : IRcTool
|
||||||
{
|
{
|
||||||
private readonly JumpLinkBuilderToolImpl _impl;
|
private readonly JumpLinkBuilderToolImpl _impl;
|
||||||
|
private readonly JumpLinkBuilderToolOption _option;
|
||||||
|
|
||||||
public JumpLinkBuilderTool()
|
public JumpLinkBuilderTool()
|
||||||
{
|
{
|
||||||
_impl = new();
|
_impl = new();
|
||||||
|
_option = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISampleTool GetTool()
|
public ISampleTool GetTool()
|
||||||
|
@ -60,10 +62,9 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
RecastDebugDraw dd = renderer.GetDebugDraw();
|
RecastDebugDraw dd = renderer.GetDebugDraw();
|
||||||
dd.DepthMask(false);
|
dd.DepthMask(false);
|
||||||
|
|
||||||
var option = _impl.GetOption();
|
|
||||||
var annotationBuilder = _impl.GetAnnotationBuilder();
|
var annotationBuilder = _impl.GetAnnotationBuilder();
|
||||||
|
|
||||||
if ((option.flags & JumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER) != 0)
|
if ((_option.flags & JumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER) != 0)
|
||||||
{
|
{
|
||||||
if (annotationBuilder != null)
|
if (annotationBuilder != null)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +122,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((option.flags & JumpLinkBuilderToolOption.DRAW_ANNOTATIONS) != 0)
|
if ((_option.flags & JumpLinkBuilderToolOption.DRAW_ANNOTATIONS) != 0)
|
||||||
{
|
{
|
||||||
dd.Begin(QUADS);
|
dd.Begin(QUADS);
|
||||||
foreach (JumpLink link in _impl.GetLinks())
|
foreach (JumpLink link in _impl.GetLinks())
|
||||||
|
@ -172,7 +173,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
{
|
{
|
||||||
foreach (JumpLink link in _impl.GetLinks())
|
foreach (JumpLink link in _impl.GetLinks())
|
||||||
{
|
{
|
||||||
if ((option.flags & JumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY) != 0)
|
if ((_option.flags & JumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY) != 0)
|
||||||
{
|
{
|
||||||
float r = link.start.height;
|
float r = link.start.height;
|
||||||
|
|
||||||
|
@ -238,7 +239,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
dd.End();
|
dd.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((option.flags & JumpLinkBuilderToolOption.DRAW_LAND_SAMPLES) != 0)
|
if ((_option.flags & JumpLinkBuilderToolOption.DRAW_LAND_SAMPLES) != 0)
|
||||||
{
|
{
|
||||||
dd.Begin(POINTS, 8.0f);
|
dd.Begin(POINTS, 8.0f);
|
||||||
for (int i = 0; i < link.start.gsamples.Length; ++i)
|
for (int i = 0; i < link.start.gsamples.Length; ++i)
|
||||||
|
@ -338,33 +339,31 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
if (0 >= _impl.GetSample().GetRecastResults().Count)
|
if (0 >= _impl.GetSample().GetRecastResults().Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var option = _impl.GetOption();
|
|
||||||
|
|
||||||
ImGui.Text("Options");
|
ImGui.Text("Options");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.SliderFloat("Ground Tolerance", ref option.groundTolerance, 0f, 2f, "%.2f");
|
ImGui.SliderFloat("Ground Tolerance", ref _option.groundTolerance, 0f, 2f, "%.2f");
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
|
|
||||||
ImGui.Text("Climb Down");
|
ImGui.Text("Climb Down");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.SliderFloat("Distance", ref option.climbDownDistance, 0f, 5f, "%.2f");
|
ImGui.SliderFloat("Distance", ref _option.climbDownDistance, 0f, 5f, "%.2f");
|
||||||
ImGui.SliderFloat("Min Cliff Height", ref option.climbDownMinHeight, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Min Cliff Height", ref _option.climbDownMinHeight, 0f, 10f, "%.2f");
|
||||||
ImGui.SliderFloat("Max Cliff Height", ref option.climbDownMaxHeight, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Max Cliff Height", ref _option.climbDownMaxHeight, 0f, 10f, "%.2f");
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
|
|
||||||
ImGui.Text("Jump Down");
|
ImGui.Text("Jump Down");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.SliderFloat("Max Distance", ref option.edgeJumpEndDistance, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Max Distance", ref _option.edgeJumpEndDistance, 0f, 10f, "%.2f");
|
||||||
ImGui.SliderFloat("Jump Height", ref option.edgeJumpHeight, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Jump Height", ref _option.edgeJumpHeight, 0f, 10f, "%.2f");
|
||||||
ImGui.SliderFloat("Max Jump Down", ref option.edgeJumpDownMaxHeight, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Max Jump Down", ref _option.edgeJumpDownMaxHeight, 0f, 10f, "%.2f");
|
||||||
ImGui.SliderFloat("Max Jump Up", ref option.edgeJumpUpMaxHeight, 0f, 10f, "%.2f");
|
ImGui.SliderFloat("Max Jump Up", ref _option.edgeJumpUpMaxHeight, 0f, 10f, "%.2f");
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
|
|
||||||
ImGui.Text("Mode");
|
ImGui.Text("Mode");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
//int buildTypes = 0;
|
//int buildTypes = 0;
|
||||||
ImGui.CheckboxFlags("Climb Down", ref option.buildTypes, JumpLinkType.EDGE_CLIMB_DOWN.Bit);
|
ImGui.CheckboxFlags("Climb Down", ref _option.buildTypes, JumpLinkType.EDGE_CLIMB_DOWN.Bit);
|
||||||
ImGui.CheckboxFlags("Edge Jump", ref option.buildTypes, JumpLinkType.EDGE_JUMP.Bit);
|
ImGui.CheckboxFlags("Edge Jump", ref _option.buildTypes, JumpLinkType.EDGE_JUMP.Bit);
|
||||||
//option.buildTypes = buildTypes;
|
//option.buildTypes = buildTypes;
|
||||||
bool build = false;
|
bool build = false;
|
||||||
bool buildOffMeshConnections = false;
|
bool buildOffMeshConnections = false;
|
||||||
|
@ -380,17 +379,27 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
|
|
||||||
if (build || buildOffMeshConnections)
|
if (build || buildOffMeshConnections)
|
||||||
{
|
{
|
||||||
_impl.Build(buildOffMeshConnections);
|
_impl.Build(buildOffMeshConnections,
|
||||||
|
_option.buildTypes,
|
||||||
|
_option.groundTolerance,
|
||||||
|
_option.climbDownDistance,
|
||||||
|
_option.climbDownMaxHeight,
|
||||||
|
_option.climbDownMinHeight,
|
||||||
|
_option.edgeJumpEndDistance,
|
||||||
|
_option.edgeJumpHeight,
|
||||||
|
_option.edgeJumpDownMaxHeight,
|
||||||
|
_option.edgeJumpUpMaxHeight
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Text("Debug Draw Options");
|
ImGui.Text("Debug Draw Options");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
//int newFlags = 0;
|
//int newFlags = 0;
|
||||||
ImGui.CheckboxFlags("Walkable Border", ref option.flags, JumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER);
|
ImGui.CheckboxFlags("Walkable Border", ref _option.flags, JumpLinkBuilderToolOption.DRAW_WALKABLE_BORDER);
|
||||||
ImGui.CheckboxFlags("Selected Edge", ref option.flags, JumpLinkBuilderToolOption.DRAW_SELECTED_EDGE);
|
ImGui.CheckboxFlags("Selected Edge", ref _option.flags, JumpLinkBuilderToolOption.DRAW_SELECTED_EDGE);
|
||||||
ImGui.CheckboxFlags("Anim Trajectory", ref option.flags, JumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY);
|
ImGui.CheckboxFlags("Anim Trajectory", ref _option.flags, JumpLinkBuilderToolOption.DRAW_ANIM_TRAJECTORY);
|
||||||
ImGui.CheckboxFlags("Land Samples", ref option.flags, JumpLinkBuilderToolOption.DRAW_LAND_SAMPLES);
|
ImGui.CheckboxFlags("Land Samples", ref _option.flags, JumpLinkBuilderToolOption.DRAW_LAND_SAMPLES);
|
||||||
ImGui.CheckboxFlags("All Annotations", ref option.flags, JumpLinkBuilderToolOption.DRAW_ANNOTATIONS);
|
ImGui.CheckboxFlags("All Annotations", ref _option.flags, JumpLinkBuilderToolOption.DRAW_ANNOTATIONS);
|
||||||
//option.flags = newFlags;
|
//option.flags = newFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,10 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
private readonly List<JumpLink> _links;
|
private readonly List<JumpLink> _links;
|
||||||
private JumpLinkBuilder _annotationBuilder;
|
private JumpLinkBuilder _annotationBuilder;
|
||||||
private readonly int _selEdge = -1;
|
private readonly int _selEdge = -1;
|
||||||
private readonly JumpLinkBuilderToolOption _option;
|
|
||||||
|
|
||||||
public JumpLinkBuilderToolImpl()
|
public JumpLinkBuilderToolImpl()
|
||||||
{
|
{
|
||||||
_links = new List<JumpLink>();
|
_links = new List<JumpLink>();
|
||||||
_option = new JumpLinkBuilderToolOption();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,11 +40,6 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
_annotationBuilder = null;
|
_annotationBuilder = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JumpLinkBuilderToolOption GetOption()
|
|
||||||
{
|
|
||||||
return _option;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JumpLinkBuilder GetAnnotationBuilder()
|
public JumpLinkBuilder GetAnnotationBuilder()
|
||||||
{
|
{
|
||||||
return _annotationBuilder;
|
return _annotationBuilder;
|
||||||
|
@ -62,7 +55,9 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
return _links;
|
return _links;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Build(bool buildOffMeshConnections)
|
public void Build(bool buildOffMeshConnections, int buildTypes,
|
||||||
|
float groundTolerance, float climbDownDistance, float climbDownMaxHeight, float climbDownMinHeight,
|
||||||
|
float edgeJumpEndDistance, float edgeJumpHeight, float edgeJumpDownMaxHeight, float edgeJumpUpMaxHeight)
|
||||||
{
|
{
|
||||||
if (_annotationBuilder == null)
|
if (_annotationBuilder == null)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +77,7 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
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 ((buildTypes & JumpLinkType.EDGE_CLIMB_DOWN.Bit) != 0)
|
||||||
{
|
{
|
||||||
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(
|
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(
|
||||||
cellSize,
|
cellSize,
|
||||||
|
@ -90,17 +85,17 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
agentRadius,
|
agentRadius,
|
||||||
agentHeight,
|
agentHeight,
|
||||||
agentClimb,
|
agentClimb,
|
||||||
_option.groundTolerance,
|
groundTolerance,
|
||||||
-agentRadius * 0.2f,
|
-agentRadius * 0.2f,
|
||||||
cellSize + 2 * agentRadius + _option.climbDownDistance,
|
cellSize + 2 * agentRadius + climbDownDistance,
|
||||||
-_option.climbDownMaxHeight,
|
-climbDownMaxHeight,
|
||||||
-_option.climbDownMinHeight,
|
-climbDownMinHeight,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
_links.AddRange(_annotationBuilder.Build(config, JumpLinkType.EDGE_CLIMB_DOWN));
|
_links.AddRange(_annotationBuilder.Build(config, JumpLinkType.EDGE_CLIMB_DOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_option.buildTypes & JumpLinkType.EDGE_JUMP.Bit) != 0)
|
if ((buildTypes & JumpLinkType.EDGE_JUMP.Bit) != 0)
|
||||||
{
|
{
|
||||||
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(
|
JumpLinkBuilderConfig config = new JumpLinkBuilderConfig(
|
||||||
cellSize,
|
cellSize,
|
||||||
|
@ -108,12 +103,12 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
agentRadius,
|
agentRadius,
|
||||||
agentHeight,
|
agentHeight,
|
||||||
agentClimb,
|
agentClimb,
|
||||||
_option.groundTolerance,
|
groundTolerance,
|
||||||
-agentRadius * 0.2f,
|
-agentRadius * 0.2f,
|
||||||
_option.edgeJumpEndDistance,
|
edgeJumpEndDistance,
|
||||||
-_option.edgeJumpDownMaxHeight,
|
-edgeJumpDownMaxHeight,
|
||||||
_option.edgeJumpUpMaxHeight,
|
edgeJumpUpMaxHeight,
|
||||||
_option.edgeJumpHeight
|
edgeJumpHeight
|
||||||
);
|
);
|
||||||
_links.AddRange(_annotationBuilder.Build(config, JumpLinkType.EDGE_JUMP));
|
_links.AddRange(_annotationBuilder.Build(config, JumpLinkType.EDGE_JUMP));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue