From 6ea72a1f9f4846c03de3c82e7ba41136fc6d4032 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 25 Mar 2023 21:49:45 +0900 Subject: [PATCH] added draw modw --- src/DotRecast.Recast.Demo/Draw/DrawMode.cs | 5 +++++ src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs | 2 +- .../Settings/RcSettingsView.cs | 15 +++------------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Draw/DrawMode.cs b/src/DotRecast.Recast.Demo/Draw/DrawMode.cs index cb98eff..c75a0a2 100644 --- a/src/DotRecast.Recast.Demo/Draw/DrawMode.cs +++ b/src/DotRecast.Recast.Demo/Draw/DrawMode.cs @@ -73,6 +73,11 @@ public class DrawMode Text = text; } + public static DrawMode OfIdx(int idx) + { + return Values[idx]; + } + public override string ToString() { return Text; diff --git a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs index c641fdc..3d8ab17 100644 --- a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs +++ b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs @@ -58,7 +58,7 @@ public class NavMeshRenderer RcSettingsView rcSettingsView = sample.getSettingsUI(); debugDraw.fog(true); debugDraw.depthMask(true); - DrawMode drawMode = rcSettingsView.getDrawMode(); + var drawMode = rcSettingsView.getDrawMode(); float texScale = 1.0f / (rcSettingsView.getCellSize() * 10.0f); float m_agentMaxSlope = rcSettingsView.getAgentMaxSlope(); diff --git a/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs b/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs index 5814396..3e64d18 100644 --- a/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs +++ b/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs @@ -69,8 +69,7 @@ public class RcSettingsView : IRcView private int maxTiles; private int maxPolys; - private int drawModeIdx = DrawMode.DRAWMODE_NAVMESH.Idx; - private DrawMode drawMode = DrawMode.DRAWMODE_NAVMESH; + private int drawMode = DrawMode.DRAWMODE_NAVMESH.Idx; private string meshInputFilePath; private bool meshInputTrigerred; @@ -211,16 +210,8 @@ public class RcSettingsView : IRcView DrawMode.Values.forEach(dm => { - ImGui.RadioButton(dm.Text, ref drawModeIdx, dm.Idx); + ImGui.RadioButton(dm.Text, ref drawMode, dm.Idx); }); - // nk_window_get_bounds(ctx, rect); - // if (mouseX >= rect.x() && mouseX <= rect.x() + rect.w() && mouseY >= rect.y() - // && mouseY <= rect.y() + rect.h()) { - // mouseInside = true; - // } - // } - // nk_end(ctx); - // } ImGui.NewLine(); ImGui.End(); @@ -307,7 +298,7 @@ public class RcSettingsView : IRcView public DrawMode getDrawMode() { - return drawMode; + return DrawMode.Values[drawMode]; } public float getEdgeMaxLen()