From c069c1fd54bc2bc54a22296dffd8ad50fbbdde78 Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 13 Jun 2023 00:24:48 +0900 Subject: [PATCH] move Demo.Sample to DemoTool.Sample --- .../Draw/NavMeshRenderer.cs | 1 + src/DotRecast.Recast.Demo/RecastDemo.cs | 4 +- src/DotRecast.Recast.Demo/Sample.cs | 98 ------------------- .../Tools/ConvexVolumeTool.cs | 1 + src/DotRecast.Recast.Demo/Tools/IRcTool.cs | 1 + .../Tools/OffMeshConnectionTool.cs | 1 + src/DotRecast.Recast.Demo/UI/RcToolsetView.cs | 1 + src/DotRecast.Recast.DemoTool/Sample.cs | 96 ++++++++++++++++++ 8 files changed, 103 insertions(+), 100 deletions(-) delete mode 100644 src/DotRecast.Recast.Demo/Sample.cs create mode 100644 src/DotRecast.Recast.DemoTool/Sample.cs diff --git a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs index 26c311a..51d9a69 100644 --- a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs +++ b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs @@ -24,6 +24,7 @@ using DotRecast.Detour; using DotRecast.Recast.DemoTool.Builder; using DotRecast.Recast.DemoTool.Geom; using DotRecast.Recast.Demo.UI; +using DotRecast.Recast.DemoTool; namespace DotRecast.Recast.Demo.Draw; diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index f619369..5b4523e 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -367,7 +367,7 @@ public class RecastDemo _imgui = new ImGuiController(_gl, window, _input); DemoInputGeomProvider geom = LoadInputMesh(Loader.ToBytes("nav_test.obj")); - sample = new Sample(geom, ImmutableArray.Empty, null, dd); + sample = new Sample(geom, ImmutableArray.Empty, null); settingsView = new RcSettingsView(); settingsView.SetSample(sample); @@ -486,7 +486,7 @@ public class RecastDemo { var bytes = Loader.ToBytes(settingsView.GetMeshInputFilePath()); var geom = LoadInputMesh(bytes); - + sample.Update(geom, ImmutableArray.Empty, null); } else if (settingsView.IsNavMeshInputTrigerred()) diff --git a/src/DotRecast.Recast.Demo/Sample.cs b/src/DotRecast.Recast.Demo/Sample.cs deleted file mode 100644 index f8e9fa9..0000000 --- a/src/DotRecast.Recast.Demo/Sample.cs +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright (c) 2009-2010 Mikko Mononen memon@inside.org -recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org -DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -using System.Collections.Generic; -using DotRecast.Detour; -using DotRecast.Recast.Demo.Draw; -using DotRecast.Recast.DemoTool.Geom; -using DotRecast.Recast.Demo.UI; -using DotRecast.Recast.DemoTool; - -namespace DotRecast.Recast.Demo; - -public class Sample -{ - private DemoInputGeomProvider _inputGeom; - private DtNavMesh _navMesh; - private DtNavMeshQuery _navMeshQuery; - private readonly RcSampleSettings _settings; - private IList _recastResults; - private bool _changed; - - public Sample(DemoInputGeomProvider inputGeom, IList recastResults, DtNavMesh navMesh, RecastDebugDraw debugDraw) - { - _inputGeom = inputGeom; - _recastResults = recastResults; - _navMesh = navMesh; - _settings = new(); - - SetQuery(navMesh); - _changed = true; - } - - private void SetQuery(DtNavMesh navMesh) - { - _navMeshQuery = navMesh != null ? new DtNavMeshQuery(navMesh) : null; - } - - public DemoInputGeomProvider GetInputGeom() - { - return _inputGeom; - } - - public IList GetRecastResults() - { - return _recastResults; - } - - public DtNavMesh GetNavMesh() - { - return _navMesh; - } - - public RcSampleSettings GetSettings() - { - return _settings; - } - - public DtNavMeshQuery GetNavMeshQuery() - { - return _navMeshQuery; - } - - public bool IsChanged() - { - return _changed; - } - - public void SetChanged(bool changed) - { - _changed = changed; - } - - public void Update(DemoInputGeomProvider geom, IList recastResults, DtNavMesh navMesh) - { - _inputGeom = geom; - _recastResults = recastResults; - _navMesh = navMesh; - SetQuery(navMesh); - _changed = true; - } -} \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs index 2c00a68..70230be 100644 --- a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using DotRecast.Core; using DotRecast.Recast.DemoTool.Builder; using DotRecast.Recast.Demo.Draw; +using DotRecast.Recast.DemoTool; using DotRecast.Recast.DemoTool.Geom; using ImGuiNET; using static DotRecast.Recast.Demo.Draw.DebugDraw; diff --git a/src/DotRecast.Recast.Demo/Tools/IRcTool.cs b/src/DotRecast.Recast.Demo/Tools/IRcTool.cs index fef856a..3b946fd 100644 --- a/src/DotRecast.Recast.Demo/Tools/IRcTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/IRcTool.cs @@ -20,6 +20,7 @@ freely, subject to the following restrictions: using DotRecast.Core; using DotRecast.Recast.Demo.Draw; +using DotRecast.Recast.DemoTool; namespace DotRecast.Recast.Demo.Tools; diff --git a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs index b0b7576..de5d117 100644 --- a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs @@ -22,6 +22,7 @@ using System; using DotRecast.Core; using DotRecast.Recast.DemoTool.Builder; using DotRecast.Recast.Demo.Draw; +using DotRecast.Recast.DemoTool; using DotRecast.Recast.DemoTool.Geom; using ImGuiNET; using static DotRecast.Recast.Demo.Draw.DebugDraw; diff --git a/src/DotRecast.Recast.Demo/UI/RcToolsetView.cs b/src/DotRecast.Recast.Demo/UI/RcToolsetView.cs index d0d7015..a4103ba 100644 --- a/src/DotRecast.Recast.Demo/UI/RcToolsetView.cs +++ b/src/DotRecast.Recast.Demo/UI/RcToolsetView.cs @@ -22,6 +22,7 @@ using System; using System.Numerics; using DotRecast.Core; using DotRecast.Recast.Demo.Tools; +using DotRecast.Recast.DemoTool; using ImGuiNET; namespace DotRecast.Recast.Demo.UI; diff --git a/src/DotRecast.Recast.DemoTool/Sample.cs b/src/DotRecast.Recast.DemoTool/Sample.cs new file mode 100644 index 0000000..83f4675 --- /dev/null +++ b/src/DotRecast.Recast.DemoTool/Sample.cs @@ -0,0 +1,96 @@ +/* +Copyright (c) 2009-2010 Mikko Mononen memon@inside.org +recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org +DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +using System.Collections.Generic; +using DotRecast.Detour; +using DotRecast.Recast.DemoTool.Geom; + +namespace DotRecast.Recast.DemoTool +{ + public class Sample + { + private DemoInputGeomProvider _inputGeom; + private DtNavMesh _navMesh; + private DtNavMeshQuery _navMeshQuery; + private readonly RcSampleSettings _settings; + private IList _recastResults; + private bool _changed; + + public Sample(DemoInputGeomProvider inputGeom, IList recastResults, DtNavMesh navMesh) + { + _inputGeom = inputGeom; + _recastResults = recastResults; + _navMesh = navMesh; + _settings = new RcSampleSettings(); + + SetQuery(navMesh); + _changed = true; + } + + private void SetQuery(DtNavMesh navMesh) + { + _navMeshQuery = navMesh != null ? new DtNavMeshQuery(navMesh) : null; + } + + public DemoInputGeomProvider GetInputGeom() + { + return _inputGeom; + } + + public IList GetRecastResults() + { + return _recastResults; + } + + public DtNavMesh GetNavMesh() + { + return _navMesh; + } + + public RcSampleSettings GetSettings() + { + return _settings; + } + + public DtNavMeshQuery GetNavMeshQuery() + { + return _navMeshQuery; + } + + public bool IsChanged() + { + return _changed; + } + + public void SetChanged(bool changed) + { + _changed = changed; + } + + public void Update(DemoInputGeomProvider geom, IList recastResults, DtNavMesh navMesh) + { + _inputGeom = geom; + _recastResults = recastResults; + _navMesh = navMesh; + SetQuery(navMesh); + _changed = true; + } + } +} \ No newline at end of file