From e6e17d83a227413275c56ff9ecf90a8f354b14ec Mon Sep 17 00:00:00 2001 From: ikpil Date: Thu, 27 Jul 2023 14:19:31 +0900 Subject: [PATCH] typo --- src/DotRecast.Detour/DtOffMeshConnection.cs | 25 +++----- .../Draw/NavMeshRenderer.cs | 2 +- ...avMeshBuilder.cs => DemoNavMeshBuilder.cs} | 61 ++++++++++--------- .../Builder/SampleAreaModifications.cs | 15 +++-- .../Builder/SoloNavMeshBuilder.cs | 11 ++-- .../Builder/TileNavMeshBuilder.cs | 56 ++++++++--------- .../Geom/DemoInputGeomProvider.cs | 8 +-- .../Tools/OffMeshConnectionToolImpl.cs | 1 + .../Tools/TileToolImpl.cs | 5 +- .../TestDetourBuilder.cs | 10 +-- 10 files changed, 97 insertions(+), 97 deletions(-) rename src/DotRecast.Recast.DemoTool/Builder/{AbstractNavMeshBuilder.cs => DemoNavMeshBuilder.cs} (62%) diff --git a/src/DotRecast.Detour/DtOffMeshConnection.cs b/src/DotRecast.Detour/DtOffMeshConnection.cs index b0e2ac0..0ebecd0 100644 --- a/src/DotRecast.Detour/DtOffMeshConnection.cs +++ b/src/DotRecast.Detour/DtOffMeshConnection.cs @@ -20,33 +20,28 @@ freely, subject to the following restrictions: namespace DotRecast.Detour { - /** - * Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is a user defined - * traversable connection made up to two vertices. - */ + /// Defines an navigation mesh off-mesh connection within a dtMeshTile object. + /// An off-mesh connection is a user defined traversable connection made up to two vertices. public class DtOffMeshConnection { - /** The endpoints of the connection. [(ax, ay, az, bx, by, bz)] */ + /// The endpoints of the connection. [(ax, ay, az, bx, by, bz)] public float[] pos = new float[6]; - /** The radius of the endpoints. [Limit: >= 0] */ + /// The radius of the endpoints. [Limit: >= 0] public float rad; - /** The polygon reference of the connection within the tile. */ + /// The polygon reference of the connection within the tile. public int poly; - /** - * Link flags. - * - * @note These are not the connection's user defined flags. Those are assigned via the connection's Poly definition. - * These are link flags used for internal purposes. - */ + /// Link flags. + /// @note These are not the connection's user defined flags. Those are assigned via the + /// connection's dtPoly definition. These are link flags used for internal purposes. public int flags; - /** End point side. */ + /// End point side. public int side; - /** The id of the offmesh connection. (User assigned when the navigation mesh is built.) */ + /// The id of the offmesh connection. (User assigned when the navigation mesh is built.) public int userId; } } \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs index b4b5440..f3edad6 100644 --- a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs +++ b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs @@ -228,7 +228,7 @@ public class NavMeshRenderer _debugDraw.DepthMask(false); _debugDraw.Begin(DebugDrawPrimitives.LINES, 2.0f); - foreach (DemoOffMeshConnection con in geom.GetOffMeshConnections()) + foreach (var con in geom.GetOffMeshConnections()) { float[] v = con.verts; _debugDraw.Vertex(v[0], v[1], v[2], baseColor); diff --git a/src/DotRecast.Recast.DemoTool/Builder/AbstractNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/DemoNavMeshBuilder.cs similarity index 62% rename from src/DotRecast.Recast.DemoTool/Builder/AbstractNavMeshBuilder.cs rename to src/DotRecast.Recast.DemoTool/Builder/DemoNavMeshBuilder.cs index d2d20b1..bb3b3b8 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/AbstractNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/DemoNavMeshBuilder.cs @@ -1,48 +1,49 @@ using DotRecast.Detour; using DotRecast.Recast.DemoTool.Geom; +using DotRecast.Recast.Geom; namespace DotRecast.Recast.DemoTool.Builder { - public abstract class AbstractNavMeshBuilder + public static class DemoNavMeshBuilder { - protected DtNavMeshCreateParams GetNavMeshCreateParams(DemoInputGeomProvider m_geom, float m_cellSize, - float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, + public static DtNavMeshCreateParams GetNavMeshCreateParams(DemoInputGeomProvider geom, float cellSize, + float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, RecastBuilderResult rcResult) { - RcPolyMesh m_pmesh = rcResult.GetMesh(); - RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail(); + RcPolyMesh pmesh = rcResult.GetMesh(); + RcPolyMeshDetail dmesh = rcResult.GetMeshDetail(); DtNavMeshCreateParams option = new DtNavMeshCreateParams(); - for (int i = 0; i < m_pmesh.npolys; ++i) + for (int i = 0; i < pmesh.npolys; ++i) { - m_pmesh.flags[i] = 1; + pmesh.flags[i] = 1; } - option.verts = m_pmesh.verts; - option.vertCount = m_pmesh.nverts; - option.polys = m_pmesh.polys; - option.polyAreas = m_pmesh.areas; - option.polyFlags = m_pmesh.flags; - option.polyCount = m_pmesh.npolys; - option.nvp = m_pmesh.nvp; - if (m_dmesh != null) + option.verts = pmesh.verts; + option.vertCount = pmesh.nverts; + option.polys = pmesh.polys; + option.polyAreas = pmesh.areas; + option.polyFlags = pmesh.flags; + option.polyCount = pmesh.npolys; + option.nvp = pmesh.nvp; + if (dmesh != null) { - option.detailMeshes = m_dmesh.meshes; - option.detailVerts = m_dmesh.verts; - option.detailVertsCount = m_dmesh.nverts; - option.detailTris = m_dmesh.tris; - option.detailTriCount = m_dmesh.ntris; + option.detailMeshes = dmesh.meshes; + option.detailVerts = dmesh.verts; + option.detailVertsCount = dmesh.nverts; + option.detailTris = dmesh.tris; + option.detailTriCount = dmesh.ntris; } - option.walkableHeight = m_agentHeight; - option.walkableRadius = m_agentRadius; - option.walkableClimb = m_agentMaxClimb; - option.bmin = m_pmesh.bmin; - option.bmax = m_pmesh.bmax; - option.cs = m_cellSize; - option.ch = m_cellHeight; + option.walkableHeight = agentHeight; + option.walkableRadius = agentRadius; + option.walkableClimb = agentMaxClimb; + option.bmin = pmesh.bmin; + option.bmax = pmesh.bmax; + option.cs = cellSize; + option.ch = cellHeight; option.buildBvTree = true; - option.offMeshConCount = m_geom.GetOffMeshConnections().Count; + option.offMeshConCount = geom.GetOffMeshConnections().Count; option.offMeshConVerts = new float[option.offMeshConCount * 6]; option.offMeshConRad = new float[option.offMeshConCount]; option.offMeshConDir = new int[option.offMeshConCount]; @@ -51,7 +52,7 @@ namespace DotRecast.Recast.DemoTool.Builder option.offMeshConUserID = new int[option.offMeshConCount]; for (int i = 0; i < option.offMeshConCount; i++) { - DemoOffMeshConnection offMeshCon = m_geom.GetOffMeshConnections()[i]; + DemoOffMeshConnection offMeshCon = geom.GetOffMeshConnections()[i]; for (int j = 0; j < 6; j++) { option.offMeshConVerts[6 * i + j] = offMeshCon.verts[j]; @@ -66,7 +67,7 @@ namespace DotRecast.Recast.DemoTool.Builder return option; } - protected DtMeshData UpdateAreaAndFlags(DtMeshData meshData) + public static DtMeshData UpdateAreaAndFlags(DtMeshData meshData) { // Update poly flags from areas. for (int i = 0; i < meshData.polys.Length; ++i) diff --git a/src/DotRecast.Recast.DemoTool/Builder/SampleAreaModifications.cs b/src/DotRecast.Recast.DemoTool/Builder/SampleAreaModifications.cs index c5063de..2263bba 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/SampleAreaModifications.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/SampleAreaModifications.cs @@ -23,7 +23,6 @@ using System.Linq; namespace DotRecast.Recast.DemoTool.Builder { - public class SampleAreaModifications { public const int SAMPLE_POLYAREA_TYPE_GROUND = 0x0; @@ -35,6 +34,13 @@ namespace DotRecast.Recast.DemoTool.Builder public const int SAMPLE_POLYAREA_TYPE_JUMP_AUTO = 0x6; public const int SAMPLE_POLYAREA_TYPE_WALKABLE = 0x3f; + public static readonly int SAMPLE_POLYFLAGS_WALK = 0x01; // Ability to walk (ground, grass, road) + public static readonly int SAMPLE_POLYFLAGS_SWIM = 0x02; // Ability to swim (water). + public static readonly int SAMPLE_POLYFLAGS_DOOR = 0x04; // Ability to move through doors. + public static readonly int SAMPLE_POLYFLAGS_JUMP = 0x08; // Ability to jump. + public static readonly int SAMPLE_POLYFLAGS_DISABLED = 0x10; // Disabled polygon + public static readonly int SAMPLE_POLYFLAGS_ALL = 0xffff; // All abilities. + public static readonly RcAreaModification SAMPLE_AREAMOD_WALKABLE = new RcAreaModification(SAMPLE_POLYAREA_TYPE_WALKABLE); public static readonly RcAreaModification SAMPLE_AREAMOD_GROUND = new RcAreaModification(SAMPLE_POLYAREA_TYPE_GROUND); public static readonly RcAreaModification SAMPLE_AREAMOD_WATER = new RcAreaModification(SAMPLE_POLYAREA_TYPE_WATER); @@ -57,12 +63,5 @@ namespace DotRecast.Recast.DemoTool.Builder { return Values.FirstOrDefault(x => x.Value == value) ?? SAMPLE_AREAMOD_GRASS; } - - public static readonly int SAMPLE_POLYFLAGS_WALK = 0x01; // Ability to walk (ground, grass, road) - public static readonly int SAMPLE_POLYFLAGS_SWIM = 0x02; // Ability to swim (water). - public static readonly int SAMPLE_POLYFLAGS_DOOR = 0x04; // Ability to move through doors. - public static readonly int SAMPLE_POLYFLAGS_JUMP = 0x08; // Ability to jump. - public static readonly int SAMPLE_POLYFLAGS_DISABLED = 0x10; // Disabled polygon - public static readonly int SAMPLE_POLYFLAGS_ALL = 0xffff; // All abilities. } } \ No newline at end of file diff --git a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs index 6de7da2..807cd93 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs @@ -24,7 +24,7 @@ using DotRecast.Recast.DemoTool.Geom; namespace DotRecast.Recast.DemoTool.Builder { - public class SoloNavMeshBuilder : AbstractNavMeshBuilder + public class SoloNavMeshBuilder { public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, @@ -62,12 +62,13 @@ namespace DotRecast.Recast.DemoTool.Builder return rcBuilder.Build(geom, bcfg); } - private DtMeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight, + public DtMeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, RecastBuilderResult result) { - DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, - agentMaxClimb, result); - return UpdateAreaAndFlags(NavMeshBuilder.CreateNavMeshData(option)); + DtNavMeshCreateParams option = DemoNavMeshBuilder + .GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, result); + var meshData = NavMeshBuilder.CreateNavMeshData(option); + return DemoNavMeshBuilder.UpdateAreaAndFlags(meshData); } } } \ No newline at end of file diff --git a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs index 9b98dc9..43cb29f 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs @@ -19,14 +19,12 @@ freely, subject to the following restrictions: using System; using System.Collections.Generic; using System.Threading.Tasks; -using DotRecast.Core; using DotRecast.Detour; using DotRecast.Recast.DemoTool.Geom; -using static DotRecast.Core.RcMath; namespace DotRecast.Recast.DemoTool.Builder { - public class TileNavMeshBuilder : AbstractNavMeshBuilder + public class TileNavMeshBuilder { public TileNavMeshBuilder() { @@ -47,7 +45,7 @@ namespace DotRecast.Recast.DemoTool.Builder return new NavMeshBuildResult(results, tileNavMesh); } - private List BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, + public List BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, @@ -63,7 +61,7 @@ namespace DotRecast.Recast.DemoTool.Builder return rcBuilder.BuildTiles(geom, cfg, Task.Factory); } - private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List meshData, float cellSize, int tileSize, int vertsPerPoly) + public DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List meshData, float cellSize, int tileSize, int vertsPerPoly) { DtNavMeshParams navMeshParams = new DtNavMeshParams(); navMeshParams.orig = geom.GetMeshBoundsMin(); @@ -79,6 +77,31 @@ namespace DotRecast.Recast.DemoTool.Builder return navMesh; } + private List BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight, + float agentRadius, float agentMaxClimb, List results) + { + // Add tiles to nav mesh + List meshData = new List(); + foreach (RecastBuilderResult result in results) + { + int x = result.tileX; + int z = result.tileZ; + DtNavMeshCreateParams option = DemoNavMeshBuilder + .GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, result); + + option.tileX = x; + option.tileZ = z; + DtMeshData md = NavMeshBuilder.CreateNavMeshData(option); + if (md != null) + { + meshData.Add(DemoNavMeshBuilder.UpdateAreaAndFlags(md)); + } + } + + return meshData; + } + + public int GetMaxTiles(DemoInputGeomProvider geom, float cellSize, int tileSize) { int tileBits = GetTileBits(geom, cellSize, tileSize); @@ -107,28 +130,5 @@ namespace DotRecast.Recast.DemoTool.Builder int th = (gh + tileSize - 1) / tileSize; return new int[] { tw, th }; } - - private List BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight, - float agentRadius, float agentMaxClimb, List results) - { - // Add tiles to nav mesh - List meshData = new List(); - foreach (RecastBuilderResult result in results) - { - int x = result.tileX; - int z = result.tileZ; - DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, - agentRadius, agentMaxClimb, result); - option.tileX = x; - option.tileZ = z; - DtMeshData md = NavMeshBuilder.CreateNavMeshData(option); - if (md != null) - { - meshData.Add(UpdateAreaAndFlags(md)); - } - } - - return meshData; - } } } \ No newline at end of file diff --git a/src/DotRecast.Recast.DemoTool/Geom/DemoInputGeomProvider.cs b/src/DotRecast.Recast.DemoTool/Geom/DemoInputGeomProvider.cs index 96a5229..ac05dd5 100644 --- a/src/DotRecast.Recast.DemoTool/Geom/DemoInputGeomProvider.cs +++ b/src/DotRecast.Recast.DemoTool/Geom/DemoInputGeomProvider.cs @@ -34,7 +34,7 @@ namespace DotRecast.Recast.DemoTool.Geom private readonly RcVec3f bmin; private readonly RcVec3f bmax; private readonly List _convexVolumes = new List(); - private readonly List offMeshConnections = new List(); + private readonly List _offMeshConnections = new List(); private readonly RcTriMesh _mesh; public DemoInputGeomProvider(List vertexPositions, List meshFaces) : @@ -134,18 +134,18 @@ namespace DotRecast.Recast.DemoTool.Geom public List GetOffMeshConnections() { - return offMeshConnections; + return _offMeshConnections; } public void AddOffMeshConnection(RcVec3f start, RcVec3f end, float radius, bool bidir, int area, int flags) { - offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags)); + _offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags)); } public void RemoveOffMeshConnections(Predicate filter) { //offMeshConnections.RetainAll(offMeshConnections.Stream().Filter(c -> !filter.Test(c)).Collect(ToList())); - offMeshConnections.RemoveAll(filter); // TODO : 확인 필요 + _offMeshConnections.RemoveAll(filter); // TODO : 확인 필요 } public float? RaycastMesh(RcVec3f src, RcVec3f dst) diff --git a/src/DotRecast.Recast.DemoTool/Tools/OffMeshConnectionToolImpl.cs b/src/DotRecast.Recast.DemoTool/Tools/OffMeshConnectionToolImpl.cs index 6518f78..eb1eed6 100644 --- a/src/DotRecast.Recast.DemoTool/Tools/OffMeshConnectionToolImpl.cs +++ b/src/DotRecast.Recast.DemoTool/Tools/OffMeshConnectionToolImpl.cs @@ -2,6 +2,7 @@ using DotRecast.Core; using DotRecast.Recast.DemoTool.Builder; using DotRecast.Recast.DemoTool.Geom; +using DotRecast.Recast.Geom; namespace DotRecast.Recast.DemoTool.Tools { diff --git a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs index 8918552..b02024a 100644 --- a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs +++ b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs @@ -1,4 +1,5 @@ using DotRecast.Core; +using DotRecast.Detour.TileCache; namespace DotRecast.Recast.DemoTool.Tools { @@ -36,9 +37,9 @@ namespace DotRecast.Recast.DemoTool.Tools int tx = (int)((pos.x - bmin[0]) / ts); int ty = (int)((pos.z - bmin[2]) / ts); - + var tileRef = navMesh.GetTileRefAt(tx, ty, 0); - navMesh.RemoveTile(tileRef); + // navMesh.RemoveTile(tileRef); } public void RemoveTile(RcVec3f pos) diff --git a/test/DotRecast.Detour.Test/TestDetourBuilder.cs b/test/DotRecast.Detour.Test/TestDetourBuilder.cs index 3f27cb1..55f22a5 100644 --- a/test/DotRecast.Detour.Test/TestDetourBuilder.cs +++ b/test/DotRecast.Detour.Test/TestDetourBuilder.cs @@ -93,10 +93,12 @@ public class TestDetourBuilder : DetourBuilder option.ch = rcConfig.ch; option.buildBvTree = true; /* - * option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts(); option.offMeshConRad = - * m_geom->GetOffMeshConnectionRads(); option.offMeshConDir = m_geom->GetOffMeshConnectionDirs(); - * option.offMeshConAreas = m_geom->GetOffMeshConnectionAreas(); option.offMeshConFlags = - * m_geom->GetOffMeshConnectionFlags(); option.offMeshConUserID = m_geom->GetOffMeshConnectionId(); + * option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts(); + * option.offMeshConRad = m_geom->GetOffMeshConnectionRads(); + * option.offMeshConDir = m_geom->GetOffMeshConnectionDirs(); + * option.offMeshConAreas = m_geom->GetOffMeshConnectionAreas(); + * option.offMeshConFlags = m_geom->GetOffMeshConnectionFlags(); + * option.offMeshConUserID = m_geom->GetOffMeshConnectionId(); * option.offMeshConCount = m_geom->GetOffMeshConnectionCount(); */ return option;