forked from bit/DotRecastNetSim
rename event
This commit is contained in:
parent
9264cf6446
commit
3b9234e83d
|
@ -1,6 +1,6 @@
|
||||||
namespace DotRecast.Recast.Demo.Messages;
|
namespace DotRecast.Recast.Demo.Messages;
|
||||||
|
|
||||||
public class SourceGeomFileSelectedEvent : IRecastDemoMessage
|
public class GeomLoadBeganEvent : IRecastDemoMessage
|
||||||
{
|
{
|
||||||
public required string FilePath { get; init; }
|
public required string FilePath { get; init; }
|
||||||
}
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DotRecast.Recast.Demo.Messages;
|
||||||
|
|
||||||
|
public class NavMeshBuildBeganEvent : IRecastDemoMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
namespace DotRecast.Recast.Demo.Messages;
|
|
||||||
|
|
||||||
public class NavMeshBuildEvent : IRecastDemoMessage
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DotRecast.Recast.Demo.Messages;
|
||||||
|
|
||||||
|
public class NavMeshLoadBeganEvent : IRecastDemoMessage
|
||||||
|
{
|
||||||
|
public required string FilePath { get; init; }
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DotRecast.Recast.Demo.Messages;
|
||||||
|
|
||||||
|
public class NavMeshSaveBeganEvent : IRecastDemoMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -493,31 +493,6 @@ public class RecastDemo : IRecastDemoChannel
|
||||||
simIter++;
|
simIter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsView.IsNavMeshInputTrigerred())
|
|
||||||
{
|
|
||||||
// try (MemoryStack stack = StackPush()) {
|
|
||||||
// PointerBuffer aFilterPatterns = stack.MallocPointer(4);
|
|
||||||
// aFilterPatterns.Put(stack.UTF8("*.bin"));
|
|
||||||
// aFilterPatterns.Put(stack.UTF8("*.zip"));
|
|
||||||
// aFilterPatterns.Put(stack.UTF8("*.bytes"));
|
|
||||||
// aFilterPatterns.Put(stack.UTF8("*.navmesh"));
|
|
||||||
// aFilterPatterns.Flip();
|
|
||||||
// string filename = TinyFileDialogs.Tinyfd_openFileDialog("Open Nav Mesh File", "", aFilterPatterns,
|
|
||||||
// "Nav Mesh File", false);
|
|
||||||
// if (filename != null) {
|
|
||||||
// File file = new File(filename);
|
|
||||||
// if (file.Exists()) {
|
|
||||||
// try {
|
|
||||||
// LoadNavMesh(file, filename);
|
|
||||||
// geom = null;
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_mouseOverMenu)
|
if (!_mouseOverMenu)
|
||||||
{
|
{
|
||||||
GLU.GlhUnProjectf(mousePos[0], viewport[3] - 1 - mousePos[1], 0.0f, modelviewMatrix, projectionMatrix, viewport, ref rayStart);
|
GLU.GlhUnProjectf(mousePos[0], viewport[3] - 1 - mousePos[1], 0.0f, modelviewMatrix, projectionMatrix, viewport, ref rayStart);
|
||||||
|
@ -700,17 +675,25 @@ public class RecastDemo : IRecastDemoChannel
|
||||||
|
|
||||||
private void OnMessage(IRecastDemoMessage message)
|
private void OnMessage(IRecastDemoMessage message)
|
||||||
{
|
{
|
||||||
if (message is SourceGeomFileSelectedEvent args)
|
if (message is GeomLoadBeganEvent args)
|
||||||
{
|
{
|
||||||
OnSourceGeomFileSelected(args);
|
OnGeomLoadBegan(args);
|
||||||
}
|
}
|
||||||
else if (message is NavMeshBuildEvent args2)
|
else if (message is NavMeshBuildBeganEvent args2)
|
||||||
{
|
{
|
||||||
OnNavMeshBuild(args2);
|
OnNavMeshBuildBegan(args2);
|
||||||
|
}
|
||||||
|
else if (message is NavMeshSaveBeganEvent args3)
|
||||||
|
{
|
||||||
|
OnNavMeshSaveBegan(args3);
|
||||||
|
}
|
||||||
|
else if (message is NavMeshLoadBeganEvent args4)
|
||||||
|
{
|
||||||
|
OnNavMeshLoadBegan(args4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSourceGeomFileSelected(SourceGeomFileSelectedEvent args)
|
private void OnGeomLoadBegan(GeomLoadBeganEvent args)
|
||||||
{
|
{
|
||||||
var bytes = Loader.ToBytes(args.FilePath);
|
var bytes = Loader.ToBytes(args.FilePath);
|
||||||
var geom = LoadInputMesh(bytes);
|
var geom = LoadInputMesh(bytes);
|
||||||
|
@ -718,7 +701,7 @@ public class RecastDemo : IRecastDemoChannel
|
||||||
sample.Update(geom, ImmutableArray<RecastBuilderResult>.Empty, null);
|
sample.Update(geom, ImmutableArray<RecastBuilderResult>.Empty, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNavMeshBuild(NavMeshBuildEvent args)
|
private void OnNavMeshBuildBegan(NavMeshBuildBeganEvent args)
|
||||||
{
|
{
|
||||||
if (null == sample.GetInputGeom())
|
if (null == sample.GetInputGeom())
|
||||||
{
|
{
|
||||||
|
@ -818,4 +801,34 @@ public class RecastDemo : IRecastDemoChannel
|
||||||
Logger.Information($"{key}: {millis} ms");
|
Logger.Information($"{key}: {millis} ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnNavMeshSaveBegan(NavMeshSaveBeganEvent args)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNavMeshLoadBegan(NavMeshLoadBeganEvent args)
|
||||||
|
{
|
||||||
|
// try (MemoryStack stack = StackPush()) {
|
||||||
|
// PointerBuffer aFilterPatterns = stack.MallocPointer(4);
|
||||||
|
// aFilterPatterns.Put(stack.UTF8("*.bin"));
|
||||||
|
// aFilterPatterns.Put(stack.UTF8("*.zip"));
|
||||||
|
// aFilterPatterns.Put(stack.UTF8("*.bytes"));
|
||||||
|
// aFilterPatterns.Put(stack.UTF8("*.navmesh"));
|
||||||
|
// aFilterPatterns.Flip();
|
||||||
|
// string filename = TinyFileDialogs.Tinyfd_openFileDialog("Open Nav Mesh File", "", aFilterPatterns,
|
||||||
|
// "Nav Mesh File", false);
|
||||||
|
// if (filename != null) {
|
||||||
|
// File file = new File(filename);
|
||||||
|
// if (file.Exists()) {
|
||||||
|
// try {
|
||||||
|
// LoadNavMesh(file, filename);
|
||||||
|
// geom = null;
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// Console.WriteLine(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -44,8 +44,6 @@ public class RcSettingsView : IRcView
|
||||||
|
|
||||||
private int drawMode = DrawMode.DRAWMODE_NAVMESH.Idx;
|
private int drawMode = DrawMode.DRAWMODE_NAVMESH.Idx;
|
||||||
|
|
||||||
private bool navMeshInputTrigerred;
|
|
||||||
|
|
||||||
private bool _isHovered;
|
private bool _isHovered;
|
||||||
public bool IsHovered() => _isHovered;
|
public bool IsHovered() => _isHovered;
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ public class RcSettingsView : IRcView
|
||||||
var settings = _sample.GetSettings();
|
var settings = _sample.GetSettings();
|
||||||
|
|
||||||
ImGui.Begin("Properties");
|
ImGui.Begin("Properties");
|
||||||
|
|
||||||
// size reset
|
// size reset
|
||||||
var size = ImGui.GetItemRectSize();
|
var size = ImGui.GetItemRectSize();
|
||||||
if (32 >= size.X && 32 >= size.Y)
|
if (32 >= size.X && 32 >= size.Y)
|
||||||
|
@ -104,7 +102,7 @@ public class RcSettingsView : IRcView
|
||||||
var picker = ImFilePicker.GetFilePicker(strLoadSourceGeom, Path.Combine(Environment.CurrentDirectory), ".obj");
|
var picker = ImFilePicker.GetFilePicker(strLoadSourceGeom, Path.Combine(Environment.CurrentDirectory), ".obj");
|
||||||
if (picker.Draw())
|
if (picker.Draw())
|
||||||
{
|
{
|
||||||
_channel.SendMessage(new SourceGeomFileSelectedEvent()
|
_channel.SendMessage(new GeomLoadBeganEvent()
|
||||||
{
|
{
|
||||||
FilePath = picker.SelectedFile,
|
FilePath = picker.SelectedFile,
|
||||||
});
|
});
|
||||||
|
@ -192,9 +190,9 @@ public class RcSettingsView : IRcView
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.Button("Build NavMesh"))
|
if (ImGui.Button("Build NavMesh"))
|
||||||
{
|
{
|
||||||
_channel.SendMessage(new NavMeshBuildEvent());
|
_channel.SendMessage(new NavMeshBuildBeganEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const string strLoadNavMesh = "Load NavMesh";
|
const string strLoadNavMesh = "Load NavMesh";
|
||||||
if (ImGui.Button(strLoadNavMesh))
|
if (ImGui.Button(strLoadNavMesh))
|
||||||
|
@ -208,7 +206,10 @@ public class RcSettingsView : IRcView
|
||||||
var picker = ImFilePicker.GetFilePicker(strLoadNavMesh, Path.Combine(Environment.CurrentDirectory));
|
var picker = ImFilePicker.GetFilePicker(strLoadNavMesh, Path.Combine(Environment.CurrentDirectory));
|
||||||
if (picker.Draw())
|
if (picker.Draw())
|
||||||
{
|
{
|
||||||
Logger.Information(picker.SelectedFile);
|
_channel.SendMessage(new NavMeshLoadBeganEvent()
|
||||||
|
{
|
||||||
|
FilePath = picker.SelectedFile,
|
||||||
|
});
|
||||||
ImFilePicker.RemoveFilePicker(strLoadNavMesh);
|
ImFilePicker.RemoveFilePicker(strLoadNavMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,12 +217,9 @@ public class RcSettingsView : IRcView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui.Button("Save NavMesh"))
|
||||||
{
|
{
|
||||||
const string strSaveNavMesh = "Save NavMesh";
|
_channel.SendMessage(new NavMeshSaveBeganEvent());
|
||||||
if (ImGui.Button(strSaveNavMesh))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,9 +265,4 @@ public class RcSettingsView : IRcView
|
||||||
{
|
{
|
||||||
this.maxPolys = maxPolys;
|
this.maxPolys = maxPolys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsNavMeshInputTrigerred()
|
|
||||||
{
|
|
||||||
return navMeshInputTrigerred;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue