forked from bit/DotRecastNetSim
rename RecastDemoCanvas
This commit is contained in:
parent
98cdbd7d20
commit
f835a14563
|
@ -33,7 +33,12 @@ public static class Program
|
|||
outputTemplate: format)
|
||||
.CreateLogger();
|
||||
|
||||
Run();
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
var demo = new RecastDemo();
|
||||
demo.start();
|
||||
demo.Run();
|
||||
}
|
||||
}
|
|
@ -38,7 +38,6 @@ using DotRecast.Detour.Io;
|
|||
using DotRecast.Recast.Demo.Builder;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.Demo.Geom;
|
||||
|
||||
using DotRecast.Recast.Demo.Tools;
|
||||
using DotRecast.Recast.Demo.UI;
|
||||
using static DotRecast.Core.RecastMath;
|
||||
|
@ -50,11 +49,12 @@ public class RecastDemo
|
|||
{
|
||||
private static readonly ILogger Logger = Log.ForContext<RecastDemo>();
|
||||
|
||||
private RcCanvas _canvas;
|
||||
private IWindow window;
|
||||
private GL _gl;
|
||||
private IInputContext _input;
|
||||
private ImGuiController _imgui;
|
||||
private GL _gl;
|
||||
private RecastDemoCanvas _canvas;
|
||||
|
||||
private int width = 1000;
|
||||
private int height = 900;
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class RecastDemo
|
|||
{
|
||||
}
|
||||
|
||||
public void start()
|
||||
public void Run()
|
||||
{
|
||||
window = CreateWindow();
|
||||
window.Run();
|
||||
|
@ -266,7 +266,7 @@ public class RecastDemo
|
|||
options.Title = title;
|
||||
options.Size = new Vector2D<int>(width, height);
|
||||
options.Position = new Vector2D<int>((resolution.X - width) / 2, (resolution.Y - height) / 2);
|
||||
options.VSync = false;
|
||||
options.VSync = true;
|
||||
options.ShouldSwapAutomatically = false;
|
||||
options.PreferredDepthBufferBits = 24;
|
||||
window = Window.Create(options);
|
||||
|
@ -280,8 +280,8 @@ public class RecastDemo
|
|||
window.Load += OnWindowOnLoad;
|
||||
window.Resize += OnWindowResize;
|
||||
window.FramebufferResize += OnWindowFramebufferSizeChanged;
|
||||
window.Update += OnWindowOnUpdate;
|
||||
window.Render += OnWindowOnRender;
|
||||
window.Update += OnWindowUpdate;
|
||||
window.Render += OnWindowRender;
|
||||
|
||||
|
||||
// // -- move somewhere else:
|
||||
|
@ -378,7 +378,7 @@ public class RecastDemo
|
|||
);
|
||||
logUI = new RcLogView();
|
||||
|
||||
_canvas = new RcCanvas(window, settingsUI, toolsUI, logUI);
|
||||
_canvas = new RecastDemoCanvas(window, settingsUI, toolsUI, logUI);
|
||||
|
||||
var vendor = _gl.GetStringS(GLEnum.Vendor);
|
||||
var version = _gl.GetStringS(GLEnum.Version);
|
||||
|
@ -419,7 +419,7 @@ public class RecastDemo
|
|||
}
|
||||
}
|
||||
|
||||
private void OnWindowOnUpdate(double dt)
|
||||
private void OnWindowUpdate(double dt)
|
||||
{
|
||||
/*
|
||||
* try (MemoryStack stack = stackPush()) { int[] w = stack.mallocInt(1); int[] h =
|
||||
|
@ -483,9 +483,8 @@ public class RecastDemo
|
|||
var bytes = Loader.ToBytes(settingsUI.GetMeshInputFilePath());
|
||||
sample.update(loadInputMesh(bytes), null, null);
|
||||
}
|
||||
|
||||
// else if (settingsUI.isNavMeshInputTrigerred())
|
||||
// {
|
||||
else if (settingsUI.isNavMeshInputTrigerred())
|
||||
{
|
||||
// try (MemoryStack stack = stackPush()) {
|
||||
// PointerBuffer aFilterPatterns = stack.mallocPointer(4);
|
||||
// aFilterPatterns.put(stack.UTF8("*.bin"));
|
||||
|
@ -507,7 +506,7 @@ public class RecastDemo
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (settingsUI.isBuildTriggered() && sample.getInputGeom() != null)
|
||||
{
|
||||
if (!building)
|
||||
|
@ -566,7 +565,6 @@ public class RecastDemo
|
|||
{
|
||||
Logger.Information($"{key}: {millis} ms");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -716,7 +714,7 @@ public class RecastDemo
|
|||
_imgui.Update((float)dt);
|
||||
}
|
||||
|
||||
private unsafe void OnWindowOnRender(double dt)
|
||||
private unsafe void OnWindowRender(double dt)
|
||||
{
|
||||
// _gl.ClearColor(Color.CadetBlue);
|
||||
// _gl.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace DotRecast.Recast.Demo.UI;
|
|||
|
||||
public interface IRcView
|
||||
{
|
||||
void Bind(RcCanvas canvas);
|
||||
void Bind(RecastDemoCanvas canvas);
|
||||
bool IsMouseInside();
|
||||
void Update(double dt);
|
||||
void Draw(double dt);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace DotRecast.Recast.Demo.UI;
|
|||
|
||||
public class RcLogView : IRcView
|
||||
{
|
||||
private RcCanvas _canvas;
|
||||
private RecastDemoCanvas _canvas;
|
||||
private bool _mouseInside;
|
||||
|
||||
private List<string> _lines = new();
|
||||
|
@ -60,7 +60,7 @@ public class RcLogView : IRcView
|
|||
}
|
||||
|
||||
|
||||
public void Bind(RcCanvas canvas)
|
||||
public void Bind(RecastDemoCanvas canvas)
|
||||
{
|
||||
_canvas = canvas;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,9 @@ public class RcSettingsView : IRcView
|
|||
private bool _mouseInside;
|
||||
public bool IsMouseInside() => _mouseInside;
|
||||
|
||||
private RcCanvas _canvas;
|
||||
private RecastDemoCanvas _canvas;
|
||||
|
||||
public void Bind(RcCanvas canvas)
|
||||
public void Bind(RecastDemoCanvas canvas)
|
||||
{
|
||||
_canvas = canvas;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ using Silk.NET.Windowing;
|
|||
|
||||
namespace DotRecast.Recast.Demo.UI;
|
||||
|
||||
public class RcCanvas
|
||||
public class RecastDemoCanvas
|
||||
{
|
||||
private static readonly ILogger Logger = Log.ForContext<RecastDemo>();
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class RcCanvas
|
|||
|
||||
public Vector2D<int> Size => _window.Size;
|
||||
|
||||
public RcCanvas(IWindow window, params IRcView[] views)
|
||||
public RecastDemoCanvas(IWindow window, params IRcView[] views)
|
||||
{
|
||||
_window = window;
|
||||
_views = views;
|
||||
|
@ -112,10 +112,6 @@ public class RcCanvas
|
|||
{
|
||||
view.Draw(dt);
|
||||
_mouseOverUI |= view.IsMouseInside();
|
||||
// if (_mouseOverUI)
|
||||
// {
|
||||
// Logger.Information("mouse hover!");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,9 +41,9 @@ public class ToolsView : IRcView
|
|||
private bool _mouseInside;
|
||||
public bool IsMouseInside() => _mouseInside;
|
||||
|
||||
private RcCanvas _canvas;
|
||||
private RecastDemoCanvas _canvas;
|
||||
|
||||
public void Bind(RcCanvas canvas)
|
||||
public void Bind(RecastDemoCanvas canvas)
|
||||
{
|
||||
_canvas = canvas;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue