diff --git a/src/DotRecast.Core/Edge.cs b/src/DotRecast.Core/Edge.cs new file mode 100644 index 0000000..33941d2 --- /dev/null +++ b/src/DotRecast.Core/Edge.cs @@ -0,0 +1,9 @@ +namespace DotRecast.Core +{ + public class Edge + { + public int[] vert = new int[2]; + public int[] polyEdge = new int[2]; + public int[] poly = new int[2]; + } +} \ No newline at end of file diff --git a/src/DotRecast.Detour.Crowd/LocalBoundary.cs b/src/DotRecast.Detour.Crowd/LocalBoundary.cs index 89eb6e9..03cf691 100644 --- a/src/DotRecast.Detour.Crowd/LocalBoundary.cs +++ b/src/DotRecast.Detour.Crowd/LocalBoundary.cs @@ -31,14 +31,6 @@ namespace DotRecast.Detour.Crowd { public const int MAX_LOCAL_SEGS = 8; - private class Segment - { - /** Segment start/end */ - public Vector3f[] s = new Vector3f[2]; - - /** Distance for pruning. */ - public float d; - } Vector3f m_center = new Vector3f(); List m_segs = new List(); @@ -172,4 +164,4 @@ namespace DotRecast.Detour.Crowd return m_segs.Count; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Detour.Crowd/Segment.cs b/src/DotRecast.Detour.Crowd/Segment.cs new file mode 100644 index 0000000..25ac658 --- /dev/null +++ b/src/DotRecast.Detour.Crowd/Segment.cs @@ -0,0 +1,13 @@ +using DotRecast.Core; + +namespace DotRecast.Detour.Crowd +{ + public class Segment + { + /** Segment start/end */ + public Vector3f[] s = new Vector3f[2]; + + /** Distance for pruning. */ + public float d; + } +} \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs index 8a9e3e8..9659d1c 100644 --- a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs +++ b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs @@ -33,10 +33,10 @@ namespace DotRecast.Detour.Extras private static int CreateBVTree(MeshData data, BVNode[] nodes, float quantFactor) { - NavMeshBuilder.BVItem[] items = new NavMeshBuilder.BVItem[data.header.polyCount]; + BVItem[] items = new BVItem[data.header.polyCount]; for (int i = 0; i < data.header.polyCount; i++) { - NavMeshBuilder.BVItem it = new NavMeshBuilder.BVItem(); + BVItem it = new BVItem(); items[i] = it; it.i = i; Vector3f bmin = new Vector3f(); diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs index 54804ff..9ae1ff3 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs @@ -8,9 +8,9 @@ namespace DotRecast.Detour.Extras.Jumplink { public class EdgeExtractor { - public Edge[] ExtractEdges(PolyMesh mesh) + public JumpEdge[] ExtractEdges(PolyMesh mesh) { - List edges = new List(); + List edges = new List(); if (mesh != null) { Vector3f orig = mesh.bmin; @@ -57,7 +57,7 @@ namespace DotRecast.Detour.Extras.Jumplink int va = mesh.polys[p + j] * 3; int vb = mesh.polys[p + nj] * 3; - Edge e = new Edge(); + JumpEdge e = new JumpEdge(); e.sp.x = orig.x + mesh.verts[vb] * cs; e.sp.y = orig.y + mesh.verts[vb + 1] * ch; e.sp.z = orig.z + mesh.verts[vb + 2] * cs; diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs index 858b8e6..09a215c 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs @@ -14,7 +14,7 @@ namespace DotRecast.Detour.Extras.Jumplink public readonly Vector3f ay = new Vector3f(); public readonly Vector3f az = new Vector3f(); - public EdgeSampler(Edge edge, Trajectory trajectory) + public EdgeSampler(JumpEdge edge, Trajectory trajectory) { this.trajectory = trajectory; ax = VSub(edge.sq, edge.sp); diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs index 0f8e24b..05ae1a5 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs @@ -5,7 +5,7 @@ namespace DotRecast.Detour.Extras.Jumplink { class EdgeSamplerFactory { - public EdgeSampler Get(JumpLinkBuilderConfig acfg, JumpLinkType type, Edge edge) + public EdgeSampler Get(JumpLinkBuilderConfig acfg, JumpLinkType type, JumpEdge edge) { EdgeSampler es = null; switch (type.Bit) @@ -25,7 +25,7 @@ namespace DotRecast.Detour.Extras.Jumplink } - private EdgeSampler InitEdgeJumpSampler(JumpLinkBuilderConfig acfg, Edge edge) + private EdgeSampler InitEdgeJumpSampler(JumpLinkBuilderConfig acfg, JumpEdge edge) { EdgeSampler es = new EdgeSampler(edge, new JumpTrajectory(acfg.jumpHeight)); es.start.height = acfg.agentClimb * 2; @@ -53,7 +53,7 @@ namespace DotRecast.Detour.Extras.Jumplink return es; } - private EdgeSampler InitClimbDownSampler(JumpLinkBuilderConfig acfg, Edge edge) + private EdgeSampler InitClimbDownSampler(JumpLinkBuilderConfig acfg, JumpEdge edge) { EdgeSampler es = new EdgeSampler(edge, new ClimbTrajectory()); es.start.height = acfg.agentClimb * 2; diff --git a/src/DotRecast.Detour.Extras/Jumplink/Edge.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs similarity index 86% rename from src/DotRecast.Detour.Extras/Jumplink/Edge.cs rename to src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs index 8a7313a..6c2a9bb 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/Edge.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs @@ -2,7 +2,7 @@ using DotRecast.Core; namespace DotRecast.Detour.Extras.Jumplink { - public class Edge + public class JumpEdge { public Vector3f sp = new Vector3f(); public Vector3f sq = new Vector3f(); diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs index 0912529..a97355a 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs @@ -15,7 +15,7 @@ namespace DotRecast.Detour.Extras.Jumplink private readonly TrajectorySampler trajectorySampler = new TrajectorySampler(); private readonly JumpSegmentBuilder jumpSegmentBuilder = new JumpSegmentBuilder(); - private readonly List edges; + private readonly List edges; private readonly IList results; public JumpLinkBuilder(IList results) @@ -29,8 +29,8 @@ namespace DotRecast.Detour.Extras.Jumplink List links = new List(); for (int tile = 0; tile < results.Count; tile++) { - Edge[] edges = this.edges[tile]; - foreach (Edge edge in edges) + JumpEdge[] edges = this.edges[tile]; + foreach (JumpEdge edge in edges) { links.AddRange(ProcessEdge(acfg, results[tile], type, edge)); } @@ -39,7 +39,7 @@ namespace DotRecast.Detour.Extras.Jumplink return links; } - private List ProcessEdge(JumpLinkBuilderConfig acfg, RecastBuilderResult result, JumpLinkType type, Edge edge) + private List ProcessEdge(JumpLinkBuilderConfig acfg, RecastBuilderResult result, JumpLinkType type, JumpEdge edge) { EdgeSampler es = edgeSamplerFactory.Get(acfg, type, edge); groundSampler.Sample(acfg, result, es); @@ -88,7 +88,7 @@ namespace DotRecast.Detour.Extras.Jumplink return links; } - public List GetEdges() + public List GetEdges() { return edges; } diff --git a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs index 16f07cb..28e9c90 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs @@ -73,14 +73,7 @@ namespace DotRecast.Detour.TileCache verts.Clear(); } }; - - public class Edge - { - public int[] vert = new int[2]; - public int[] polyEdge = new int[2]; - public int[] poly = new int[2]; - }; - + private readonly TileCacheLayerHeaderReader reader = new TileCacheLayerHeaderReader(); public void BuildTileCacheRegions(TileCacheLayer layer, int walkableClimb) diff --git a/src/DotRecast.Detour/BVItem.cs b/src/DotRecast.Detour/BVItem.cs new file mode 100644 index 0000000..bcc2964 --- /dev/null +++ b/src/DotRecast.Detour/BVItem.cs @@ -0,0 +1,9 @@ +namespace DotRecast.Detour +{ + public class BVItem + { + public readonly int[] bmin = new int[3]; + public readonly int[] bmax = new int[3]; + public int i; + }; +} \ No newline at end of file diff --git a/src/DotRecast.Detour/NavMeshBuilder.cs b/src/DotRecast.Detour/NavMeshBuilder.cs index 1f8b8ad..e632526 100644 --- a/src/DotRecast.Detour/NavMeshBuilder.cs +++ b/src/DotRecast.Detour/NavMeshBuilder.cs @@ -30,13 +30,6 @@ namespace DotRecast.Detour { const int MESH_NULL_IDX = 0xffff; - public class BVItem - { - public readonly int[] bmin = new int[3]; - public readonly int[] bmax = new int[3]; - public int i; - }; - private class CompareItemX : IComparer { public int Compare(BVItem a, BVItem b) @@ -674,4 +667,4 @@ namespace DotRecast.Detour return nmd; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/AgentTrail.cs b/src/DotRecast.Recast.Demo/Tools/AgentTrail.cs new file mode 100644 index 0000000..57586dc --- /dev/null +++ b/src/DotRecast.Recast.Demo/Tools/AgentTrail.cs @@ -0,0 +1,7 @@ +namespace DotRecast.Recast.Demo.Tools; + +public class AgentTrail +{ + public float[] trail = new float[CrowdTool.AGENT_MAX_TRAIL * 3]; + public int htrail; +}; \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index b0aa74e..0ff80be 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -71,14 +71,7 @@ public class CrowdTool : Tool private readonly CrowdProfilingTool profilingTool; private readonly CrowdAgentDebugInfo m_agentDebug = new CrowdAgentDebugInfo(); - private static readonly int AGENT_MAX_TRAIL = 64; - - private class AgentTrail - { - public float[] trail = new float[AGENT_MAX_TRAIL * 3]; - public int htrail; - }; - + public static readonly int AGENT_MAX_TRAIL = 64; private readonly Dictionary m_trails = new(); private Vector3f m_targetPos; private long m_targetRef; diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs index 7d686a8..2b1046e 100644 --- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs @@ -60,7 +60,7 @@ public class JumpLinkBuilderTool : Tool { if (annotationBuilder != null) { - foreach (Edge[] edges in annotationBuilder.GetEdges()) + foreach (JumpEdge[] edges in annotationBuilder.GetEdges()) { dd.Begin(LINES, 3.0f); for (int i = 0; i < edges.Length; ++i) diff --git a/src/DotRecast.Recast/HeightPatch.cs b/src/DotRecast.Recast/HeightPatch.cs new file mode 100644 index 0000000..8360200 --- /dev/null +++ b/src/DotRecast.Recast/HeightPatch.cs @@ -0,0 +1,11 @@ +namespace DotRecast.Recast +{ + public class HeightPatch + { + public int xmin; + public int ymin; + public int width; + public int height; + public int[] data; + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/LayerRegion.cs b/src/DotRecast.Recast/LayerRegion.cs new file mode 100644 index 0000000..a6bb3c8 --- /dev/null +++ b/src/DotRecast.Recast/LayerRegion.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace DotRecast.Recast +{ + public class LayerRegion + { + public int id; + public int layerId; + public bool @base; + public int ymin, ymax; + public List layers; + public List neis; + + public LayerRegion(int i) + { + id = i; + ymin = 0xFFFF; + layerId = 0xff; + layers = new List(); + neis = new List(); + } + }; +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastLayers.cs b/src/DotRecast.Recast/RecastLayers.cs index ca1dcd5..b8abb4e 100644 --- a/src/DotRecast.Recast/RecastLayers.cs +++ b/src/DotRecast.Recast/RecastLayers.cs @@ -34,24 +34,6 @@ namespace DotRecast.Recast const int RC_MAX_LAYERS = RecastConstants.RC_NOT_CONNECTED; const int RC_MAX_NEIS = 16; - private class LayerRegion - { - public int id; - public int layerId; - public bool @base; - public int ymin, ymax; - public List layers; - public List neis; - - public LayerRegion(int i) - { - id = i; - ymin = 0xFFFF; - layerId = 0xff; - layers = new List(); - neis = new List(); - } - }; private static void AddUnique(List a, int v) { @@ -564,4 +546,4 @@ namespace DotRecast.Recast return lset; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastMesh.cs b/src/DotRecast.Recast/RecastMesh.cs index 41e7d6d..01c7290 100644 --- a/src/DotRecast.Recast/RecastMesh.cs +++ b/src/DotRecast.Recast/RecastMesh.cs @@ -19,6 +19,7 @@ freely, subject to the following restrictions: */ using System; +using DotRecast.Core; namespace DotRecast.Recast { @@ -29,12 +30,6 @@ namespace DotRecast.Recast public const int MAX_MESH_VERTS_POLY = 0xffff; public const int VERTEX_BUCKET_COUNT = (1 << 12); - private class Edge - { - public int[] vert = new int[2]; - public int[] polyEdge = new int[2]; - public int[] poly = new int[2]; - } private static void BuildMeshAdjacency(int[] polys, int npolys, int nverts, int vertsPerPoly) { @@ -1381,4 +1376,4 @@ namespace DotRecast.Recast return dst; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs index 284b78c..2ffb4a5 100644 --- a/src/DotRecast.Recast/RecastMeshDetail.cs +++ b/src/DotRecast.Recast/RecastMeshDetail.cs @@ -37,14 +37,6 @@ namespace DotRecast.Recast public const int EV_UNDEF = -1; public const int EV_HULL = -2; - private class HeightPatch - { - public int xmin; - public int ymin; - public int width; - public int height; - public int[] data; - } private static float Vdot2(float[] a, float[] b) { @@ -1692,4 +1684,4 @@ namespace DotRecast.Recast return mesh; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastRegion.cs b/src/DotRecast.Recast/RecastRegion.cs index 1afa612..2e6adbc 100644 --- a/src/DotRecast.Recast/RecastRegion.cs +++ b/src/DotRecast.Recast/RecastRegion.cs @@ -30,13 +30,6 @@ namespace DotRecast.Recast { const int RC_NULL_NEI = 0xffff; - public class SweepSpan - { - public int rid; // row id - public int id; // region id - public int ns; // number samples - public int nei; // neighbour id - } public static int CalculateDistanceField(CompactHeightfield chf, int[] src) { diff --git a/src/DotRecast.Recast/SweepSpan.cs b/src/DotRecast.Recast/SweepSpan.cs new file mode 100644 index 0000000..6d63ab5 --- /dev/null +++ b/src/DotRecast.Recast/SweepSpan.cs @@ -0,0 +1,10 @@ +namespace DotRecast.Recast +{ + public class SweepSpan + { + public int rid; // row id + public int id; // region id + public int ns; // number samples + public int nei; // neighbour id + } +} \ No newline at end of file