“Change slide float input to ImGUI”

This commit is contained in:
ikpil 2023-03-18 01:33:21 +09:00
parent b869f50c2f
commit cb8c846ded
11 changed files with 190 additions and 172 deletions

View File

@ -16,7 +16,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
using System.Linq;
using System.Numerics; using System.Numerics;
using DotRecast.Core;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.UI; using DotRecast.Recast.Demo.UI;
using ImGuiNET; using ImGuiNET;
@ -37,21 +39,22 @@ public class RcSettingsView : IRcView
private int minRegionSize = 8; private int minRegionSize = 8;
private int mergedRegionSize = 20; private int mergedRegionSize = 20;
private int _partitioning = 0;
private PartitionType partitioning = PartitionType.WATERSHED; private PartitionType partitioning = PartitionType.WATERSHED;
private bool filterLowHangingObstacles = true; private bool filterLowHangingObstacles = true;
private bool filterLedgeSpans = true; private bool filterLedgeSpans = true;
private bool filterWalkableLowHeightSpans = true; private bool filterWalkableLowHeightSpans = true;
private readonly float[] edgeMaxLen = new[] { 12f }; private float edgeMaxLen = 12f;
private readonly float[] edgeMaxError = new[] { 1.3f }; private float edgeMaxError = 1.3f;
private readonly int[] vertsPerPoly = new[] { 6 }; private int vertsPerPoly = 6;
private readonly float[] detailSampleDist = new[] { 6f }; private float detailSampleDist = 6f;
private readonly float[] detailSampleMaxError = new[] { 1f }; private float detailSampleMaxError = 1f;
private bool tiled = false; private bool tiled = false;
private readonly int[] tileSize = new[] { 32 }; private int tileSize = 32;
// public readonly NkColor white = NkColor.create(); // public readonly NkColor white = NkColor.create();
// public readonly NkColor background = NkColor.create(); // public readonly NkColor background = NkColor.create();
@ -76,7 +79,7 @@ public class RcSettingsView : IRcView
return true; return true;
} }
public bool renderInternal(IWindow i, int x, int y, int width, int height, int mouseX, int mouseY) public bool renderInternal(IWindow win, int x, int y, int width, int height, int mouseX, int mouseY)
{ {
bool mouseInside = false; bool mouseInside = false;
ImGui.Text("Input Mesh"); ImGui.Text("Input Mesh");
@ -88,67 +91,62 @@ public class RcSettingsView : IRcView
ImGui.Text("Rasterization"); ImGui.Text("Rasterization");
ImGui.Separator(); ImGui.Separator();
ImGui.SliderFloat("Cell Size", ref cellSize, 0.01f, 1f, $"{cellSize}"); ImGui.SliderFloat("Cell Size", ref cellSize, 0.01f, 1f, "%.2f");
ImGui.SliderFloat("Cell Height", ref cellHeight, 0.01f, 1f, $"{cellHeight}"); ImGui.SliderFloat("Cell Height", ref cellHeight, 0.01f, 1f, "%.2f");
ImGui.Text($"Voxels {voxels[0]} x {voxels[1]}"); ImGui.Text($"Voxels {voxels[0]} x {voxels[1]}");
ImGui.NewLine(); ImGui.NewLine();
ImGui.Text("Agent"); ImGui.Text("Agent");
ImGui.Separator(); ImGui.Separator();
ImGui.SliderFloat("Height", ref agentHeight, 5f, 0.1f, $"{agentHeight}"); ImGui.SliderFloat("Height", ref agentHeight, 0.1f, 5f, "%.1f");
ImGui.SliderFloat("Radius", ref agentRadius, 5f, 0.1f, $"{agentRadius}"); ImGui.SliderFloat("Radius", ref agentRadius, 0.1f, 5f, "%.1f");
ImGui.SliderFloat("Max Climb", ref agentMaxClimb, 5f, 0.1f, $"{agentMaxClimb}"); ImGui.SliderFloat("Max Climb", ref agentMaxClimb, 0.1f, 5f, "%.1f");
ImGui.SliderFloat("Max Slope", ref agentMaxSlope, 90f, 1f, $"{agentMaxSlope}"); ImGui.SliderFloat("Max Slope", ref agentMaxSlope, 1f, 90f, "%.0f");
ImGui.NewLine(); ImGui.NewLine();
ImGui.Text("Region"); ImGui.Text("Region");
ImGui.Separator(); ImGui.Separator();
ImGui.SliderInt("Min Region Size", ref minRegionSize, 1, 150); ImGui.SliderInt("Min Region Size", ref minRegionSize, 1, 150, "%.0f");
ImGui.SliderInt("Merged Region Size", ref mergedRegionSize, 1, 150); ImGui.SliderInt("Merged Region Size", ref mergedRegionSize, 1, 150, "%.0f");
// ImGui.NewLine();
// nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1); ImGui.Text("Partitioning");
// nk_layout_row_dynamic(ctx, 18, 1); PartitionType.Values.forEach(partition =>
// nk_label(ctx, "Partitioning", NK_TEXT_ALIGN_LEFT); {
// partitioning = NuklearUIHelper.nk_radio(ctx, PartitionType.values(), partitioning, var label = partition.Name.Substring(0, 1).ToUpper()
// p => p.name().substring(0, 1) + p.name().substring(1).toLowerCase()); + partition.Name.Substring(1).ToLower();
// ImGui.RadioButton(label, ref _partitioning, partition.Idx);
// nk_layout_row_dynamic(ctx, 3, 1); });
// nk_spacing(ctx, 1); ImGui.NewLine();
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Filtering", NK_TEXT_ALIGN_LEFT); ImGui.Text("Filtering");
ImGui.Checkbox("Low Hanging Obstacles", ref filterLowHangingObstacles);
ImGui.Checkbox("Ledge Spans", ref filterLedgeSpans);
ImGui.Checkbox("Walkable Low Height Spans", ref filterWalkableLowHeightSpans);
ImGui.NewLine();
ImGui.Text("Polygonization");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// filterLowHangingObstacles = nk_option_text(ctx, "Low Hanging Obstacles", filterLowHangingObstacles); ImGui.SliderFloat("Max Edge Length", ref edgeMaxLen, 0f, 50f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// filterLedgeSpans = nk_option_text(ctx, "Ledge Spans", filterLedgeSpans); ImGui.SliderFloat("Max Edge Error", ref edgeMaxError, 0.1f, 3f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1);
// filterWalkableLowHeightSpans = nk_option_text(ctx, "Walkable Low Height Spans",
// filterWalkableLowHeightSpans);
//
// nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Polygonization", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Edge Length", 0f, edgeMaxLen, 50f, 0.1f, 0.1f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Edge Error", 0.1f, edgeMaxError, 3f, 0.1f, 0.1f);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_int(ctx, "Vert Per Poly", 3, vertsPerPoly, 12, 1, 1); // nk_property_int(ctx, "Vert Per Poly", 3, vertsPerPoly, 12, 1, 1);
// ImGui.NewLine();
// nk_layout_row_dynamic(ctx, 3, 1); // nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Detail Mesh", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Detail Mesh", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Sample Distance", 0f, detailSampleDist, 16f, 0.1f, 0.1f); ImGui.SliderFloat("Sample Distance", ref detailSampleDist, 0f, 16f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Sample Error", 0f, detailSampleMaxError, 16f, 0.1f, 0.1f); ImGui.SliderFloat("Max Sample Error", ref detailSampleMaxError, 0f, 16f, "%.1f");
// //
// nk_layout_row_dynamic(ctx, 3, 1); // nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Tiling", NK_TEXT_ALIGN_LEFT); ImGui.Text("Tiling");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// tiled = nk_check_text(ctx, "Enable", tiled); // tiled = nk_check_text(ctx, "Enable", tiled);
// if (tiled) { // if (tiled) {
@ -172,7 +170,7 @@ public class RcSettingsView : IRcView
// navMeshInputTrigerred = nk_button_text(ctx, "Load Nav Mesh..."); // navMeshInputTrigerred = nk_button_text(ctx, "Load Nav Mesh...");
// //
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Draw", NK_TEXT_ALIGN_LEFT); ImGui.Text("Draw");
// drawMode = NuklearUIHelper.nk_radio(ctx, DrawMode.values(), drawMode, dm => dm.toString()); // drawMode = NuklearUIHelper.nk_radio(ctx, DrawMode.values(), drawMode, dm => dm.toString());
// //
// nk_window_get_bounds(ctx, rect); // nk_window_get_bounds(ctx, rect);
@ -263,27 +261,27 @@ public class RcSettingsView : IRcView
public float getEdgeMaxLen() public float getEdgeMaxLen()
{ {
return edgeMaxLen[0]; return edgeMaxLen;
} }
public float getEdgeMaxError() public float getEdgeMaxError()
{ {
return edgeMaxError[0]; return edgeMaxError;
} }
public int getVertsPerPoly() public int getVertsPerPoly()
{ {
return vertsPerPoly[0]; return vertsPerPoly;
} }
public float getDetailSampleDist() public float getDetailSampleDist()
{ {
return detailSampleDist[0]; return detailSampleDist;
} }
public float getDetailSampleMaxError() public float getDetailSampleMaxError()
{ {
return detailSampleMaxError[0]; return detailSampleMaxError;
} }
public void setVoxels(int[] voxels) public void setVoxels(int[] voxels)
@ -299,7 +297,7 @@ public class RcSettingsView : IRcView
public int getTileSize() public int getTileSize()
{ {
return tileSize[0]; return tileSize;
} }
public void setTiles(int[] tiles) public void setTiles(int[] tiles)

View File

@ -25,6 +25,7 @@ using DotRecast.Core;
using DotRecast.Recast.Demo.Builder; using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.Geom; using DotRecast.Recast.Demo.Geom;
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;
@ -34,9 +35,9 @@ public class ConvexVolumeTool : Tool
{ {
private Sample sample; private Sample sample;
private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS; private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
private readonly float[] boxHeight = new[] { 6f }; private float boxHeight = 6f;
private readonly float[] boxDescent = new[] { 1f }; private float boxDescent = 1f;
private readonly float[] polyOffset = new[] { 0f }; private float polyOffset = 0f;
private readonly List<float> pts = new(); private readonly List<float> pts = new();
private readonly List<int> hull = new(); private readonly List<int> hull = new();
@ -99,13 +100,13 @@ public class ConvexVolumeTool : Tool
minh = Math.Min(minh, verts[i * 3 + 1]); minh = Math.Min(minh, verts[i * 3 + 1]);
} }
minh -= boxDescent[0]; minh -= boxDescent;
maxh = minh + boxHeight[0]; maxh = minh + boxHeight;
if (polyOffset[0] > 0.01f) if (polyOffset > 0.01f)
{ {
float[] offset = new float[verts.Length * 2]; float[] offset = new float[verts.Length * 2];
int noffset = PolyUtils.offsetPoly(verts, hull.Count, polyOffset[0], offset, int noffset = PolyUtils.offsetPoly(verts, hull.Count, polyOffset, offset,
offset.Length); offset.Length);
if (noffset > 0) if (noffset > 0)
{ {
@ -151,8 +152,8 @@ public class ConvexVolumeTool : Tool
minh = Math.Min(minh, pts[i + 1]); minh = Math.Min(minh, pts[i + 1]);
} }
minh -= boxDescent[0]; minh -= boxDescent;
maxh = minh + boxHeight[0]; maxh = minh + boxHeight;
dd.begin(POINTS, 4.0f); dd.begin(POINTS, 4.0f);
for (int i = 0; i < pts.Count; i += 3) for (int i = 0; i < pts.Count; i += 3)
@ -187,11 +188,11 @@ public class ConvexVolumeTool : Tool
public override void layout(IWindow ctx) public override void layout(IWindow ctx)
{ {
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Shape Height", 0.1f, boxHeight, 20f, 0.1f, 0.1f); ImGui.SliderFloat("Shape Height", ref boxHeight, 0.1f, 20f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Shape Descent", 0.1f, boxDescent, 20f, 0.1f, 0.1f); ImGui.SliderFloat("Shape Descent", ref boxDescent, 0.1f, 20f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Poly Offset", 0.1f, polyOffset, 10f, 0.1f, 0.1f); ImGui.SliderFloat("Poly Offset", ref polyOffset, 0.1f, 10f, "%.1f");
// nk_label(ctx, "Area Type", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Area Type", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// if (nk_option_label(ctx, "Ground", areaType == SampleAreaModifications.SAMPLE_AREAMOD_GROUND)) { // if (nk_option_label(ctx, "Ground", areaType == SampleAreaModifications.SAMPLE_AREAMOD_GROUND)) {

View File

@ -24,6 +24,7 @@ using DotRecast.Detour;
using DotRecast.Detour.Crowd; using DotRecast.Detour.Crowd;
using DotRecast.Recast.Demo.Builder; using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using ImGuiNET;
using Silk.NET.Windowing; using Silk.NET.Windowing;
using static DotRecast.Recast.Demo.Draw.DebugDraw; using static DotRecast.Recast.Demo.Draw.DebugDraw;
@ -32,16 +33,16 @@ namespace DotRecast.Recast.Demo.Tools;
public class CrowdProfilingTool public class CrowdProfilingTool
{ {
private readonly Func<CrowdAgentParams> agentParamsSupplier; private readonly Func<CrowdAgentParams> agentParamsSupplier;
private readonly int[] expandSimOptions = new[] { 1 }; private int expandSimOptions = 1;
private readonly int[] expandCrowdOptions = new[] { 1 }; private int expandCrowdOptions = 1;
private readonly int[] agents = new[] { 1000 }; private int agents = 1000;
private readonly int[] randomSeed = new[] { 270 }; private int randomSeed = 270;
private readonly int[] numberOfZones = new[] { 4 }; private int numberOfZones = 4;
private readonly float[] zoneRadius = new[] { 20f }; private float zoneRadius = 20f;
private readonly float[] percentMobs = new[] { 80f }; private float percentMobs = 80f;
private readonly float[] percentTravellers = new[] { 15f }; private float percentTravellers = 15f;
private readonly int[] pathQueueSize = new[] { 32 }; private int pathQueueSize = 32;
private readonly int[] maxIterations = new[] { 300 }; private int maxIterations = 300;
private Crowd crowd; private Crowd crowd;
private NavMesh navMesh; private NavMesh navMesh;
private CrowdConfig config; private CrowdConfig config;
@ -66,11 +67,11 @@ public class CrowdProfilingTool
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_int(ctx, "Number of Zones", 0, numberOfZones, 10, 1, 1); // nk_property_int(ctx, "Number of Zones", 0, numberOfZones, 10, 1, 1);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Zone Radius", 0, zoneRadius, 100, 1, 1); ImGui.SliderFloat("Zone Radius", ref zoneRadius, 0, 100, "%.0f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Mobs %", 0, percentMobs, 100, 1, 1); ImGui.SliderFloat("Mobs %", ref percentMobs, 0, 100, "%.0f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Travellers %", 0, percentTravellers, 100, 1, 1); ImGui.SliderFloat("Travellers %", ref percentTravellers, 0, 100, "%.0f");
// nk_tree_state_pop(ctx); // nk_tree_state_pop(ctx);
// } // }
// if (nk_tree_state_push(ctx, 0, "Crowd Options", expandCrowdOptions)) { // if (nk_tree_state_push(ctx, 0, "Crowd Options", expandCrowdOptions)) {
@ -159,7 +160,7 @@ public class CrowdProfilingTool
{ {
int zone = (int)(rnd.frand() * zones.Count); int zone = (int)(rnd.frand() * zones.Count);
Result<FindRandomPointResult> result = navquery.findRandomPointWithinCircle(zones[zone].getRandomRef(), Result<FindRandomPointResult> result = navquery.findRandomPointWithinCircle(zones[zone].getRandomRef(),
zones[zone].getRandomPt(), zoneRadius[0], filter, rnd); zones[zone].getRandomPt(), zoneRadius, filter, rnd);
if (result.succeeded()) if (result.succeeded())
{ {
pos = result.result.getRandomPt(); pos = result.result.getRandomPt();
@ -174,9 +175,9 @@ public class CrowdProfilingTool
zones.Clear(); zones.Clear();
QueryFilter filter = new DefaultQueryFilter(); QueryFilter filter = new DefaultQueryFilter();
NavMeshQuery navquery = new NavMeshQuery(navMesh); NavMeshQuery navquery = new NavMeshQuery(navMesh);
for (int i = 0; i < numberOfZones[0]; i++) for (int i = 0; i < numberOfZones; i++)
{ {
float zoneSeparation = zoneRadius[0] * zoneRadius[0] * 16; float zoneSeparation = zoneRadius * zoneRadius * 16;
for (int k = 0; k < 100; k++) for (int k = 0; k < 100; k++)
{ {
Result<FindRandomPointResult> result = navquery.findRandomPoint(filter, rnd); Result<FindRandomPointResult> result = navquery.findRandomPoint(filter, rnd);
@ -239,8 +240,8 @@ public class CrowdProfilingTool
long startTime = Stopwatch.GetTimestamp(); long startTime = Stopwatch.GetTimestamp();
if (crowd != null) if (crowd != null)
{ {
crowd.config().pathQueueSize = pathQueueSize[0]; crowd.config().pathQueueSize = pathQueueSize;
crowd.config().maxFindPathIterations = maxIterations[0]; crowd.config().maxFindPathIterations = maxIterations;
crowd.update(dt, null); crowd.update(dt, null);
} }
@ -280,7 +281,7 @@ public class CrowdProfilingTool
if (nearestPoly.succeeded()) if (nearestPoly.succeeded())
{ {
Result<FindRandomPointResult> result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(), Result<FindRandomPointResult> result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(),
agentData.home, zoneRadius[0] * 2f, filter, rnd); agentData.home, zoneRadius * 2f, filter, rnd);
if (result.succeeded()) if (result.succeeded())
{ {
crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt()); crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt());
@ -295,7 +296,7 @@ public class CrowdProfilingTool
if (nearestPoly.succeeded()) if (nearestPoly.succeeded())
{ {
Result<FindRandomPointResult> result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(), Result<FindRandomPointResult> result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(),
agentData.home, zoneRadius[0] * 0.2f, filter, rnd); agentData.home, zoneRadius * 0.2f, filter, rnd);
if (result.succeeded()) if (result.succeeded())
{ {
crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt()); crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt());
@ -309,7 +310,7 @@ public class CrowdProfilingTool
List<FindRandomPointResult> potentialTargets = new(); List<FindRandomPointResult> potentialTargets = new();
foreach (FindRandomPointResult zone in zones) foreach (FindRandomPointResult zone in zones)
{ {
if (DemoMath.vDistSqr(zone.getRandomPt(), ag.npos, 0) > zoneRadius[0] * zoneRadius[0]) if (DemoMath.vDistSqr(zone.getRandomPt(), ag.npos, 0) > zoneRadius * zoneRadius)
{ {
potentialTargets.Add(zone); potentialTargets.Add(zone);
} }

View File

@ -27,6 +27,7 @@ using DotRecast.Detour.Crowd.Tracking;
using DotRecast.Recast.Demo.Builder; using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.Geom; using DotRecast.Recast.Demo.Geom;
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;
@ -232,8 +233,8 @@ public class CrowdTool : Tool
ap.collisionQueryRange = ap.radius * 12.0f; ap.collisionQueryRange = ap.radius * 12.0f;
ap.pathOptimizationRange = ap.radius * 30.0f; ap.pathOptimizationRange = ap.radius * 30.0f;
ap.updateFlags = getUpdateFlags(); ap.updateFlags = getUpdateFlags();
ap.obstacleAvoidanceType = toolParams.m_obstacleAvoidanceType[0]; ap.obstacleAvoidanceType = toolParams.m_obstacleAvoidanceType;
ap.separationWeight = toolParams.m_separationWeight[0]; ap.separationWeight = toolParams.m_separationWeight;
return ap; return ap;
} }
@ -729,7 +730,7 @@ public class CrowdTool : Tool
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// toolParams.m_separation = nk_option_text(ctx, "Separation", toolParams.m_separation); // toolParams.m_separation = nk_option_text(ctx, "Separation", toolParams.m_separation);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Separation Weight", 0f, toolParams.m_separationWeight, 20f, 0.01f, 0.01f); ImGui.SliderFloat("Separation Weight", ref toolParams.m_separationWeight, 0f, 20f, "%.2f");
// if (m_optimizeVis != toolParams.m_optimizeVis || m_optimizeTopo != toolParams.m_optimizeTopo // if (m_optimizeVis != toolParams.m_optimizeVis || m_optimizeTopo != toolParams.m_optimizeTopo
// || m_anticipateTurns != toolParams.m_anticipateTurns || m_obstacleAvoidance != toolParams.m_obstacleAvoidance // || m_anticipateTurns != toolParams.m_anticipateTurns || m_obstacleAvoidance != toolParams.m_obstacleAvoidance
// || m_separation != toolParams.m_separation // || m_separation != toolParams.m_separation
@ -784,7 +785,7 @@ public class CrowdTool : Tool
} }
int updateFlags = getUpdateFlags(); int updateFlags = getUpdateFlags();
profilingTool.updateAgentParams(updateFlags, toolParams.m_obstacleAvoidanceType[0], toolParams.m_separationWeight[0]); profilingTool.updateAgentParams(updateFlags, toolParams.m_obstacleAvoidanceType, toolParams.m_separationWeight);
foreach (CrowdAgent ag in crowd.getActiveAgents()) foreach (CrowdAgent ag in crowd.getActiveAgents())
{ {
CrowdAgentParams option = new CrowdAgentParams(); CrowdAgentParams option = new CrowdAgentParams();
@ -798,8 +799,8 @@ public class CrowdTool : Tool
option.queryFilterType = ag.option.queryFilterType; option.queryFilterType = ag.option.queryFilterType;
option.userData = ag.option.userData; option.userData = ag.option.userData;
option.updateFlags = updateFlags; option.updateFlags = updateFlags;
option.obstacleAvoidanceType = toolParams.m_obstacleAvoidanceType[0]; option.obstacleAvoidanceType = toolParams.m_obstacleAvoidanceType;
option.separationWeight = toolParams.m_separationWeight[0]; option.separationWeight = toolParams.m_separationWeight;
crowd.updateAgentParameters(ag, option); crowd.updateAgentParameters(ag, option);
} }
} }

View File

@ -20,7 +20,7 @@ namespace DotRecast.Recast.Demo.Tools;
public class CrowdToolParams public class CrowdToolParams
{ {
public readonly int[] m_expandSelectedDebugDraw = new[] { 1 }; public int m_expandSelectedDebugDraw = 1;
public bool m_showCorners; public bool m_showCorners;
public bool m_showCollisionSegments; public bool m_showCollisionSegments;
public bool m_showPath; public bool m_showPath;
@ -28,19 +28,19 @@ public class CrowdToolParams
public bool m_showOpt; public bool m_showOpt;
public bool m_showNeis; public bool m_showNeis;
public readonly int[] m_expandDebugDraw = new[] { 0 }; public int m_expandDebugDraw = 0;
public bool m_showLabels; public bool m_showLabels;
public bool m_showGrid; public bool m_showGrid;
public bool m_showNodes; public bool m_showNodes;
public bool m_showPerfGraph; public bool m_showPerfGraph;
public bool m_showDetailAll; public bool m_showDetailAll;
public readonly int[] m_expandOptions = new[] { 1 }; public int m_expandOptions = 1;
public bool m_anticipateTurns = true; public bool m_anticipateTurns = true;
public bool m_optimizeVis = true; public bool m_optimizeVis = true;
public bool m_optimizeTopo = true; public bool m_optimizeTopo = true;
public bool m_obstacleAvoidance = true; public bool m_obstacleAvoidance = true;
public readonly int[] m_obstacleAvoidanceType = new[] { 3 }; public int m_obstacleAvoidanceType = 3;
public bool m_separation; public bool m_separation;
public readonly float[] m_separationWeight = new[] { 2f }; public float m_separationWeight = 2f;
} }

View File

@ -29,6 +29,7 @@ using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.Geom; using DotRecast.Recast.Demo.Geom;
using DotRecast.Recast.Demo.Tools.Gizmos; using DotRecast.Recast.Demo.Tools.Gizmos;
using DotRecast.Recast.Demo.UI; using DotRecast.Recast.Demo.UI;
using ImGuiNET;
using Silk.NET.Windowing; using Silk.NET.Windowing;
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;
@ -59,24 +60,24 @@ public class DynamicUpdateTool : Tool
private Sample sample; private Sample sample;
private ToolMode mode = ToolMode.BUILD; private ToolMode mode = ToolMode.BUILD;
private readonly float[] cellSize = new[] { 0.3f }; private float cellSize = 0.3f;
private PartitionType partitioning = PartitionType.WATERSHED; private PartitionType partitioning = PartitionType.WATERSHED;
private bool filterLowHangingObstacles = true; private bool filterLowHangingObstacles = true;
private bool filterLedgeSpans = true; private bool filterLedgeSpans = true;
private bool filterWalkableLowHeightSpans = true; private bool filterWalkableLowHeightSpans = true;
private readonly float[] walkableHeight = new[] { 2f }; private float walkableHeight = 2f;
private readonly float[] walkableRadius = new[] { 0.6f }; private float walkableRadius = 0.6f;
private readonly float[] walkableClimb = new[] { 0.9f }; private float walkableClimb = 0.9f;
private readonly float[] walkableSlopeAngle = new[] { 45f }; private float walkableSlopeAngle = 45f;
private readonly float[] minRegionArea = new[] { 6f }; private float minRegionArea = 6f;
private readonly float[] regionMergeSize = new[] { 36f }; private float regionMergeSize = 36f;
private readonly float[] maxEdgeLen = new[] { 12f }; private float maxEdgeLen = 12f;
private readonly float[] maxSimplificationError = new[] { 1.3f }; private float maxSimplificationError = 1.3f;
private readonly int[] vertsPerPoly = new[] { 6 }; private int vertsPerPoly = 6;
private bool buildDetailMesh = true; private bool buildDetailMesh = true;
private bool compression = true; private bool compression = true;
private readonly float[] detailSampleDist = new[] { 6f }; private float detailSampleDist = 6f;
private readonly float[] detailSampleMaxError = new[] { 1f }; private float detailSampleMaxError = 1f;
private bool showColliders = false; private bool showColliders = false;
private long buildTime; private long buildTime;
private long raycastTime; private long raycastTime;
@ -510,20 +511,20 @@ public class DynamicUpdateTool : Tool
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Rasterization", NK_TEXT_ALIGN_LEFT); ImGui.Text("Rasterization");
// nk_layout_row_dynamic(ctx, 18, 2); // nk_layout_row_dynamic(ctx, 18, 2);
// nk_label(ctx, "Cell Size", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Cell Size", NK_TEXT_ALIGN_LEFT);
// nk_label(ctx, string.format("%.2f", cellSize[0]), NK_TEXT_ALIGN_RIGHT); // nk_label(ctx, string.format("%.2f", cellSize[0]), NK_TEXT_ALIGN_RIGHT);
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Agent", NK_TEXT_ALIGN_LEFT); ImGui.Text("Agent");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Height", 0f, walkableHeight, 5f, 0.01f, 0.01f); ImGui.SliderFloat("Height", ref walkableHeight, 0f, 5f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Radius", 0f, walkableRadius, 10f, 0.01f, 0.01f); ImGui.SliderFloat("Radius", ref walkableRadius, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Climb", 0f, walkableClimb, 10f, 0.01f, 0.01f); ImGui.SliderFloat("Max Climb", ref walkableClimb, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 18, 2); // nk_layout_row_dynamic(ctx, 18, 2);
// nk_label(ctx, "Max Slope", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Max Slope", NK_TEXT_ALIGN_LEFT);
// nk_label(ctx, string.format("%.0f", walkableSlopeAngle[0]), NK_TEXT_ALIGN_RIGHT); // nk_label(ctx, string.format("%.0f", walkableSlopeAngle[0]), NK_TEXT_ALIGN_RIGHT);
@ -531,14 +532,14 @@ public class DynamicUpdateTool : Tool
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Partitioning", NK_TEXT_ALIGN_LEFT); ImGui.Text("Partitioning");
// partitioning = NuklearUIHelper.nk_radio(ctx, PartitionType.values(), partitioning, // partitioning = NuklearUIHelper.nk_radio(ctx, PartitionType.values(), partitioning,
// p => p.name().substring(0, 1) + p.name().substring(1).toLowerCase()); // p => p.name().substring(0, 1) + p.name().substring(1).toLowerCase());
// //
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Filtering", NK_TEXT_ALIGN_LEFT); ImGui.Text("Filtering");
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// filterLowHangingObstacles = nk_option_text(ctx, "Low Hanging Obstacles", filterLowHangingObstacles); // filterLowHangingObstacles = nk_option_text(ctx, "Low Hanging Obstacles", filterLowHangingObstacles);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
@ -549,20 +550,20 @@ public class DynamicUpdateTool : Tool
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Region", NK_TEXT_ALIGN_LEFT); ImGui.Text("Region");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Min Region Size", 0, minRegionArea, 150, 0.1f, 0.1f); ImGui.SliderFloat("Min Region Size", ref minRegionArea, 0, 150, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Merged Region Size", 0, regionMergeSize, 400, 0.1f, 0.1f); ImGui.SliderFloat("Merged Region Size", ref regionMergeSize, 0, 400, "%.1f");
// //
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Polygonization", NK_TEXT_ALIGN_LEFT); ImGui.Text("Polygonization");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Edge Length", 0f, maxEdgeLen, 50f, 0.1f, 0.1f); ImGui.SliderFloat("Max Edge Length", ref maxEdgeLen, 0f, 50f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Edge Error", 0.1f, maxSimplificationError, 10f, 0.1f, 0.1f); ImGui.SliderFloat("Max Edge Error", ref maxSimplificationError, 0.1f, 10f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_int(ctx, "Verts Per Poly", 3, vertsPerPoly, 12, 1, 1); // nk_property_int(ctx, "Verts Per Poly", 3, vertsPerPoly, 12, 1, 1);
// //
@ -573,9 +574,9 @@ public class DynamicUpdateTool : Tool
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// buildDetailMesh = nk_check_text(ctx, "Enable", buildDetailMesh); // buildDetailMesh = nk_check_text(ctx, "Enable", buildDetailMesh);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Sample Distance", 0f, detailSampleDist, 16f, 0.1f, 0.1f); ImGui.SliderFloat("Sample Distance", ref detailSampleDist, 0f, 16f, "%.1f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Sample Error", 0f, detailSampleMaxError, 16f, 0.1f, 0.1f); ImGui.SliderFloat("Max Sample Error", ref detailSampleMaxError, 0f, 16f, "%.1f");
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
@ -590,7 +591,7 @@ public class DynamicUpdateTool : Tool
// nk_layout_row_dynamic(ctx, 1, 1); // nk_layout_row_dynamic(ctx, 1, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Colliders", NK_TEXT_ALIGN_LEFT); ImGui.Text("Colliders");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// showColliders = nk_check_text(ctx, "Show", showColliders); // showColliders = nk_check_text(ctx, "Show", showColliders);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
@ -726,39 +727,39 @@ public class DynamicUpdateTool : Tool
private void configDynaMesh() private void configDynaMesh()
{ {
dynaMesh.config.partitionType = partitioning; dynaMesh.config.partitionType = partitioning;
dynaMesh.config.walkableHeight = walkableHeight[0]; dynaMesh.config.walkableHeight = walkableHeight;
dynaMesh.config.walkableSlopeAngle = walkableSlopeAngle[0]; dynaMesh.config.walkableSlopeAngle = walkableSlopeAngle;
dynaMesh.config.walkableRadius = walkableRadius[0]; dynaMesh.config.walkableRadius = walkableRadius;
dynaMesh.config.walkableClimb = walkableClimb[0]; dynaMesh.config.walkableClimb = walkableClimb;
dynaMesh.config.filterLowHangingObstacles = filterLowHangingObstacles; dynaMesh.config.filterLowHangingObstacles = filterLowHangingObstacles;
dynaMesh.config.filterLedgeSpans = filterLedgeSpans; dynaMesh.config.filterLedgeSpans = filterLedgeSpans;
dynaMesh.config.filterWalkableLowHeightSpans = filterWalkableLowHeightSpans; dynaMesh.config.filterWalkableLowHeightSpans = filterWalkableLowHeightSpans;
dynaMesh.config.minRegionArea = minRegionArea[0]; dynaMesh.config.minRegionArea = minRegionArea;
dynaMesh.config.regionMergeArea = regionMergeSize[0]; dynaMesh.config.regionMergeArea = regionMergeSize;
dynaMesh.config.maxEdgeLen = maxEdgeLen[0]; dynaMesh.config.maxEdgeLen = maxEdgeLen;
dynaMesh.config.maxSimplificationError = maxSimplificationError[0]; dynaMesh.config.maxSimplificationError = maxSimplificationError;
dynaMesh.config.vertsPerPoly = vertsPerPoly[0]; dynaMesh.config.vertsPerPoly = vertsPerPoly;
dynaMesh.config.buildDetailMesh = buildDetailMesh; dynaMesh.config.buildDetailMesh = buildDetailMesh;
dynaMesh.config.detailSampleDistance = detailSampleDist[0]; dynaMesh.config.detailSampleDistance = detailSampleDist;
dynaMesh.config.detailSampleMaxError = detailSampleMaxError[0]; dynaMesh.config.detailSampleMaxError = detailSampleMaxError;
} }
private void updateUI() private void updateUI()
{ {
cellSize[0] = dynaMesh.config.cellSize; cellSize = dynaMesh.config.cellSize;
partitioning = dynaMesh.config.partitionType; partitioning = dynaMesh.config.partitionType;
walkableHeight[0] = dynaMesh.config.walkableHeight; walkableHeight = dynaMesh.config.walkableHeight;
walkableSlopeAngle[0] = dynaMesh.config.walkableSlopeAngle; walkableSlopeAngle = dynaMesh.config.walkableSlopeAngle;
walkableRadius[0] = dynaMesh.config.walkableRadius; walkableRadius = dynaMesh.config.walkableRadius;
walkableClimb[0] = dynaMesh.config.walkableClimb; walkableClimb = dynaMesh.config.walkableClimb;
minRegionArea[0] = dynaMesh.config.minRegionArea; minRegionArea = dynaMesh.config.minRegionArea;
regionMergeSize[0] = dynaMesh.config.regionMergeArea; regionMergeSize = dynaMesh.config.regionMergeArea;
maxEdgeLen[0] = dynaMesh.config.maxEdgeLen; maxEdgeLen = dynaMesh.config.maxEdgeLen;
maxSimplificationError[0] = dynaMesh.config.maxSimplificationError; maxSimplificationError = dynaMesh.config.maxSimplificationError;
vertsPerPoly[0] = dynaMesh.config.vertsPerPoly; vertsPerPoly = dynaMesh.config.vertsPerPoly;
buildDetailMesh = dynaMesh.config.buildDetailMesh; buildDetailMesh = dynaMesh.config.buildDetailMesh;
detailSampleDist[0] = dynaMesh.config.detailSampleDistance; detailSampleDist = dynaMesh.config.detailSampleDistance;
detailSampleMaxError[0] = dynaMesh.config.detailSampleMaxError; detailSampleMaxError = dynaMesh.config.detailSampleMaxError;
filterLowHangingObstacles = dynaMesh.config.filterLowHangingObstacles; filterLowHangingObstacles = dynaMesh.config.filterLowHangingObstacles;
filterLedgeSpans = dynaMesh.config.filterLedgeSpans; filterLedgeSpans = dynaMesh.config.filterLedgeSpans;
filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans; filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans;

View File

@ -22,6 +22,7 @@ using DotRecast.Detour.Extras.Jumplink;
using DotRecast.Recast.Demo.Builder; using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.Geom; using DotRecast.Recast.Demo.Geom;
using ImGuiNET;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
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;
@ -326,37 +327,37 @@ public class JumpLinkBuilderTool : Tool
// if (!sample.getRecastResults().isEmpty()) { // if (!sample.getRecastResults().isEmpty()) {
// //
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Options", NK_TEXT_ALIGN_LEFT); ImGui.Text("Options");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Ground Tolerance", 0f, option.groundTolerance, 2f, 0.05f, 0.01f); ImGui.SliderFloat("Ground Tolerance", ref option.groundTolerance, 0f, 2f, "%.2f");
// nk_layout_row_dynamic(ctx, 5, 1); // nk_layout_row_dynamic(ctx, 5, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// //
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Climb Down", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Climb Down", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Distance", 0f, option.climbDownDistance, 5f, 0.05f, 0.01f); ImGui.SliderFloat("Distance", ref option.climbDownDistance, 0f, 5f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Min Cliff Height", 0f, option.climbDownMinHeight, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Min Cliff Height", ref option.climbDownMinHeight, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Cliff Height", 0f, option.climbDownMaxHeight, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Max Cliff Height", ref option.climbDownMaxHeight, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 5, 1); // nk_layout_row_dynamic(ctx, 5, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// //
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Jump Down", NK_TEXT_ALIGN_LEFT); // nk_label(ctx, "Jump Down", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Distance", 0f, option.edgeJumpEndDistance, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Max Distance", ref option.edgeJumpEndDistance, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Jump Height", 0f, option.edgeJumpHeight, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Jump Height", ref option.edgeJumpHeight, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Jump Down", 0f, option.edgeJumpDownMaxHeight, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Max Jump Down", ref option.edgeJumpDownMaxHeight, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Jump Up", 0f, option.edgeJumpUpMaxHeight, 10f, 0.05f, 0.01f); ImGui.SliderFloat("Max Jump Up", ref option.edgeJumpUpMaxHeight, 0f, 10f, "%.2f");
// nk_layout_row_dynamic(ctx, 5, 1); // nk_layout_row_dynamic(ctx, 5, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1); // nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Mode", NK_TEXT_ALIGN_LEFT); ImGui.Text("Mode");
// nk_layout_row_dynamic(ctx, 20, 1); // nk_layout_row_dynamic(ctx, 20, 1);
// int buildTypes = 0; // int buildTypes = 0;
// buildTypes |= nk_option_text(ctx, "Climb Down", // buildTypes |= nk_option_text(ctx, "Climb Down",

View File

@ -31,13 +31,13 @@ public class JumpLinkBuilderToolParams
public const int DRAW_ANNOTATIONS = 1 << 6; public const int DRAW_ANNOTATIONS = 1 << 6;
public int flags = DRAW_WALKABLE_SURFACE | DRAW_WALKABLE_BORDER | DRAW_SELECTED_EDGE | DRAW_ANIM_TRAJECTORY | DRAW_LAND_SAMPLES | DRAW_ANNOTATIONS; public int flags = DRAW_WALKABLE_SURFACE | DRAW_WALKABLE_BORDER | DRAW_SELECTED_EDGE | DRAW_ANIM_TRAJECTORY | DRAW_LAND_SAMPLES | DRAW_ANNOTATIONS;
public readonly float[] groundTolerance = new[] { 0.3f }; public float groundTolerance = 0.3f;
public readonly float[] climbDownDistance = new[] { 0.4f }; public float climbDownDistance = 0.4f;
public readonly float[] climbDownMaxHeight = new[] { 3.2f }; public float climbDownMaxHeight = 3.2f;
public readonly float[] climbDownMinHeight = new[] { 1.5f }; public float climbDownMinHeight = 1.5f;
public readonly float[] edgeJumpEndDistance = new[] { 2f }; public float edgeJumpEndDistance = 2f;
public readonly float[] edgeJumpHeight = new[] { 0.4f }; public float edgeJumpHeight = 0.4f;
public readonly float[] edgeJumpDownMaxHeight = new[] { 2.5f }; public float edgeJumpDownMaxHeight = 2.5f;
public readonly float[] edgeJumpUpMaxHeight = new[] { 0.3f }; public float edgeJumpUpMaxHeight = 0.3f;
public int buildTypes = (1 << (int)JumpLinkType.EDGE_CLIMB_DOWN) | (1 << (int)JumpLinkType.EDGE_JUMP); public int buildTypes = (1 << (int)JumpLinkType.EDGE_CLIMB_DOWN) | (1 << (int)JumpLinkType.EDGE_JUMP);
} }

View File

@ -1,11 +1,26 @@
namespace DotRecast.Recast using System.Collections.Immutable;
namespace DotRecast.Recast
{ {
/// < Tessellate edges between areas during contour /// < Tessellate edges between areas during contour
/// simplification. /// simplification.
public enum PartitionType public class PartitionType
{ {
WATERSHED, public static readonly PartitionType WATERSHED = new PartitionType(0, nameof(WATERSHED));
MONOTONE, public static readonly PartitionType MONOTONE = new PartitionType(1, nameof(MONOTONE));
LAYERS public static readonly PartitionType LAYERS = new PartitionType(2, nameof(LAYERS));
public static readonly ImmutableArray<PartitionType> Values = ImmutableArray.Create(WATERSHED, MONOTONE, LAYERS);
public int Idx { get; }
public string Name { get; }
private PartitionType(int idx, string name)
{
Idx = idx;
Name = name;
}
public override string ToString() => Name;
} }
} }

View File

@ -43,7 +43,7 @@ public class RecastLayersTest
private const int m_vertsPerPoly = 6; private const int m_vertsPerPoly = 6;
private const float m_detailSampleDist = 6.0f; private const float m_detailSampleDist = 6.0f;
private const float m_detailSampleMaxError = 1.0f; private const float m_detailSampleMaxError = 1.0f;
private const PartitionType m_partitionType = PartitionType.WATERSHED; private readonly PartitionType m_partitionType = PartitionType.WATERSHED;
private const int m_tileSize = 48; private const int m_tileSize = 48;
[Test] [Test]

View File

@ -48,7 +48,7 @@ public class RecastTileMeshTest
private const int m_vertsPerPoly = 6; private const int m_vertsPerPoly = 6;
private const float m_detailSampleDist = 6.0f; private const float m_detailSampleDist = 6.0f;
private const float m_detailSampleMaxError = 1.0f; private const float m_detailSampleMaxError = 1.0f;
private const PartitionType m_partitionType = PartitionType.WATERSHED; private PartitionType m_partitionType = PartitionType.WATERSHED;
private const int m_tileSize = 32; private const int m_tileSize = 32;
[Test] [Test]