fix netstandard21

This commit is contained in:
ikpil 2023-03-17 01:09:10 +09:00
parent be1a4915ec
commit 5d0c5db2e7
222 changed files with 1203 additions and 390 deletions

View File

@ -1,3 +1,14 @@
# DotRecast # DotRecast
- https://github.com/recastnavigation/recastnavigation DotRecast is a port of recast4j(https://github.com/ppiastucki/recast4j) to C# and has been built to target netstandard2.1 to work with both Unity and pure C#.
- https://github.com/ppiastucki/recast4j
If you're using Unity 3D, the following projects have been modified to build with netstandard2.1:
- DotRecast.Core
- DotRecast.Recast
- DotRecast.Detour
- DotRecast.Detour.Crowd
- DotRecast.Detour.Dynamic
- DotRecast.Detour.Extras
- DotRecast.Detour.TileCache
Please feel free to copy and use these projects in Unity 3D. We plan to continue improving them as time goes on.

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Core; namespace DotRecast.Core
{
public static class ArrayUtils public static class ArrayUtils
{ {
@ -38,4 +40,5 @@ public static class ArrayUtils
return temp; return temp;
} }
}
} }

View File

@ -1,6 +1,8 @@
using System.Threading; using System.Threading;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class AtomicBoolean public class AtomicBoolean
{ {
@ -15,4 +17,5 @@ public class AtomicBoolean
{ {
return 0 != _location; return 0 != _location;
} }
}
} }

View File

@ -1,6 +1,8 @@
using System.Threading; using System.Threading;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class AtomicFloat public class AtomicFloat
{ {
@ -25,4 +27,5 @@ public class AtomicFloat
{ {
return Interlocked.CompareExchange(ref _location, value, comparand); return Interlocked.CompareExchange(ref _location, value, comparand);
} }
}
} }

View File

@ -1,6 +1,8 @@
using System.Threading; using System.Threading;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class AtomicInteger public class AtomicInteger
{ {
@ -63,4 +65,5 @@ public class AtomicInteger
return Interlocked.Add(ref _location, value); return Interlocked.Add(ref _location, value);
} }
}
} }

View File

@ -1,6 +1,8 @@
using System.Threading; using System.Threading;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class AtomicLong public class AtomicLong
{ {
@ -49,4 +51,5 @@ public class AtomicLong
{ {
return Interlocked.Add(ref _location, value); return Interlocked.Add(ref _location, value);
} }
}
} }

View File

@ -1,7 +1,9 @@
using System; using System;
using System.Buffers.Binary; using System.Buffers.Binary;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class ByteBuffer public class ByteBuffer
{ {
@ -93,14 +95,16 @@ public class ByteBuffer
public float getFloat() public float getFloat()
{ {
var span = ReadBytes(4); var span = ReadBytes(4);
if (_order == ByteOrder.BIG_ENDIAN) if (_order == ByteOrder.BIG_ENDIAN && BitConverter.IsLittleEndian)
{ {
return BinaryPrimitives.ReadSingleBigEndian(span); span.Reverse();
} }
else else if (_order == ByteOrder.LITTLE_ENDIAN && !BitConverter.IsLittleEndian)
{ {
return BinaryPrimitives.ReadSingleLittleEndian(span); span.Reverse();
} }
return BitConverter.ToSingle(span);
} }
public long getLong() public long getLong()
@ -125,4 +129,5 @@ public class ByteBuffer
{ {
// ? // ?
} }
}
} }

View File

@ -1,8 +1,12 @@
namespace DotRecast.Core; namespace DotRecast.Core
{
public enum ByteOrder public enum ByteOrder
{ {
/// <summary>Default on most Windows systems</summary> /// <summary>Default on most Windows systems</summary>
LITTLE_ENDIAN, LITTLE_ENDIAN,
BIG_ENDIAN, BIG_ENDIAN,
}
} }

View File

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Core; namespace DotRecast.Core
{
public static class CollectionExtensions public static class CollectionExtensions
{ {
@ -26,4 +28,5 @@ public static class CollectionExtensions
list[n] = value; list[n] = value;
} }
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Core; namespace DotRecast.Core
{
public static class ConvexUtils { public static class ConvexUtils {
@ -27,7 +29,7 @@ public static class ConvexUtils {
// returns number of points on hull. // returns number of points on hull.
public static List<int> convexhull(List<float> pts) { public static List<int> convexhull(List<float> pts) {
int npts = pts.Count / 3; int npts = pts.Count / 3;
List<int> @out = new(); List<int> @out = new List<int>();
// Find lower-leftmost point. // Find lower-leftmost point.
int hull = 0; int hull = 0;
for (int i = 1; i < npts; ++i) { for (int i = 1; i < npts; ++i) {
@ -83,3 +85,5 @@ public static class ConvexUtils {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Core; namespace DotRecast.Core
{
public class DemoMath { public class DemoMath {
public static float vDistSqr(float[] v1, float[] v2, int i) { public static float vDistSqr(float[] v1, float[] v2, int i) {
@ -77,3 +79,5 @@ public class DemoMath {
return u * g + (1f - u) * f; return u * g + (1f - u) * f;
} }
} }
}

View File

@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>
</Project> </Project>

View File

@ -1,6 +1,8 @@
using System.IO; using System.IO;
namespace DotRecast.Core; namespace DotRecast.Core
{
public static class Loader public static class Loader
{ {
@ -29,4 +31,5 @@ public static class Loader
return filename; return filename;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Core; namespace DotRecast.Core
{
using System.Collections.Generic; using System.Collections.Generic;
@ -32,7 +34,7 @@ public class OrderedQueue<T>
public OrderedQueue(Comparison<T> comparison) public OrderedQueue(Comparison<T> comparison)
{ {
_items = new(); _items = new List<T>();
_comparison = comparison; _comparison = comparison;
} }
@ -71,3 +73,5 @@ public class OrderedQueue<T>
return 0 == _items.Count; return 0 == _items.Count;
} }
} }
}

View File

@ -25,7 +25,9 @@ using System.Collections.ObjectModel;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Crowd.Tracking; using DotRecast.Detour.Crowd.Tracking;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
@ -177,7 +179,7 @@ public class Crowd {
// Allocate temp buffer for merging paths. // Allocate temp buffer for merging paths.
m_pathq = new PathQueue(config); m_pathq = new PathQueue(config);
m_agents = new(); m_agents = new HashSet<CrowdAgent>();
// The navQuery is mostly used for local searches, no need for large node pool. // The navQuery is mostly used for local searches, no need for large node pool.
navMesh = nav; navMesh = nav;
@ -334,7 +336,7 @@ public class Crowd {
* @return List of active agents * @return List of active agents
*/ */
public List<CrowdAgent> getActiveAgents() { public List<CrowdAgent> getActiveAgents() {
return new(m_agents); return new List<CrowdAgent>(m_agents);
} }
public float[] getQueryExtents() { public float[] getQueryExtents() {
@ -516,7 +518,7 @@ public class Crowd {
private void updateMoveRequest(ICollection<CrowdAgent> agents, float dt) { private void updateMoveRequest(ICollection<CrowdAgent> agents, float dt) {
_telemetry.start("updateMoveRequest"); _telemetry.start("updateMoveRequest");
OrderedQueue<CrowdAgent> queue = new((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime)); OrderedQueue<CrowdAgent> queue = new OrderedQueue<CrowdAgent>((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime));
// Fire off new requests. // Fire off new requests.
foreach (CrowdAgent ag in agents) { foreach (CrowdAgent ag in agents) {
@ -559,7 +561,7 @@ public class Crowd {
if (cr.succeeded()) { if (cr.succeeded()) {
reqPos = cr.result.getClosest(); reqPos = cr.result.getClosest();
} else { } else {
reqPath = new(); reqPath = new List<long>();
} }
} else { } else {
vCopy(reqPos, ag.targetPos); vCopy(reqPos, ag.targetPos);
@ -568,7 +570,7 @@ public class Crowd {
// Could not find path, start the request from current // Could not find path, start the request from current
// location. // location.
vCopy(reqPos, ag.npos); vCopy(reqPos, ag.npos);
reqPath = new(); reqPath = new List<long>();
reqPath.Add(path[0]); reqPath.Add(path[0]);
} }
@ -717,7 +719,7 @@ public class Crowd {
private void updateTopologyOptimization(ICollection<CrowdAgent> agents, float dt) { private void updateTopologyOptimization(ICollection<CrowdAgent> agents, float dt) {
_telemetry.start("updateTopologyOptimization"); _telemetry.start("updateTopologyOptimization");
OrderedQueue<CrowdAgent> queue = new((a1, a2) => a2.topologyOptTime.CompareTo(a1.topologyOptTime)); OrderedQueue<CrowdAgent> queue = new OrderedQueue<CrowdAgent>((a1, a2) => a2.topologyOptTime.CompareTo(a1.topologyOptTime));
foreach (CrowdAgent ag in agents) { foreach (CrowdAgent ag in agents) {
if (ag.state != CrowdAgent.CrowdAgentState.DT_CROWDAGENT_STATE_WALKING) { if (ag.state != CrowdAgent.CrowdAgentState.DT_CROWDAGENT_STATE_WALKING) {
@ -779,7 +781,7 @@ public class Crowd {
private List<CrowdNeighbour> getNeighbours(float[] pos, float height, float range, CrowdAgent skip, ProximityGrid grid) { private List<CrowdNeighbour> getNeighbours(float[] pos, float height, float range, CrowdAgent skip, ProximityGrid grid) {
List<CrowdNeighbour> result = new(); List<CrowdNeighbour> result = new List<CrowdNeighbour>();
HashSet<CrowdAgent> proxAgents = grid.queryItems(pos[0] - range, pos[2] - range, pos[0] + range, pos[2] + range); HashSet<CrowdAgent> proxAgents = grid.queryItems(pos[0] - range, pos[2] - range, pos[0] + range, pos[2] + range);
foreach (CrowdAgent ag in proxAgents) { foreach (CrowdAgent ag in proxAgents) {
@ -1170,3 +1172,5 @@ public class Crowd {
}; };
} }
}

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
@ -60,7 +62,7 @@ public class CrowdAgent {
/// Time since the agent's path corridor was optimized. /// Time since the agent's path corridor was optimized.
public float topologyOptTime; public float topologyOptTime;
/// The known neighbors of the agent. /// The known neighbors of the agent.
public List<Crowd.CrowdNeighbour> neis = new(); public List<Crowd.CrowdNeighbour> neis = new List<Crowd.CrowdNeighbour>();
/// The desired speed. /// The desired speed.
public float desiredSpeed; public float desiredSpeed;
@ -78,7 +80,7 @@ public class CrowdAgent {
/// The agent's configuration parameters. /// The agent's configuration parameters.
public CrowdAgentParams option; public CrowdAgentParams option;
/// The local path corridor corners for the agent. /// The local path corridor corners for the agent.
public List<StraightPathItem> corners = new(); public List<StraightPathItem> corners = new List<StraightPathItem>();
public MoveRequestState targetState; /// < State of the movement request. public MoveRequestState targetState; /// < State of the movement request.
public long targetRef; /// < Target polyref of the movement request. public long targetRef; /// < Target polyref of the movement request.
@ -189,4 +191,5 @@ public class CrowdAgent {
} }
} }
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class CrowdAgentAnimation { public class CrowdAgentAnimation {
public bool active; public bool active;
@ -28,3 +30,5 @@ public class CrowdAgentAnimation {
public float t, tmax; public float t, tmax;
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
/// Configuration parameters for a crowd agent. /// Configuration parameters for a crowd agent.
/// @ingroup crowd /// @ingroup crowd
@ -59,4 +61,5 @@ public class CrowdAgentParams {
/// User defined data attached to the agent. /// User defined data attached to the agent.
public object userData; public object userData;
}
} }

View File

@ -16,7 +16,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class CrowdConfig { public class CrowdConfig {
@ -64,3 +66,5 @@ public class CrowdConfig {
} }
} }
}

View File

@ -21,7 +21,9 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class CrowdTelemetry { public class CrowdTelemetry {
@ -29,8 +31,8 @@ public class CrowdTelemetry {
public const int TIMING_SAMPLES = 10; public const int TIMING_SAMPLES = 10;
private float _maxTimeToEnqueueRequest; private float _maxTimeToEnqueueRequest;
private float _maxTimeToFindPath; private float _maxTimeToFindPath;
private readonly Dictionary<string, long> _executionTimings = new(); private readonly Dictionary<string, long> _executionTimings = new Dictionary<string, long>();
private readonly Dictionary<string, List<long>> _executionTimingSamples = new(); private readonly Dictionary<string, List<long>> _executionTimingSamples = new Dictionary<string, List<long>>();
public float maxTimeToEnqueueRequest() { public float maxTimeToEnqueueRequest() {
return _maxTimeToEnqueueRequest; return _maxTimeToEnqueueRequest;
@ -66,7 +68,7 @@ public class CrowdTelemetry {
long duration = Stopwatch.GetTimestamp() - _executionTimings[name]; long duration = Stopwatch.GetTimestamp() - _executionTimings[name];
if (!_executionTimingSamples.TryGetValue(name, out var s)) if (!_executionTimingSamples.TryGetValue(name, out var s))
{ {
s = new(); s = new List<long>();
_executionTimingSamples.Add(name, s); _executionTimingSamples.Add(name, s);
} }
@ -77,3 +79,5 @@ public class CrowdTelemetry {
_executionTimings[name] = (long) s.Average(); _executionTimings[name] = (long) s.Average();
} }
} }
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
@ -37,8 +39,8 @@ public class LocalBoundary {
} }
float[] m_center = new float[3]; float[] m_center = new float[3];
List<Segment> m_segs = new(); List<Segment> m_segs = new List<Segment>();
List<long> m_polys = new(); List<long> m_polys = new List<long>();
public LocalBoundary() { public LocalBoundary() {
m_center[0] = m_center[1] = m_center[2] = float.MaxValue; m_center[0] = m_center[1] = m_center[2] = float.MaxValue;
@ -135,3 +137,5 @@ public class LocalBoundary {
return m_segs.Count; return m_segs.Count;
} }
} }
}

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Detour.Crowd.Tracking; using DotRecast.Detour.Crowd.Tracking;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
@ -507,3 +509,5 @@ public class ObstacleAvoidanceQuery {
return Tuple.Create(ns, nvel); return Tuple.Create(ns, nvel);
} }
} }
}

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
@ -95,7 +97,7 @@ public class PathCorridor {
// Concatenate paths. // Concatenate paths.
// Adjust beginning of the buffer to include the visited. // Adjust beginning of the buffer to include the visited.
List<long> result = new(); List<long> result = new List<long>();
// Store visited // Store visited
for (int i = visited.Count - 1; i > furthestVisited; --i) { for (int i = visited.Count - 1; i > furthestVisited; --i) {
result.Add(visited[i]); result.Add(visited[i]);
@ -171,7 +173,7 @@ public class PathCorridor {
* Allocates the corridor's path buffer. * Allocates the corridor's path buffer.
*/ */
public PathCorridor() { public PathCorridor() {
m_path = new(); m_path = new List<long>();
} }
/** /**
@ -209,7 +211,7 @@ public class PathCorridor {
* @return Corners * @return Corners
*/ */
public List<StraightPathItem> findCorners(int maxCorners, NavMeshQuery navquery, QueryFilter filter) { public List<StraightPathItem> findCorners(int maxCorners, NavMeshQuery navquery, QueryFilter filter) {
List<StraightPathItem> path = new(); List<StraightPathItem> path = new List<StraightPathItem>();
Result<List<StraightPathItem>> result = navquery.findStraightPath(m_pos, m_target, m_path, maxCorners, 0); Result<List<StraightPathItem>> result = navquery.findStraightPath(m_pos, m_target, m_path, maxCorners, 0);
if (result.succeeded()) { if (result.succeeded()) {
path = result.result; path = result.result;
@ -441,7 +443,7 @@ public class PathCorridor {
public void setCorridor(float[] target, List<long> path) { public void setCorridor(float[] target, List<long> path) {
vCopy(m_target, target); vCopy(m_target, target);
m_path = new(path); m_path = new List<long>(path);
} }
public void fixPathStart(long safeRef, float[] safePos) { public void fixPathStart(long safeRef, float[] safePos) {
@ -560,3 +562,5 @@ public class PathCorridor {
return m_path.Count; return m_path.Count;
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class PathQuery { public class PathQuery {
/// Path find start and end location. /// Path find start and end location.
@ -30,3 +32,5 @@ public class PathQuery {
public NavMeshQuery navQuery; public NavMeshQuery navQuery;
} }
}

View File

@ -18,9 +18,13 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class PathQueryResult { public class PathQueryResult {
public Status status; public Status status;
public List<long> path = new(); public List<long> path = new List<long>();
} }
}

View File

@ -20,14 +20,16 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
using static DetourCommon; using static DetourCommon;
public class PathQueue { public class PathQueue {
private readonly CrowdConfig config; private readonly CrowdConfig config;
private readonly LinkedList<PathQuery> queue = new(); private readonly LinkedList<PathQuery> queue = new LinkedList<PathQuery>();
public PathQueue(CrowdConfig config) { public PathQueue(CrowdConfig config) {
this.config = config; this.config = config;
@ -81,3 +83,5 @@ public class PathQueue {
} }
} }
}

View File

@ -22,7 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class ProximityGrid { public class ProximityGrid {
@ -33,7 +35,7 @@ public class ProximityGrid {
public ProximityGrid(float m_cellSize) { public ProximityGrid(float m_cellSize) {
this.m_cellSize = m_cellSize; this.m_cellSize = m_cellSize;
m_invCellSize = 1.0f / m_cellSize; m_invCellSize = 1.0f / m_cellSize;
items = new(); items = new Dictionary<ItemKey, List<CrowdAgent>>();
} }
void clear() { void clear() {
@ -50,7 +52,7 @@ public class ProximityGrid {
for (int x = iminx; x <= imaxx; ++x) { for (int x = iminx; x <= imaxx; ++x) {
ItemKey key = new ItemKey(x, y); ItemKey key = new ItemKey(x, y);
if (!items.TryGetValue(key, out var ids)) { if (!items.TryGetValue(key, out var ids)) {
ids = new(); ids = new List<CrowdAgent>();
items.Add(key, ids); items.Add(key, ids);
} }
ids.Add(agent); ids.Add(agent);
@ -64,7 +66,7 @@ public class ProximityGrid {
int imaxx = (int) Math.Floor(maxx * m_invCellSize); int imaxx = (int) Math.Floor(maxx * m_invCellSize);
int imaxy = (int) Math.Floor(maxy * m_invCellSize); int imaxy = (int) Math.Floor(maxy * m_invCellSize);
HashSet<CrowdAgent> result = new(); HashSet<CrowdAgent> result = new HashSet<CrowdAgent>();
for (int y = iminy; y <= imaxy; ++y) { for (int y = iminy; y <= imaxy; ++y) {
for (int x = iminx; x <= imaxx; ++x) { for (int x = iminx; x <= imaxx; ++x) {
ItemKey key = new ItemKey(x, y); ItemKey key = new ItemKey(x, y);
@ -128,3 +130,5 @@ public class ProximityGrid {
}; };
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Crowd; namespace DotRecast.Detour.Crowd
{
public class SweepCircleCircleResult { public class SweepCircleCircleResult {
@ -32,3 +34,5 @@ public class SweepCircleCircleResult {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Crowd.Tracking; namespace DotRecast.Detour.Crowd.Tracking
{
public class CrowdAgentDebugInfo { public class CrowdAgentDebugInfo {
@ -27,3 +29,5 @@ public class CrowdAgentDebugInfo {
public ObstacleAvoidanceDebugData vod; public ObstacleAvoidanceDebugData vod;
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour.Crowd.Tracking; namespace DotRecast.Detour.Crowd.Tracking
{
using static DetourCommon; using static DetourCommon;
@ -122,4 +124,5 @@ public class ObstacleAvoidanceDebugData {
public float getSampleCollisionTimePenalty(int i) { public float getSampleCollisionTimePenalty(int i) {
return m_tpen[i]; return m_tpen[i];
} }
}
} }

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
using DotRecast.Detour.Dynamic.Colliders; using DotRecast.Detour.Dynamic.Colliders;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class AddColliderQueueItem : UpdateQueueItem { public class AddColliderQueueItem : UpdateQueueItem {
@ -42,3 +44,5 @@ public class AddColliderQueueItem : UpdateQueueItem {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public abstract class AbstractCollider : Collider { public abstract class AbstractCollider : Collider {
@ -42,3 +44,5 @@ public abstract class AbstractCollider : Collider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class BoxCollider : AbstractCollider { public class BoxCollider : AbstractCollider {
@ -77,3 +79,5 @@ public class BoxCollider : AbstractCollider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class CapsuleCollider : AbstractCollider { public class CapsuleCollider : AbstractCollider {
@ -47,3 +49,5 @@ public class CapsuleCollider : AbstractCollider {
} }
} }
}

View File

@ -18,10 +18,14 @@ freely, subject to the following restrictions:
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public interface Collider { public interface Collider {
float[] bounds(); float[] bounds();
void rasterize(Heightfield hf, Telemetry telemetry); void rasterize(Heightfield hf, Telemetry telemetry);
} }
}

View File

@ -21,7 +21,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class CompositeCollider : Collider { public class CompositeCollider : Collider {
@ -63,3 +65,5 @@ public class CompositeCollider : Collider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class ConvexTrimeshCollider : AbstractCollider { public class ConvexTrimeshCollider : AbstractCollider {
@ -44,3 +46,5 @@ public class ConvexTrimeshCollider : AbstractCollider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class CylinderCollider : AbstractCollider { public class CylinderCollider : AbstractCollider {
@ -46,3 +48,5 @@ public class CylinderCollider : AbstractCollider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class SphereCollider : AbstractCollider { public class SphereCollider : AbstractCollider {
@ -43,3 +45,5 @@ public class SphereCollider : AbstractCollider {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders; namespace DotRecast.Detour.Dynamic.Colliders
{
public class TrimeshCollider : AbstractCollider { public class TrimeshCollider : AbstractCollider {
@ -59,3 +61,5 @@ public class TrimeshCollider : AbstractCollider {
} }
} }
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>

View File

@ -27,17 +27,19 @@ using DotRecast.Detour.Dynamic.Colliders;
using DotRecast.Detour.Dynamic.Io; using DotRecast.Detour.Dynamic.Io;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class DynamicNavMesh { public class DynamicNavMesh {
public const int MAX_VERTS_PER_POLY = 6; public const int MAX_VERTS_PER_POLY = 6;
public readonly DynamicNavMeshConfig config; public readonly DynamicNavMeshConfig config;
private readonly RecastBuilder builder; private readonly RecastBuilder builder;
private readonly Dictionary<long, DynamicTile> _tiles = new(); private readonly Dictionary<long, DynamicTile> _tiles = new Dictionary<long, DynamicTile>();
private readonly Telemetry telemetry; private readonly Telemetry telemetry;
private readonly NavMeshParams navMeshParams; private readonly NavMeshParams navMeshParams;
private readonly BlockingCollection<UpdateQueueItem> updateQueue = new(); private readonly BlockingCollection<UpdateQueueItem> updateQueue = new BlockingCollection<UpdateQueueItem>();
private readonly AtomicLong currentColliderId = new AtomicLong(0); private readonly AtomicLong currentColliderId = new AtomicLong(0);
private NavMesh _navMesh; private NavMesh _navMesh;
private bool dirty = true; private bool dirty = true;
@ -127,7 +129,7 @@ public class DynamicNavMesh {
} }
private List<UpdateQueueItem> consumeQueue() { private List<UpdateQueueItem> consumeQueue() {
List<UpdateQueueItem> items = new(); List<UpdateQueueItem> items = new List<UpdateQueueItem>();
while (updateQueue.TryTake(out var item)) { while (updateQueue.TryTake(out var item)) {
items.Add(item); items.Add(item);
} }
@ -170,7 +172,7 @@ public class DynamicNavMesh {
int minz = (int) Math.Floor((bounds[2] - navMeshParams.orig[2]) / navMeshParams.tileHeight); int minz = (int) Math.Floor((bounds[2] - navMeshParams.orig[2]) / navMeshParams.tileHeight);
int maxx = (int) Math.Floor((bounds[3] - navMeshParams.orig[0]) / navMeshParams.tileWidth); int maxx = (int) Math.Floor((bounds[3] - navMeshParams.orig[0]) / navMeshParams.tileWidth);
int maxz = (int) Math.Floor((bounds[5] - navMeshParams.orig[2]) / navMeshParams.tileHeight); int maxz = (int) Math.Floor((bounds[5] - navMeshParams.orig[2]) / navMeshParams.tileHeight);
List<DynamicTile> tiles = new(); List<DynamicTile> tiles = new List<DynamicTile>();
for (int z = minz; z <= maxz; ++z) { for (int z = minz; z <= maxz; ++z) {
for (int x = minx; x <= maxx; ++x) { for (int x = minx; x <= maxx; ++x) {
DynamicTile tile = getTileAt(x, z); DynamicTile tile = getTileAt(x, z);
@ -224,3 +226,5 @@ public class DynamicNavMesh {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class DynamicNavMeshConfig { public class DynamicNavMeshConfig {
@ -54,3 +56,5 @@ public class DynamicNavMeshConfig {
} }
} }
}

View File

@ -20,13 +20,14 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using DotRecast.Detour.Dynamic.Colliders; using DotRecast.Detour.Dynamic.Colliders;
using DotRecast.Detour.Dynamic.Io; using DotRecast.Detour.Dynamic.Io;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class DynamicTile { public class DynamicTile {
@ -34,7 +35,7 @@ public class DynamicTile {
public DynamicTileCheckpoint checkpoint; public DynamicTileCheckpoint checkpoint;
public RecastBuilderResult recastResult; public RecastBuilderResult recastResult;
MeshData meshData; MeshData meshData;
private readonly ConcurrentDictionary<long, Collider> colliders = new(); private readonly ConcurrentDictionary<long, Collider> colliders = new ConcurrentDictionary<long, Collider>();
private bool dirty = true; private bool dirty = true;
private long id; private long id;
@ -55,7 +56,7 @@ public class DynamicTile {
} }
private Heightfield buildHeightfield(DynamicNavMeshConfig config, Telemetry telemetry) { private Heightfield buildHeightfield(DynamicNavMeshConfig config, Telemetry telemetry) {
ICollection<long> rasterizedColliders = checkpoint != null ? checkpoint.colliders : ImmutableArray<long>.Empty; ICollection<long> rasterizedColliders = checkpoint != null ? checkpoint.colliders : ImmutableHashSet<long>.Empty;
Heightfield heightfield = checkpoint != null ? checkpoint.heightfield : voxelTile.heightfield(); Heightfield heightfield = checkpoint != null ? checkpoint.heightfield : voxelTile.heightfield();
foreach (var (cid, c) in colliders) { foreach (var (cid, c) in colliders) {
if (!rasterizedColliders.Contains(cid)) { if (!rasterizedColliders.Contains(cid)) {
@ -152,3 +153,5 @@ public class DynamicTile {
} }
} }
} }
}

View File

@ -21,7 +21,9 @@ using DotRecast.Recast;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class DynamicTileCheckpoint { public class DynamicTileCheckpoint {
@ -59,3 +61,5 @@ public class DynamicTileCheckpoint {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public static class ByteUtils { public static class ByteUtils {
@ -50,28 +52,30 @@ public static class ByteUtils {
public static int putInt(int value, byte[] data, int position, ByteOrder order) { public static int putInt(int value, byte[] data, int position, ByteOrder order) {
if (order == ByteOrder.BIG_ENDIAN) { if (order == ByteOrder.BIG_ENDIAN) {
data[position] = (byte) (value >>> 24); data[position] = (byte) ((uint)value >> 24);
data[position + 1] = (byte) (value >>> 16); data[position + 1] = (byte) ((uint)value >> 16);
data[position + 2] = (byte) (value >>> 8); data[position + 2] = (byte) ((uint)value >> 8);
data[position + 3] = (byte) (value & 0xFF); data[position + 3] = (byte) (value & 0xFF);
} else { } else {
data[position] = (byte) (value & 0xFF); data[position] = (byte) (value & 0xFF);
data[position + 1] = (byte) (value >>> 8); data[position + 1] = (byte) ((uint)value >> 8);
data[position + 2] = (byte) (value >>> 16); data[position + 2] = (byte) ((uint)value >> 16);
data[position + 3] = (byte) (value >>> 24); data[position + 3] = (byte) ((uint)value >> 24);
} }
return position + 4; return position + 4;
} }
public static int putShort(int value, byte[] data, int position, ByteOrder order) { public static int putShort(int value, byte[] data, int position, ByteOrder order) {
if (order == ByteOrder.BIG_ENDIAN) { if (order == ByteOrder.BIG_ENDIAN) {
data[position] = (byte) (value >>> 8); data[position] = (byte) ((uint)value >> 8);
data[position + 1] = (byte) (value & 0xFF); data[position + 1] = (byte) (value & 0xFF);
} else { } else {
data[position] = (byte) (value & 0xFF); data[position] = (byte) (value & 0xFF);
data[position + 1] = (byte) (value >>> 8); data[position + 1] = (byte) ((uint)value >> 8);
} }
return position + 2; return position + 2;
} }
} }
}

View File

@ -20,7 +20,9 @@ using System;
using DotRecast.Core; using DotRecast.Core;
using K4os.Compression.LZ4; using K4os.Compression.LZ4;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public class LZ4VoxelTileCompressor { public class LZ4VoxelTileCompressor {
@ -38,3 +40,5 @@ public class LZ4VoxelTileCompressor {
} }
} }
}

View File

@ -21,7 +21,9 @@ using System.Collections.Generic;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public class VoxelFile { public class VoxelFile {
@ -54,7 +56,7 @@ public class VoxelFile {
public int tileSizeZ; public int tileSizeZ;
public float[] rotation = new float[3]; public float[] rotation = new float[3];
public float[] bounds = new float[6]; public float[] bounds = new float[6];
public readonly List<VoxelTile> tiles = new(); public readonly List<VoxelTile> tiles = new List<VoxelTile>();
public void addTile(VoxelTile tile) { public void addTile(VoxelTile tile) {
tiles.Add(tile); tiles.Add(tile);
@ -146,3 +148,5 @@ public class VoxelFile {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System.IO;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public class VoxelFileReader { public class VoxelFileReader {
@ -123,3 +125,5 @@ public class VoxelFileReader {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System.IO;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public class VoxelFileWriter : DetourWriter { public class VoxelFileWriter : DetourWriter {
@ -87,3 +89,5 @@ public class VoxelFileWriter : DetourWriter {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Io; namespace DotRecast.Detour.Dynamic.Io
{
public class VoxelTile { public class VoxelTile {
@ -179,3 +181,5 @@ public class VoxelTile {
return data; return data;
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public class RemoveColliderQueueItem : UpdateQueueItem { public class RemoveColliderQueueItem : UpdateQueueItem {
@ -39,3 +41,5 @@ public class RemoveColliderQueueItem : UpdateQueueItem {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
public interface UpdateQueueItem { public interface UpdateQueueItem {
@ -27,3 +29,5 @@ public interface UpdateQueueItem {
void process(DynamicTile tile); void process(DynamicTile tile);
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic; namespace DotRecast.Detour.Dynamic
{
/** /**
@ -158,3 +160,5 @@ public class VoxelQuery {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Extras; namespace DotRecast.Detour.Extras
{
public class BVTreeBuilder { public class BVTreeBuilder {
@ -53,3 +55,5 @@ public class BVTreeBuilder {
} }
} }
}

View File

@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -3,7 +3,9 @@ using System;
using DotRecast.Recast; using DotRecast.Recast;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public abstract class AbstractGroundSampler : GroundSampler { public abstract class AbstractGroundSampler : GroundSampler {
@ -46,3 +48,5 @@ public abstract class AbstractGroundSampler : GroundSampler {
} }
} }
}

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class ClimbTrajectory : Trajectory { public class ClimbTrajectory : Trajectory {
@ -11,3 +13,5 @@ public class ClimbTrajectory : Trajectory {
} }
} }
}

View File

@ -1,6 +1,10 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class Edge { public class Edge {
public readonly float[] sp = new float[3]; public readonly float[] sp = new float[3];
public readonly float[] sq = new float[3]; public readonly float[] sq = new float[3];
} }
}

View File

@ -3,11 +3,13 @@ using DotRecast.Recast;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RecastConstants;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class EdgeExtractor { public class EdgeExtractor {
public Edge[] extractEdges(PolyMesh mesh) { public Edge[] extractEdges(PolyMesh mesh) {
List<Edge> edges = new(); List<Edge> edges = new List<Edge>();
if (mesh != null) { if (mesh != null) {
float[] orig = mesh.bmin; float[] orig = mesh.bmin;
float cs = mesh.cs; float cs = mesh.cs;
@ -56,3 +58,5 @@ public class EdgeExtractor {
} }
} }
}

View File

@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class EdgeSampler { public class EdgeSampler {
public readonly GroundSegment start = new GroundSegment(); public readonly GroundSegment start = new GroundSegment();
public readonly List<GroundSegment> end = new(); public readonly List<GroundSegment> end = new List<GroundSegment>();
public readonly Trajectory trajectory; public readonly Trajectory trajectory;
public readonly float[] ax = new float[3]; public readonly float[] ax = new float[3];
@ -23,3 +25,5 @@ public class EdgeSampler {
} }
} }
}

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
class EdgeSamplerFactory { class EdgeSamplerFactory {
@ -77,3 +79,5 @@ class EdgeSamplerFactory {
} }
} }
}

View File

@ -1,7 +1,11 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class GroundSample { public class GroundSample {
public readonly float[] p = new float[3]; public readonly float[] p = new float[3];
public bool validTrajectory; public bool validTrajectory;
public bool validHeight; public bool validHeight;
} }
}

View File

@ -1,9 +1,13 @@
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public interface GroundSampler { public interface GroundSampler {
void sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es); void sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es);
} }
}

View File

@ -1,4 +1,6 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class GroundSegment { public class GroundSegment {
public readonly float[] p = new float[3]; public readonly float[] p = new float[3];
@ -7,3 +9,5 @@ public class GroundSegment {
public float height; public float height;
} }
}

View File

@ -1,4 +1,6 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpLink { public class JumpLink {
@ -13,3 +15,5 @@ public class JumpLink {
public Trajectory trajectory; public Trajectory trajectory;
} }
}

View File

@ -5,7 +5,9 @@ using DotRecast.Core;
using DotRecast.Recast; using DotRecast.Recast;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpLinkBuilder { public class JumpLinkBuilder {
@ -24,7 +26,7 @@ public class JumpLinkBuilder {
} }
public List<JumpLink> build(JumpLinkBuilderConfig acfg, JumpLinkType type) { public List<JumpLink> build(JumpLinkBuilderConfig acfg, JumpLinkType type) {
List<JumpLink> links = new(); List<JumpLink> links = new List<JumpLink>();
for (int tile = 0; tile < results.Count; tile++) { for (int tile = 0; tile < results.Count; tile++) {
Edge[] edges = this.edges[tile]; Edge[] edges = this.edges[tile];
foreach (Edge edge in edges) { foreach (Edge edge in edges) {
@ -44,7 +46,7 @@ public class JumpLinkBuilder {
private List<JumpLink> buildJumpLinks(JumpLinkBuilderConfig acfg, EdgeSampler es, JumpSegment[] jumpSegments) { private List<JumpLink> buildJumpLinks(JumpLinkBuilderConfig acfg, EdgeSampler es, JumpSegment[] jumpSegments) {
List<JumpLink> links = new(); List<JumpLink> links = new List<JumpLink>();
foreach (JumpSegment js in jumpSegments) { foreach (JumpSegment js in jumpSegments) {
float[] sp = es.start.gsamples[js.startSample].p; float[] sp = es.start.gsamples[js.startSample].p;
float[] sq = es.start.gsamples[js.startSample + js.samples - 1].p; float[] sq = es.start.gsamples[js.startSample + js.samples - 1].p;
@ -82,3 +84,5 @@ public class JumpLinkBuilder {
} }
} }
}

View File

@ -1,4 +1,6 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpLinkBuilderConfig { public class JumpLinkBuilderConfig {
@ -31,3 +33,5 @@ public class JumpLinkBuilderConfig {
} }
} }
}

View File

@ -1,5 +1,8 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public enum JumpLinkType { public enum JumpLinkType {
EDGE_JUMP, EDGE_CLIMB_DOWN, EDGE_JUMP_OVER EDGE_JUMP, EDGE_CLIMB_DOWN, EDGE_JUMP_OVER
}
} }

View File

@ -1,7 +1,11 @@
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpSegment { public class JumpSegment {
public int groundSegment; public int groundSegment;
public int startSample; public int startSample;
public int samples; public int samples;
} }
}

View File

@ -3,7 +3,9 @@ using System.Collections.Generic;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
class JumpSegmentBuilder { class JumpSegmentBuilder {
@ -93,3 +95,5 @@ class JumpSegmentBuilder {
} }
} }
}

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpTrajectory : Trajectory { public class JumpTrajectory : Trajectory {
@ -39,3 +41,5 @@ public class JumpTrajectory : Trajectory {
} }
} }
}

View File

@ -2,7 +2,9 @@ using System;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Recast; using DotRecast.Recast;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
class NavMeshGroundSampler : AbstractGroundSampler { class NavMeshGroundSampler : AbstractGroundSampler {
@ -89,3 +91,5 @@ class NavMeshGroundSampler : AbstractGroundSampler {
} }
} }
}

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
public class Trajectory { public class Trajectory {
@ -14,3 +16,5 @@ public class Trajectory {
} }
} }
}

View File

@ -2,7 +2,9 @@ using System;
using DotRecast.Recast; using DotRecast.Recast;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.Extras.Jumplink; namespace DotRecast.Detour.Extras.Jumplink
{
class TrajectorySampler { class TrajectorySampler {
@ -74,3 +76,5 @@ class TrajectorySampler {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System.IO; using System.IO;
namespace DotRecast.Detour.Extras; namespace DotRecast.Detour.Extras
{
public class ObjExporter { public class ObjExporter {
@ -62,3 +64,5 @@ public class ObjExporter {
*/ */
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras; namespace DotRecast.Detour.Extras
{
public class PolyUtils { public class PolyUtils {
@ -78,3 +80,5 @@ public class PolyUtils {
return edge; return edge;
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class BVTreeCreator { public class BVTreeCreator {
@ -28,3 +30,5 @@ public class BVTreeCreator {
} }
} }
}

View File

@ -20,12 +20,14 @@ using System.Collections.Generic;
using System.IO.Compression; using System.IO.Compression;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
class GraphConnectionReader : ZipBinaryReader { class GraphConnectionReader : ZipBinaryReader {
public List<int[]> read(ZipArchive file, string filename, Meta meta, int[] indexToNode) { public List<int[]> read(ZipArchive file, string filename, Meta meta, int[] indexToNode) {
List<int[]> connections = new(); List<int[]> connections = new List<int[]>();
ByteBuffer buffer = toByteBuffer(file, filename); ByteBuffer buffer = toByteBuffer(file, filename);
while (buffer.remaining() > 0) { while (buffer.remaining() > 0) {
int count = buffer.getInt(); int count = buffer.getInt();
@ -45,3 +47,5 @@ class GraphConnectionReader : ZipBinaryReader {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
@ -42,3 +44,5 @@ public class GraphData {
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class GraphMeshData { public class GraphMeshData {
@ -60,3 +62,5 @@ public class GraphMeshData {
} }
} }
}

View File

@ -21,7 +21,9 @@ using System.IO.Compression;
using System.Numerics; using System.Numerics;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class GraphMeshDataReader : ZipBinaryReader { public class GraphMeshDataReader : ZipBinaryReader {
@ -137,10 +139,20 @@ public class GraphMeshDataReader : ZipBinaryReader {
return new GraphMeshData(tileXCount, tileZCount, tiles); return new GraphMeshData(tileXCount, tileZCount, tiles);
} }
public static int highestOneBit(uint i)
{
i |= (i >> 1);
i |= (i >> 2);
i |= (i >> 4);
i |= (i >> 8);
i |= (i >> 16);
return (int)(i - (i >> 1));
}
// See NavmeshBase.cs: ASTAR_RECAST_LARGER_TILES // See NavmeshBase.cs: ASTAR_RECAST_LARGER_TILES
private int getVertMask(int vertsCount) private int getVertMask(int vertsCount)
{ {
int vertMask = 1 << (BitOperations.Log2((uint)vertsCount) + 1); int vertMask = 1 << highestOneBit((uint)vertsCount);
if (vertMask != vertsCount) { if (vertMask != vertsCount) {
vertMask *= 2; vertMask *= 2;
} }
@ -149,3 +161,5 @@ public class GraphMeshDataReader : ZipBinaryReader {
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
@ -37,3 +39,5 @@ public class GraphMeta {
public Vector3f forcedBoundsCenter { get; set; } public Vector3f forcedBoundsCenter { get; set; }
public Vector3f forcedBoundsSize { get; set; } public Vector3f forcedBoundsSize { get; set; }
} }
}

View File

@ -20,7 +20,9 @@ using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Text.Json; using System.Text.Json;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class GraphMetaReader { public class GraphMetaReader {
@ -36,3 +38,5 @@ public class GraphMetaReader {
return JsonSerializer.Deserialize<GraphMeta>(json, options); return JsonSerializer.Deserialize<GraphMeta>(json, options);
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class LinkBuilder { public class LinkBuilder {
@ -64,3 +66,5 @@ public class LinkBuilder {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class Meta { public class Meta {
@ -71,3 +73,5 @@ public class Meta {
} }
} }
}

View File

@ -23,7 +23,9 @@ using System.Text.Json;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class MetaReader { public class MetaReader {
@ -52,3 +54,5 @@ public class MetaReader {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.IO.Compression; using System.IO.Compression;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
class NodeIndexReader : ZipBinaryReader { class NodeIndexReader : ZipBinaryReader {
@ -36,3 +38,5 @@ class NodeIndexReader : ZipBinaryReader {
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class NodeLink2 { public class NodeLink2 {
public readonly long linkID; public readonly long linkID;
@ -33,3 +35,5 @@ public class NodeLink2 {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.IO.Compression; using System.IO.Compression;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class NodeLink2Reader : ZipBinaryReader { public class NodeLink2Reader : ZipBinaryReader {
@ -47,3 +49,5 @@ public class NodeLink2Reader : ZipBinaryReader {
return links; return links;
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class OffMeshLinkCreator { public class OffMeshLinkCreator {
@ -61,3 +63,5 @@ public class OffMeshLinkCreator {
} }
} }
} }
}

View File

@ -20,7 +20,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
/** /**
* Import navmeshes created with A* Pathfinding Project Unity plugin (https://arongranberg.com/astar/). Graph data is * Import navmeshes created with A* Pathfinding Project Unity plugin (https://arongranberg.com/astar/). Graph data is
@ -73,3 +75,5 @@ public class UnityAStarPathfindingImporter {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public class UnityAStarPathfindingReader { public class UnityAStarPathfindingReader {
@ -47,9 +49,9 @@ public class UnityAStarPathfindingReader {
// Read NodeLink2 data (off-mesh links) // Read NodeLink2 data (off-mesh links)
NodeLink2[] nodeLinks2 = nodeLink2Reader.read(file, NODE_LINK_2_FILE_NAME, indexToNode); NodeLink2[] nodeLinks2 = nodeLink2Reader.read(file, NODE_LINK_2_FILE_NAME, indexToNode);
// Read graph by graph // Read graph by graph
List<GraphMeta> metaList = new(); List<GraphMeta> metaList = new List<GraphMeta>();
List<GraphMeshData> meshDataList = new(); List<GraphMeshData> meshDataList = new List<GraphMeshData>();
List<List<int[]>> connectionsList = new(); List<List<int[]>> connectionsList = new List<List<int[]>>();
for (int graphIndex = 0; graphIndex < meta.graphs; graphIndex++) { for (int graphIndex = 0; graphIndex < meta.graphs; graphIndex++) {
GraphMeta graphMeta = graphMetaReader.read(file, string.Format(GRAPH_META_FILE_NAME_PATTERN, graphIndex)); GraphMeta graphMeta = graphMetaReader.read(file, string.Format(GRAPH_META_FILE_NAME_PATTERN, graphIndex));
// First graph mesh data - vertices and polygons // First graph mesh data - vertices and polygons
@ -65,3 +67,5 @@ public class UnityAStarPathfindingReader {
return new GraphData(meta, indexToNode, nodeLinks2, metaList, meshDataList, connectionsList); return new GraphData(meta, indexToNode, nodeLinks2, metaList, meshDataList, connectionsList);
} }
} }
}

View File

@ -21,7 +21,9 @@ using System.IO.Compression;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
namespace DotRecast.Detour.Extras.Unity.Astar; namespace DotRecast.Detour.Extras.Unity.Astar
{
public abstract class ZipBinaryReader { public abstract class ZipBinaryReader {
@ -35,3 +37,5 @@ public abstract class ZipBinaryReader {
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Extras; namespace DotRecast.Detour.Extras
{
public class Vector3f { public class Vector3f {
@ -33,3 +35,5 @@ public class Vector3f {
} }
} }
}

View File

@ -25,7 +25,9 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public abstract class AbstractTileLayersBuilder { public abstract class AbstractTileLayersBuilder {
@ -37,7 +39,7 @@ public abstract class AbstractTileLayersBuilder {
} }
private List<byte[]> buildSingleThread(ByteOrder order, bool cCompatibility, int tw, int th) { private List<byte[]> buildSingleThread(ByteOrder order, bool cCompatibility, int tw, int th) {
List<byte[]> layers = new(); List<byte[]> layers = new List<byte[]>();
for (int y = 0; y < th; ++y) { for (int y = 0; y < th; ++y) {
for (int x = 0; x < tw; ++x) { for (int x = 0; x < tw; ++x) {
layers.AddRange(build(x, y, order, cCompatibility)); layers.AddRange(build(x, y, order, cCompatibility));
@ -64,7 +66,7 @@ public abstract class AbstractTileLayersBuilder {
.Select(x => x.Result) .Select(x => x.Result)
.ToDictionary(x => Tuple.Create(x.Item1, x.Item2), x => x.Item3); .ToDictionary(x => Tuple.Create(x.Item1, x.Item2), x => x.Item3);
List<byte[]> layers = new(); List<byte[]> layers = new List<byte[]>();
for (int y = 0; y < th; ++y) { for (int y = 0; y < th; ++y) {
for (int x = 0; x < tw; ++x) { for (int x = 0; x < tw; ++x) {
var key = Tuple.Create(x, y); var key = Tuple.Create(x, y);
@ -76,3 +78,5 @@ public abstract class AbstractTileLayersBuilder {
protected abstract List<byte[]> build(int tx, int ty, ByteOrder order, bool cCompatibility); protected abstract List<byte[]> build(int tx, int ty, ByteOrder order, bool cCompatibility);
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class CompressedTile { public class CompressedTile {
public readonly int index; public readonly int index;
@ -33,3 +35,5 @@ public class CompressedTile {
salt = 1; salt = 1;
} }
} }
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>

View File

@ -16,7 +16,9 @@
using System; using System;
namespace DotRecast.Detour.TileCache.Io.Compress; namespace DotRecast.Detour.TileCache.Io.Compress
{
/** /**
* Core of FastLZ compression algorithm. * Core of FastLZ compression algorithm.
@ -311,10 +313,10 @@ public class FastLz {
if (level == LEVEL_2) { if (level == LEVEL_2) {
if (distance < MAX_DISTANCE) { if (distance < MAX_DISTANCE) {
if (len < 7) { if (len < 7) {
output[outOffset + op++] = (byte) ((len << 5) + (distance >>> 8)); output[outOffset + op++] = (byte) ((len << 5) + (int)((ulong)distance >> 8));
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
} else { } else {
output[outOffset + op++] = (byte) ((7 << 5) + (distance >>> 8)); output[outOffset + op++] = (byte) ((7 << 5) + ((ulong)distance >> 8));
for (len -= 7; len >= 255; len -= 255) { for (len -= 7; len >= 255; len -= 255) {
output[outOffset + op++] = (byte) 255; output[outOffset + op++] = (byte) 255;
} }
@ -327,7 +329,7 @@ public class FastLz {
distance -= MAX_DISTANCE; distance -= MAX_DISTANCE;
output[outOffset + op++] = (byte) ((len << 5) + 31); output[outOffset + op++] = (byte) ((len << 5) + 31);
output[outOffset + op++] = (byte) 255; output[outOffset + op++] = (byte) 255;
output[outOffset + op++] = (byte) (distance >>> 8); output[outOffset + op++] = (byte) ((ulong)distance >> 8);
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
} else { } else {
distance -= MAX_DISTANCE; distance -= MAX_DISTANCE;
@ -337,14 +339,14 @@ public class FastLz {
} }
output[outOffset + op++] = (byte) len; output[outOffset + op++] = (byte) len;
output[outOffset + op++] = (byte) 255; output[outOffset + op++] = (byte) 255;
output[outOffset + op++] = (byte) (distance >>> 8); output[outOffset + op++] = (byte) ((ulong)distance >> 8);
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
} }
} }
} else { } else {
if (len > MAX_LEN - 2) { if (len > MAX_LEN - 2) {
while (len > MAX_LEN - 2) { while (len > MAX_LEN - 2) {
output[outOffset + op++] = (byte) ((7 << 5) + (distance >>> 8)); output[outOffset + op++] = (byte) ((7 << 5) + ((ulong)distance >> 8));
output[outOffset + op++] = (byte) (MAX_LEN - 2 - 7 - 2); output[outOffset + op++] = (byte) (MAX_LEN - 2 - 7 - 2);
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
len -= MAX_LEN - 2; len -= MAX_LEN - 2;
@ -352,10 +354,10 @@ public class FastLz {
} }
if (len < 7) { if (len < 7) {
output[outOffset + op++] = (byte) ((len << 5) + (distance >>> 8)); output[outOffset + op++] = (byte) ((len << 5) + (int)((ulong)distance >> 8));
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
} else { } else {
output[outOffset + op++] = (byte) ((7 << 5) + (distance >>> 8)); output[outOffset + op++] = (byte) ((7 << 5) + (int)((ulong)distance >> 8));
output[outOffset + op++] = (byte) (len - 7); output[outOffset + op++] = (byte) (len - 7);
output[outOffset + op++] = (byte) (distance & 255); output[outOffset + op++] = (byte) (distance & 255);
} }
@ -573,4 +575,5 @@ public class FastLz {
} }
private FastLz() { } private FastLz() { }
}
} }

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using DotRecast.Core; using DotRecast.Core;
using K4os.Compression.LZ4; using K4os.Compression.LZ4;
namespace DotRecast.Detour.TileCache.Io.Compress; namespace DotRecast.Detour.TileCache.Io.Compress
{
public class FastLzTileCacheCompressor : TileCacheCompressor { public class FastLzTileCacheCompressor : TileCacheCompressor {
@ -38,3 +40,5 @@ public class FastLzTileCacheCompressor : TileCacheCompressor {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using K4os.Compression.LZ4; using K4os.Compression.LZ4;
namespace DotRecast.Detour.TileCache.Io.Compress; namespace DotRecast.Detour.TileCache.Io.Compress
{
public class LZ4TileCacheCompressor : TileCacheCompressor { public class LZ4TileCacheCompressor : TileCacheCompressor {
@ -33,3 +35,5 @@ public class LZ4TileCacheCompressor : TileCacheCompressor {
} }
} }
}

View File

@ -17,13 +17,21 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache.Io.Compress; namespace DotRecast.Detour.TileCache.Io.Compress
{
public class TileCacheCompressorFactory { public class TileCacheCompressorFactory {
public static TileCacheCompressor get(bool cCompatibility) { public static TileCacheCompressor get(bool cCompatibility)
return cCompatibility ? new FastLzTileCacheCompressor() : new LZ4TileCacheCompressor(); {
if (cCompatibility)
return new FastLzTileCacheCompressor();
return new LZ4TileCacheCompressor();
} }
} }
}

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.TileCache.Io; namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheLayerHeaderReader { public class TileCacheLayerHeaderReader {
@ -59,3 +61,5 @@ public class TileCacheLayerHeaderReader {
} }
} }
}

View File

@ -22,7 +22,9 @@ using System.IO;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
namespace DotRecast.Detour.TileCache.Io; namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheLayerHeaderWriter : DetourWriter { public class TileCacheLayerHeaderWriter : DetourWriter {
@ -52,3 +54,5 @@ public class TileCacheLayerHeaderWriter : DetourWriter {
} }
} }
}

View File

@ -23,7 +23,9 @@ using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
using DotRecast.Detour.TileCache.Io.Compress; using DotRecast.Detour.TileCache.Io.Compress;
namespace DotRecast.Detour.TileCache.Io; namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheReader { public class TileCacheReader {
@ -93,3 +95,5 @@ public class TileCacheReader {
return option; return option;
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache.Io; namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheSetHeader { public class TileCacheSetHeader {
@ -32,3 +34,5 @@ public class TileCacheSetHeader {
public TileCacheParams cacheParams = new TileCacheParams(); public TileCacheParams cacheParams = new TileCacheParams();
} }
}

View File

@ -22,7 +22,9 @@ using System.IO;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Io; using DotRecast.Detour.Io;
namespace DotRecast.Detour.TileCache.Io; namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheWriter : DetourWriter { public class TileCacheWriter : DetourWriter {
@ -73,3 +75,5 @@ public class TileCacheWriter : DetourWriter {
} }
} }
}

View File

@ -17,9 +17,13 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class ObstacleRequest { public class ObstacleRequest {
public ObstacleRequestAction action; public ObstacleRequestAction action;
public long refs; public long refs;
} }
}

View File

@ -17,8 +17,12 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public enum ObstacleRequestAction { public enum ObstacleRequestAction {
REQUEST_ADD, REQUEST_REMOVE REQUEST_ADD, REQUEST_REMOVE
} }
}

View File

@ -17,9 +17,13 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public enum ObstacleState { public enum ObstacleState {
DT_OBSTACLE_EMPTY, DT_OBSTACLE_PROCESSING, DT_OBSTACLE_PROCESSED, DT_OBSTACLE_REMOVING DT_OBSTACLE_EMPTY, DT_OBSTACLE_PROCESSING, DT_OBSTACLE_PROCESSED, DT_OBSTACLE_REMOVING
} }
}

View File

@ -25,7 +25,9 @@ using DotRecast.Detour.TileCache.Io;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCache { public class TileCache {
@ -46,11 +48,11 @@ public class TileCache {
private readonly TileCacheCompressor m_tcomp; private readonly TileCacheCompressor m_tcomp;
private readonly TileCacheMeshProcess m_tmproc; private readonly TileCacheMeshProcess m_tmproc;
private readonly List<TileCacheObstacle> m_obstacles = new(); private readonly List<TileCacheObstacle> m_obstacles = new List<TileCacheObstacle>();
private TileCacheObstacle m_nextFreeObstacle; private TileCacheObstacle m_nextFreeObstacle;
private readonly List<ObstacleRequest> m_reqs = new(); private readonly List<ObstacleRequest> m_reqs = new List<ObstacleRequest>();
private readonly List<long> m_update = new(); private readonly List<long> m_update = new List<long>();
private readonly TileCacheBuilder builder = new TileCacheBuilder(); private readonly TileCacheBuilder builder = new TileCacheBuilder();
private readonly TileCacheLayerHeaderReader tileReader = new TileCacheLayerHeaderReader(); private readonly TileCacheLayerHeaderReader tileReader = new TileCacheLayerHeaderReader();
@ -137,7 +139,7 @@ public class TileCache {
} }
public List<long> getTilesAt(int tx, int ty) { public List<long> getTilesAt(int tx, int ty) {
List<long> tiles = new(); List<long> tiles = new List<long>();
// Find tile based on hash. // Find tile based on hash.
int h = NavMesh.computeTileHash(tx, ty, m_tileLutMask); int h = NavMesh.computeTileHash(tx, ty, m_tileLutMask);
@ -357,7 +359,7 @@ public class TileCache {
} }
List<long> queryTiles(float[] bmin, float[] bmax) { List<long> queryTiles(float[] bmin, float[] bmax) {
List<long> results = new(); List<long> results = new List<long>();
float tw = m_params.width * m_params.cs; float tw = m_params.width * m_params.cs;
float th = m_params.height * m_params.cs; float th = m_params.height * m_params.cs;
int tx0 = (int) Math.Floor((bmin[0] - m_params.orig[0]) / tw); int tx0 = (int) Math.Floor((bmin[0] - m_params.orig[0]) / tw);
@ -603,3 +605,5 @@ public class TileCache {
return m_navmesh; return m_navmesh;
} }
} }
}

View File

@ -26,7 +26,9 @@ using DotRecast.Detour.TileCache.Io;
using DotRecast.Detour.TileCache.Io.Compress; using DotRecast.Detour.TileCache.Io.Compress;
using static DotRecast.Detour.DetourCommon; using static DotRecast.Detour.DetourCommon;
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheBuilder { public class TileCacheBuilder {
@ -42,7 +44,7 @@ public class TileCacheBuilder {
public class LayerMonotoneRegion { public class LayerMonotoneRegion {
public int area; public int area;
public List<int> neis = new(16); public List<int> neis = new List<int>(16);
public int regId; public int regId;
public int areaId; public int areaId;
}; };
@ -53,9 +55,9 @@ public class TileCacheBuilder {
public List<int> poly; public List<int> poly;
public TempContour() { public TempContour() {
verts = new(); verts = new List<int>();
nverts = 0; nverts = 0;
poly = new(); poly = new List<int>();
} }
public int npoly() { public int npoly() {
@ -1195,7 +1197,7 @@ public class TileCacheBuilder {
return false; return false;
// Find edges which share the removed vertex. // Find edges which share the removed vertex.
List<int> edges = new(); List<int> edges = new List<int>();
int nedges = 0; int nedges = 0;
for (int i = 0; i < mesh.npolys; ++i) { for (int i = 0; i < mesh.npolys; ++i) {
@ -1262,10 +1264,10 @@ public class TileCacheBuilder {
} }
int nedges = 0; int nedges = 0;
List<int> edges = new(); List<int> edges = new List<int>();
int nhole = 0; int nhole = 0;
List<int> hole = new(); List<int> hole = new List<int>();
List<int> harea = new(); List<int> harea = new List<int>();
for (int i = 0; i < mesh.npolys; ++i) { for (int i = 0; i < mesh.npolys; ++i) {
int p = i * maxVertsPerPoly * 2; int p = i * maxVertsPerPoly * 2;
@ -1841,3 +1843,5 @@ public class TileCacheBuilder {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public interface TileCacheCompressor { public interface TileCacheCompressor {
@ -25,3 +27,5 @@ public interface TileCacheCompressor {
byte[] compress(byte[] buf); byte[] compress(byte[] buf);
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheContour { public class TileCacheContour {
public int nverts; public int nverts;
@ -25,3 +27,5 @@ public class TileCacheContour {
public int reg; public int reg;
public int area; public int area;
} }
}

View File

@ -17,9 +17,13 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheContourSet { public class TileCacheContourSet {
public int nconts; public int nconts;
public TileCacheContour[] conts; public TileCacheContour[] conts;
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheLayer { public class TileCacheLayer {
public TileCacheLayerHeader header; public TileCacheLayerHeader header;
@ -27,3 +29,5 @@ public class TileCacheLayer {
public short[] cons; // char public short[] cons; // char
public short[] regs; // char public short[] regs; // char
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheLayerHeader { public class TileCacheLayerHeader {
@ -34,3 +36,5 @@ public class TileCacheLayerHeader {
public int minx, maxx, miny, maxy; /// < Usable sub-region. public int minx, maxx, miny, maxy; /// < Usable sub-region.
} }
}

View File

@ -17,9 +17,13 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public interface TileCacheMeshProcess { public interface TileCacheMeshProcess {
void process(NavMeshDataCreateParams option); void process(NavMeshDataCreateParams option);
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheObstacle { public class TileCacheObstacle {
@ -37,8 +39,8 @@ public class TileCacheObstacle {
public readonly float[] center = new float[3]; public readonly float[] center = new float[3];
public readonly float[] extents = new float[3]; public readonly float[] extents = new float[3];
public readonly float[] rotAux = new float[2]; // { cos(0.5f*angle)*sin(-0.5f*angle); cos(0.5f*angle)*cos(0.5f*angle) - 0.5 } public readonly float[] rotAux = new float[2]; // { cos(0.5f*angle)*sin(-0.5f*angle); cos(0.5f*angle)*cos(0.5f*angle) - 0.5 }
public List<long> touched = new(); public List<long> touched = new List<long>();
public readonly List<long> pending = new(); public readonly List<long> pending = new List<long>();
public int salt; public int salt;
public ObstacleState state = ObstacleState.DT_OBSTACLE_EMPTY; public ObstacleState state = ObstacleState.DT_OBSTACLE_EMPTY;
public TileCacheObstacle next; public TileCacheObstacle next;
@ -49,3 +51,5 @@ public class TileCacheObstacle {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheParams { public class TileCacheParams {
public readonly float[] orig = new float[3]; public readonly float[] orig = new float[3];
@ -31,3 +33,5 @@ public class TileCacheParams {
public int maxObstacles; public int maxObstacles;
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCachePolyMesh { public class TileCachePolyMesh {
public int nvp; public int nvp;
@ -32,3 +34,5 @@ public class TileCachePolyMesh {
this.nvp = nvp; this.nvp = nvp;
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.TileCache; namespace DotRecast.Detour.TileCache
{
public class TileCacheStorageParams { public class TileCacheStorageParams {
@ -33,3 +35,5 @@ public class TileCacheStorageParams {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Bounding volume node. * Bounding volume node.
@ -33,3 +35,5 @@ public class BVNode {
/** The node's index. (Negative for escape sequence.) */ /** The node's index. (Negative for escape sequence.) */
public int i; public int i;
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class ClosestPointOnPolyResult { public class ClosestPointOnPolyResult {
@ -40,3 +42,5 @@ public class ClosestPointOnPolyResult {
} }
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -235,3 +237,5 @@ public static class ConvexConvexIntersection {
} }
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -100,3 +102,5 @@ public class DefaultQueryFilter : QueryFilter {
} }
} }
}

View File

@ -16,7 +16,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -37,3 +39,5 @@ public class DefaultQueryHeuristic : QueryHeuristic {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class DetourBuilder { public class DetourBuilder {
@ -30,3 +32,5 @@ public class DetourBuilder {
return data; return data;
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public static class DetourCommon { public static class DetourCommon {
@ -635,3 +637,5 @@ public static class DetourCommon {
} }
} }
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
//TODO: (PP) Add comments //TODO: (PP) Add comments
public class FindDistanceToWallResult { public class FindDistanceToWallResult {
@ -43,4 +45,5 @@ public class FindDistanceToWallResult {
return normal; return normal;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
//TODO: (PP) Add comments //TODO: (PP) Add comments
public class FindLocalNeighbourhoodResult { public class FindLocalNeighbourhoodResult {
@ -40,4 +42,5 @@ public class FindLocalNeighbourhoodResult {
return parentRefs; return parentRefs;
} }
}
} }

View File

@ -1,6 +1,8 @@
using System; using System;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -51,3 +53,5 @@ public class FindNearestPolyQuery : PolyQuery {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class FindNearestPolyResult { public class FindNearestPolyResult {
private readonly long nearestRef; private readonly long nearestRef;
@ -45,3 +47,5 @@ public class FindNearestPolyResult {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
// TODO: (PP) Add comments // TODO: (PP) Add comments
@ -47,4 +49,5 @@ public class FindPolysAroundResult {
return costs; return costs;
} }
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
//TODO: (PP) Add comments //TODO: (PP) Add comments
public class FindRandomPointResult { public class FindRandomPointResult {
@ -39,4 +41,5 @@ public class FindRandomPointResult {
return randomPt; return randomPt;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class GetPolyWallSegmentsResult { public class GetPolyWallSegmentsResult {
@ -42,3 +44,5 @@ public class GetPolyWallSegmentsResult {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System;
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public abstract class DetourWriter { public abstract class DetourWriter {
@ -42,11 +44,11 @@ public abstract class DetourWriter {
protected void write(BinaryWriter stream, long value, ByteOrder order) { protected void write(BinaryWriter stream, long value, ByteOrder order) {
if (order == ByteOrder.BIG_ENDIAN) { if (order == ByteOrder.BIG_ENDIAN) {
write(stream, (int) (value >>> 32), order); write(stream, (int) ((ulong)value >> 32), order);
write(stream, (int) (value & 0xFFFFFFFF), order); write(stream, (int) (value & 0xFFFFFFFF), order);
} else { } else {
write(stream, (int) (value & 0xFFFFFFFF), order); write(stream, (int) (value & 0xFFFFFFFF), order);
write(stream, (int) (value >>> 32), order); write(stream, (int) ((ulong)value >> 32), order);
} }
} }
@ -80,3 +82,5 @@ public abstract class DetourWriter {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System;
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public static class IOUtils { public static class IOUtils {
@ -51,8 +53,11 @@ public static class IOUtils {
return new ByteBuffer(bytes); return new ByteBuffer(bytes);
} }
public static int swapEndianness(int i) { public static int swapEndianness(int i)
var s = ((i >>> 24) & 0xFF) | ((i>>8) & 0xFF00) | ((i<<8) & 0xFF0000) | ((i << 24) & 0xFF000000); {
var s = (((uint)i >> 24) & 0xFF) | (((uint)i>>8) & 0xFF00) | (((uint)i<<8) & 0xFF0000) | ((i << 24) & 0xFF000000);
return (int)s; return (int)s;
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class MeshDataReader { public class MeshDataReader {
@ -199,3 +201,5 @@ public class MeshDataReader {
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class MeshDataWriter : DetourWriter { public class MeshDataWriter : DetourWriter {
@ -140,3 +142,5 @@ public class MeshDataWriter : DetourWriter {
} }
} }
}

View File

@ -20,7 +20,9 @@ using System;
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
using static DetourCommon; using static DetourCommon;
@ -125,3 +127,5 @@ public class MeshSetReader {
return NavMesh.encodePolyId(salt, it, ip); return NavMesh.encodePolyId(salt, it, ip);
} }
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class MeshSetWriter : DetourWriter { public class MeshSetWriter : DetourWriter {
@ -76,3 +78,5 @@ public class MeshSetWriter : DetourWriter {
} }
} }
}

View File

@ -1,6 +1,8 @@
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class NavMeshParamReader { public class NavMeshParamReader {
@ -17,3 +19,5 @@ public class NavMeshParamReader {
} }
} }
}

View File

@ -1,7 +1,9 @@
using System.IO; using System.IO;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class NavMeshParamWriter : DetourWriter { public class NavMeshParamWriter : DetourWriter {
@ -16,3 +18,5 @@ public class NavMeshParamWriter : DetourWriter {
} }
} }
}

View File

@ -15,7 +15,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class NavMeshSetHeader { public class NavMeshSetHeader {
@ -31,3 +33,5 @@ public class NavMeshSetHeader {
public int maxVertsPerPoly; public int maxVertsPerPoly;
} }
}

View File

@ -1,6 +1,10 @@
namespace DotRecast.Detour.Io; namespace DotRecast.Detour.Io
{
public class NavMeshTileHeader { public class NavMeshTileHeader {
public long tileRef; public long tileRef;
public int dataSize; public int dataSize;
} }
}

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -45,7 +47,7 @@ public class LegacyNavMeshQuery : NavMeshQuery {
} }
if (startRef == endRef) { if (startRef == endRef) {
List<long> singlePath = new(1); List<long> singlePath = new List<long>(1);
singlePath.Add(startRef); singlePath.Add(startRef);
return Results.success(singlePath); return Results.success(singlePath);
} }
@ -412,7 +414,7 @@ public class LegacyNavMeshQuery : NavMeshQuery {
/// @returns The status flags for the query. /// @returns The status flags for the query.
public override Result<List<long>> finalizeSlicedFindPath() { public override Result<List<long>> finalizeSlicedFindPath() {
List<long> path = new(64); List<long> path = new List<long>(64);
if (m_query.status.isFailed()) { if (m_query.status.isFailed()) {
// Reset query. // Reset query.
m_query = new QueryData(); m_query = new QueryData();
@ -480,7 +482,7 @@ public class LegacyNavMeshQuery : NavMeshQuery {
/// @returns The status flags for the query. /// @returns The status flags for the query.
public override Result<List<long>> finalizeSlicedFindPathPartial(List<long> existing) { public override Result<List<long>> finalizeSlicedFindPathPartial(List<long> existing) {
List<long> path = new(64); List<long> path = new List<long>(64);
if (null == existing || existing.Count <= 0) { if (null == existing || existing.Count <= 0) {
return Results.failure(path); return Results.failure(path);
} }
@ -728,3 +730,5 @@ public class LegacyNavMeshQuery : NavMeshQuery {
return Results.success(new FindDistanceToWallResult((float) Math.Sqrt(radiusSqr), hitPos, hitNormal)); return Results.success(new FindDistanceToWallResult((float) Math.Sqrt(radiusSqr), hitPos, hitNormal));
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Defines a link between polygons. * Defines a link between polygons.
@ -40,3 +42,5 @@ public class Link {
public int bmax; public int bmax;
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class MeshData { public class MeshData {
@ -43,4 +45,5 @@ public class MeshData {
/** The tile off-mesh connections. [Size: MeshHeader::offMeshConCount] */ /** The tile off-mesh connections. [Size: MeshHeader::offMeshConCount] */
public OffMeshConnection[] offMeshCons; public OffMeshConnection[] offMeshCons;
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** Provides high level information related to a dtMeshTile object. */ /** Provides high level information related to a dtMeshTile object. */
public class MeshHeader { public class MeshHeader {
@ -77,3 +79,5 @@ public class MeshHeader {
/** The bounding volume quantization factor. */ /** The bounding volume quantization factor. */
public float bvQuantFactor; public float bvQuantFactor;
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Defines a navigation mesh tile. * Defines a navigation mesh tile.
@ -33,7 +35,7 @@ public class MeshTile {
public MeshData data; public MeshData data;
public int[] polyLinks; public int[] polyLinks;
/** The tile links. */ /** The tile links. */
public readonly List<Link> links = new(); public readonly List<Link> links = new List<Link>();
/** Index to the next free link. */ /** Index to the next free link. */
public int linksFreeList = NavMesh.DT_NULL_LINK; // FIXME: Remove public int linksFreeList = NavMesh.DT_NULL_LINK; // FIXME: Remove
/** Tile flags. (See: #dtTileFlags) */ /** Tile flags. (See: #dtTileFlags) */
@ -44,3 +46,5 @@ public class MeshTile {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class MoveAlongSurfaceResult { public class MoveAlongSurfaceResult {
@ -44,3 +46,5 @@ public class MoveAlongSurfaceResult {
} }
} }
}

View File

@ -23,7 +23,9 @@ using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -58,8 +60,8 @@ public class NavMesh {
float m_tileWidth, m_tileHeight; /// < Dimensions of each tile. float m_tileWidth, m_tileHeight; /// < Dimensions of each tile.
int m_maxTiles; /// < Max number of tiles. int m_maxTiles; /// < Max number of tiles.
private readonly int m_tileLutMask; /// < Tile hash lookup mask. private readonly int m_tileLutMask; /// < Tile hash lookup mask.
private readonly Dictionary<int, List<MeshTile>> posLookup = new(); private readonly Dictionary<int, List<MeshTile>> posLookup = new Dictionary<int, List<MeshTile>>();
private readonly LinkedList<MeshTile> availableTiles = new(); private readonly LinkedList<MeshTile> availableTiles = new LinkedList<MeshTile>();
private readonly MeshTile[] m_tiles; /// < List of tiles. private readonly MeshTile[] m_tiles; /// < List of tiles.
/** The maximum number of vertices per navigation polygon. */ /** The maximum number of vertices per navigation polygon. */
private readonly int m_maxVertPerPoly; private readonly int m_maxVertPerPoly;
@ -285,7 +287,7 @@ public class NavMesh {
// for off-mesh connection finding. // for off-mesh connection finding.
List<long> queryPolygonsInTile(MeshTile tile, float[] qmin, float[] qmax) { List<long> queryPolygonsInTile(MeshTile tile, float[] qmin, float[] qmax) {
List<long> polys = new(); List<long> polys = new List<long>();
if (tile.data.bvTree != null) { if (tile.data.bvTree != null) {
int nodeIndex = 0; int nodeIndex = 0;
float[] tbmin = tile.data.header.bmin; float[] tbmin = tile.data.header.bmin;
@ -756,7 +758,7 @@ public class NavMesh {
if (tile == null) { if (tile == null) {
return ImmutableArray<Tuple<long, float, float>>.Empty; return ImmutableArray<Tuple<long, float, float>>.Empty;
} }
List<Tuple<long, float, float>> result = new(); List<Tuple<long, float, float>> result = new List<Tuple<long, float, float>>();
float[] amin = new float[2]; float[] amin = new float[2];
float[] amax = new float[2]; float[] amax = new float[2];
calcSlabEndPoints(verts, va, vb, amin, amax, side); calcSlabEndPoints(verts, va, vb, amin, amax, side);
@ -1195,7 +1197,7 @@ public class NavMesh {
} }
public List<MeshTile> getTilesAt(int x, int y) { public List<MeshTile> getTilesAt(int x, int y) {
List<MeshTile> tiles = new(); List<MeshTile> tiles = new List<MeshTile>();
foreach (MeshTile tile in getTileListByPos(x, y)) { foreach (MeshTile tile in getTileListByPos(x, y)) {
if (tile.data.header != null && tile.data.header.x == x && tile.data.header.y == y) { if (tile.data.header != null && tile.data.header.x == x && tile.data.header.y == y) {
tiles.Add(tile); tiles.Add(tile);
@ -1418,10 +1420,12 @@ public class NavMesh {
var tileHash = computeTileHash(x, z, m_tileLutMask); var tileHash = computeTileHash(x, z, m_tileLutMask);
if (!posLookup.TryGetValue(tileHash, out var tiles)) if (!posLookup.TryGetValue(tileHash, out var tiles))
{ {
tiles = new(); tiles = new List<MeshTile>();
posLookup.Add(tileHash, tiles); posLookup.Add(tileHash, tiles);
} }
return tiles; return tiles;
} }
} }
}

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -600,3 +602,5 @@ public class NavMeshBuilder {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/// Represents the source data used to build an navigation mesh tile. /// Represents the source data used to build an navigation mesh tile.
public class NavMeshDataCreateParams { public class NavMeshDataCreateParams {
@ -99,4 +101,5 @@ public class NavMeshDataCreateParams {
/// @} /// @}
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Configuration parameters used to define multi-tile navigation meshes. The values are used to allocate space during * Configuration parameters used to define multi-tile navigation meshes. The values are used to allocate space during
@ -37,3 +39,5 @@ public class NavMeshParams {
/** The maximum number of polygons each tile can contain. */ /** The maximum number of polygons each tile can contain. */
public int maxPolys; public int maxPolys;
} }
}

View File

@ -22,7 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
using static Node; using static Node;
@ -636,7 +638,7 @@ public class NavMeshQuery {
int[] maxxy = m_nav.calcTileLoc(bmax); int[] maxxy = m_nav.calcTileLoc(bmax);
int maxx = maxxy[0]; int maxx = maxxy[0];
int maxy = maxxy[1]; int maxy = maxxy[1];
List<MeshTile> tiles = new(); List<MeshTile> tiles = new List<MeshTile>();
for (int y = miny; y <= maxy; ++y) { for (int y = miny; y <= maxy; ++y) {
for (int x = minx; x <= maxx; ++x) { for (int x = minx; x <= maxx; ++x) {
tiles.AddRange(m_nav.getTilesAt(x, y)); tiles.AddRange(m_nav.getTilesAt(x, y));
@ -694,7 +696,7 @@ public class NavMeshQuery {
} }
if (startRef == endRef) { if (startRef == endRef) {
List<long> singlePath = new(1); List<long> singlePath = new List<long>(1);
singlePath.Add(startRef); singlePath.Add(startRef);
return Results.success(singlePath); return Results.success(singlePath);
} }
@ -1181,7 +1183,7 @@ public class NavMeshQuery {
/// @returns The status flags for the query. /// @returns The status flags for the query.
public virtual Result<List<long>> finalizeSlicedFindPath() { public virtual Result<List<long>> finalizeSlicedFindPath() {
List<long> path = new(64); List<long> path = new List<long>(64);
if (m_query.status.isFailed()) { if (m_query.status.isFailed()) {
// Reset query. // Reset query.
m_query = new QueryData(); m_query = new QueryData();
@ -1215,7 +1217,7 @@ public class NavMeshQuery {
/// @returns The status flags for the query. /// @returns The status flags for the query.
public virtual Result<List<long>> finalizeSlicedFindPathPartial(List<long> existing) { public virtual Result<List<long>> finalizeSlicedFindPathPartial(List<long> existing) {
List<long> path = new(64); List<long> path = new List<long>(64);
if (null == existing || existing.Count <= 0) { if (null == existing || existing.Count <= 0) {
return Results.failure(path); return Results.failure(path);
} }
@ -1350,7 +1352,7 @@ public class NavMeshQuery {
public virtual Result<List<StraightPathItem>> findStraightPath(float[] startPos, float[] endPos, List<long> path, public virtual Result<List<StraightPathItem>> findStraightPath(float[] startPos, float[] endPos, List<long> path,
int maxStraightPath, int options) { int maxStraightPath, int options) {
List<StraightPathItem> straightPath = new(); List<StraightPathItem> straightPath = new List<StraightPathItem>();
if (null == startPos || !vIsFinite(startPos) || null == endPos || !vIsFinite(endPos) if (null == startPos || !vIsFinite(startPos) || null == endPos || !vIsFinite(endPos)
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0) { || null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0) {
return Results.invalidParam<List<StraightPathItem>>(); return Results.invalidParam<List<StraightPathItem>>();
@ -1578,7 +1580,7 @@ public class NavMeshQuery {
startNode.total = 0; startNode.total = 0;
startNode.id = startRef; startNode.id = startRef;
startNode.flags = Node.DT_NODE_CLOSED; startNode.flags = Node.DT_NODE_CLOSED;
LinkedList<Node> stack = new(); LinkedList<Node> stack = new LinkedList<Node>();
stack.AddLast(startNode); stack.AddLast(startNode);
float[] bestPos = new float[3]; float[] bestPos = new float[3];
@ -1690,7 +1692,7 @@ public class NavMeshQuery {
} }
} }
List<long> visited = new(); List<long> visited = new List<long>();
if (bestNode != null) { if (bestNode != null) {
// Reverse the path. // Reverse the path.
Node prev = null; Node prev = null;
@ -2157,9 +2159,9 @@ public class NavMeshQuery {
return Results.invalidParam<FindPolysAroundResult>(); return Results.invalidParam<FindPolysAroundResult>();
} }
List<long> resultRef = new(); List<long> resultRef = new List<long>();
List<long> resultParent = new(); List<long> resultParent = new List<long>();
List<float> resultCost = new(); List<float> resultCost = new List<float>();
m_nodePool.clear(); m_nodePool.clear();
m_openList.clear(); m_openList.clear();
@ -2316,9 +2318,9 @@ public class NavMeshQuery {
return Results.invalidParam<FindPolysAroundResult>(); return Results.invalidParam<FindPolysAroundResult>();
} }
List<long> resultRef = new(); List<long> resultRef = new List<long>();
List<long> resultParent = new(); List<long> resultParent = new List<long>();
List<float> resultCost = new(); List<float> resultCost = new List<float>();
m_nodePool.clear(); m_nodePool.clear();
m_openList.clear(); m_openList.clear();
@ -2488,8 +2490,8 @@ public class NavMeshQuery {
return Results.invalidParam<FindLocalNeighbourhoodResult>(); return Results.invalidParam<FindLocalNeighbourhoodResult>();
} }
List<long> resultRef = new(); List<long> resultRef = new List<long>();
List<long> resultParent = new(); List<long> resultParent = new List<long>();
NodePool tinyNodePool = new NodePool(); NodePool tinyNodePool = new NodePool();
@ -2497,7 +2499,7 @@ public class NavMeshQuery {
startNode.pidx = 0; startNode.pidx = 0;
startNode.id = startRef; startNode.id = startRef;
startNode.flags = Node.DT_NODE_CLOSED; startNode.flags = Node.DT_NODE_CLOSED;
LinkedList<Node> stack = new(); LinkedList<Node> stack = new LinkedList<Node>();
stack.AddLast(startNode); stack.AddLast(startNode);
resultRef.Add(startNode.id); resultRef.Add(startNode.id);
@ -2679,9 +2681,9 @@ public class NavMeshQuery {
MeshTile tile = tileAndPoly.result.Item1; MeshTile tile = tileAndPoly.result.Item1;
Poly poly = tileAndPoly.result.Item2; Poly poly = tileAndPoly.result.Item2;
List<long> segmentRefs = new(); List<long> segmentRefs = new List<long>();
List<float[]> segmentVerts = new(); List<float[]> segmentVerts = new List<float[]>();
List<SegInterval> ints = new(16); List<SegInterval> ints = new List<SegInterval>(16);
for (int i = 0, j = poly.vertCount - 1; i < poly.vertCount; j = i++) { for (int i = 0, j = poly.vertCount - 1; i < poly.vertCount; j = i++) {
// Skip non-solid edges. // Skip non-solid edges.
@ -3012,7 +3014,7 @@ public class NavMeshQuery {
* Gets the path leading to the specified end node. * Gets the path leading to the specified end node.
*/ */
protected List<long> getPathToNode(Node endNode) { protected List<long> getPathToNode(Node endNode) {
List<long> path = new(); List<long> path = new List<long>();
// Reverse the path. // Reverse the path.
Node curNode = endNode; Node curNode = endNode;
do { do {
@ -3053,4 +3055,5 @@ public class NavMeshQuery {
return m_nodePool; return m_nodePool;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class Node { public class Node {
@ -60,3 +62,5 @@ public class Node {
} }
} }
}

View File

@ -20,14 +20,16 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class NodePool public class NodePool
{ {
private readonly Dictionary<long, List<Node>> m_map = new(); private readonly Dictionary<long, List<Node>> m_map = new Dictionary<long, List<Node>>();
private readonly List<Node> m_nodes = new(); private readonly List<Node> m_nodes = new List<Node>();
public NodePool() { public NodePool() {
@ -41,7 +43,7 @@ public class NodePool
public List<Node> findNodes(long id) { public List<Node> findNodes(long id) {
var hasNode = m_map.TryGetValue(id, out var nodes);; var hasNode = m_map.TryGetValue(id, out var nodes);;
if (nodes == null) { if (nodes == null) {
nodes = new(); nodes = new List<Node>();
} }
return nodes; return nodes;
} }
@ -73,7 +75,7 @@ public class NodePool
m_nodes.Add(node); m_nodes.Add(node);
var hasNode = m_map.TryGetValue(id, out var nodes);; var hasNode = m_map.TryGetValue(id, out var nodes);;
if (nodes == null) { if (nodes == null) {
nodes = new(); nodes = new List<Node>();
m_map.Add(id, nodes); m_map.Add(id, nodes);
} }
nodes.Add(node); nodes.Add(node);
@ -97,3 +99,5 @@ public class NodePool
} }
} }
}

View File

@ -17,13 +17,15 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using System.Collections.Generic; using System.Collections.Generic;
public class NodeQueue { public class NodeQueue {
private readonly List<Node> m_heap = new(); private readonly List<Node> m_heap = new List<Node>();
public int count() public int count()
{ {
@ -61,3 +63,5 @@ public class NodeQueue {
return 0 == m_heap.Count; return 0 == m_heap.Count;
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is a user defined * Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is a user defined
@ -41,4 +43,5 @@ public class OffMeshConnection {
public int 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; public int userId;
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** Defines a polygon within a MeshTile object. */ /** Defines a polygon within a MeshTile object. */
public class Poly { public class Poly {
@ -69,3 +71,5 @@ public class Poly {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** Defines the location of detail sub-mesh data within a dtMeshTile. */ /** Defines the location of detail sub-mesh data within a dtMeshTile. */
public class PolyDetail { public class PolyDetail {
@ -30,3 +32,5 @@ public class PolyDetail {
/** The number of triangles in the sub-mesh. */ /** The number of triangles in the sub-mesh. */
public int triCount; public int triCount;
} }
}

View File

@ -1,6 +1,10 @@
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public interface PolyQuery { public interface PolyQuery {
void process(MeshTile tile, Poly poly, long refs); void process(MeshTile tile, Poly poly, long refs);
} }
}

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -92,3 +94,5 @@ public interface PolygonByCircleConstraint {
} }
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class QueryData { public class QueryData {
public Status status; public Status status;
@ -30,4 +32,5 @@ public class QueryData {
public int options; public int options;
public float raycastLimitSqr; public float raycastLimitSqr;
public QueryHeuristic heuristic; public QueryHeuristic heuristic;
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public interface QueryFilter { public interface QueryFilter {
@ -27,3 +29,5 @@ public interface QueryFilter {
Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly); Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly);
} }
}

View File

@ -16,10 +16,14 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public interface QueryHeuristic { public interface QueryHeuristic {
float getCost(float[] neighbourPos, float[] endPos); float getCost(float[] neighbourPos, float[] endPos);
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
@ -32,9 +34,11 @@ public class RaycastHit {
/** hitNormal The normal of the nearest wall hit. [(x, y, z)] */ /** hitNormal The normal of the nearest wall hit. [(x, y, z)] */
public readonly float[] hitNormal = new float[3]; public readonly float[] hitNormal = new float[3];
/** Visited polygons. */ /** Visited polygons. */
public readonly List<long> path = new(); public readonly List<long> path = new List<long>();
/** The cost of the path until hit. */ /** The cost of the path until hit. */
public float pathCost; public float pathCost;
/** The index of the edge on the readonly polygon where the wall was hit. */ /** The index of the edge on the readonly polygon where the wall was hit. */
public int hitEdgeIndex; public int hitEdgeIndex;
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public static class Results public static class Results
{ {
@ -81,3 +83,5 @@ public class Result<T> {
} }
} }
}

View File

@ -17,14 +17,16 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
public class Status { public class Status {
public static Status FAILURE = new(0); public static Status FAILURE = new Status(0);
public static Status SUCCSESS = new(1); public static Status SUCCSESS = new Status(1);
public static Status IN_PROGRESS = new(2); public static Status IN_PROGRESS = new Status(2);
public static Status PARTIAL_RESULT = new(3); public static Status PARTIAL_RESULT = new Status(3);
public static Status FAILURE_INVALID_PARAM = new(4); public static Status FAILURE_INVALID_PARAM = new Status(4);
public int Value { get; } public int Value { get; }
@ -53,3 +55,5 @@ public static class StatusEx
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
using static DetourCommon; using static DetourCommon;
@ -45,4 +47,5 @@ public class StraightPathItem {
return refs; return refs;
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Detour; namespace DotRecast.Detour
{
/** /**
* Wrapper for 3-element pieces (3D vectors) of a bigger float array. * Wrapper for 3-element pieces (3D vectors) of a bigger float array.
@ -44,4 +46,5 @@ public class VectorPtr
{ {
return array[index + offset]; return array[index + offset];
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class AreaModification public class AreaModification
{ {
@ -67,4 +69,5 @@ public class AreaModification
{ {
return ((value & mask) | (area & ~mask)); return ((value & mask) | (area & ~mask));
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Provides information on the content of a cell column in a compact heightfield. */ /** Provides information on the content of a cell column in a compact heightfield. */
public class CompactCell public class CompactCell
@ -28,4 +30,5 @@ public class CompactCell
/** Number of spans in the column. */ /** Number of spans in the column. */
public int count; public int count;
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** A compact, static heightfield representing unobstructed space. */ /** A compact, static heightfield representing unobstructed space. */
public class CompactHeightfield public class CompactHeightfield
@ -70,4 +72,5 @@ public class CompactHeightfield
/** Array containing area id data. [Size: #spanCount] */ /** Array containing area id data. [Size: #spanCount] */
public int[] areas; public int[] areas;
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a span of unobstructed space within a compact heightfield. */ /** Represents a span of unobstructed space within a compact heightfield. */
public class CompactSpan public class CompactSpan
@ -34,4 +36,5 @@ public class CompactSpan
/** The height of the span. (Measured from #y.) */ /** The height of the span. (Measured from #y.) */
public int h; public int h;
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a simple, non-overlapping contour in field space. */ /** Represents a simple, non-overlapping contour in field space. */
public class Contour public class Contour
@ -40,4 +42,5 @@ public class Contour
/** The area id of the contour. */ /** The area id of the contour. */
public int reg; public int reg;
}
} }

View File

@ -20,13 +20,15 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a group of related contours. */ /** Represents a group of related contours. */
public class ContourSet public class ContourSet
{ {
/** A list of the contours in the set. */ /** A list of the contours in the set. */
public List<Contour> conts = new(); public List<Contour> conts = new List<Contour>();
/** The minimum bounds in world space. [(x, y, z)] */ /** The minimum bounds in world space. [(x, y, z)] */
public float[] bmin = new float[3]; public float[] bmin = new float[3];
@ -51,4 +53,5 @@ public class ContourSet
/** The max edge error that this contour set was simplified with. */ /** The max edge error that this contour set was simplified with. */
public float maxError; public float maxError;
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class ConvexVolume public class ConvexVolume
{ {
@ -26,4 +28,5 @@ public class ConvexVolume
public float hmin; public float hmin;
public float hmax; public float hmax;
public AreaModification areaMod; public AreaModification areaMod;
}
} }

View File

@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public class ChunkyTriMesh public class ChunkyTriMesh
{ {
@ -150,7 +152,7 @@ public class ChunkyTriMesh
{ {
int nchunks = (ntris + trisPerChunk - 1) / trisPerChunk; int nchunks = (ntris + trisPerChunk - 1) / trisPerChunk;
nodes = new(nchunks); nodes = new List<ChunkyTriMeshNode>(nchunks);
this.ntris = ntris; this.ntris = ntris;
// Build tree // Build tree
@ -219,7 +221,7 @@ public class ChunkyTriMesh
public List<ChunkyTriMeshNode> getChunksOverlappingRect(float[] bmin, float[] bmax) public List<ChunkyTriMeshNode> getChunksOverlappingRect(float[] bmin, float[] bmax)
{ {
// Traverse tree // Traverse tree
List<ChunkyTriMeshNode> ids = new(); List<ChunkyTriMeshNode> ids = new List<ChunkyTriMeshNode>();
int i = 0; int i = 0;
while (i < nodes.Count) while (i < nodes.Count)
{ {
@ -244,4 +246,5 @@ public class ChunkyTriMesh
return ids; return ids;
} }
}
} }

View File

@ -1,4 +1,6 @@
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public class ChunkyTriMeshNode public class ChunkyTriMeshNode
{ {
@ -7,3 +9,5 @@ public class ChunkyTriMeshNode
public int i; public int i;
public int[] tris; public int[] tris;
} }
}

View File

@ -18,9 +18,12 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public interface ConvexVolumeProvider public interface ConvexVolumeProvider
{ {
IList<ConvexVolume> convexVolumes(); IList<ConvexVolume> convexVolumes();
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public interface InputGeomProvider : ConvexVolumeProvider public interface InputGeomProvider : ConvexVolumeProvider
{ {
@ -29,4 +31,5 @@ public interface InputGeomProvider : ConvexVolumeProvider
float[] getMeshBoundsMax(); float[] getMeshBoundsMax();
IEnumerable<TriMesh> meshes(); IEnumerable<TriMesh> meshes();
}
} }

View File

@ -22,7 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public class SimpleInputGeomProvider : InputGeomProvider public class SimpleInputGeomProvider : InputGeomProvider
{ {
@ -31,7 +33,7 @@ public class SimpleInputGeomProvider : InputGeomProvider
public readonly float[] normals; public readonly float[] normals;
readonly float[] bmin; readonly float[] bmin;
readonly float[] bmax; readonly float[] bmax;
readonly List<ConvexVolume> volumes = new(); readonly List<ConvexVolume> volumes = new List<ConvexVolume>();
public SimpleInputGeomProvider(List<float> vertexPositions, List<int> meshFaces) public SimpleInputGeomProvider(List<float> vertexPositions, List<int> meshFaces)
: this(mapVertices(vertexPositions), mapFaces(meshFaces)) : this(mapVertices(vertexPositions), mapFaces(meshFaces))
@ -102,8 +104,7 @@ public class SimpleInputGeomProvider : InputGeomProvider
volumes.Add(vol); volumes.Add(vol);
} }
public IEnumerable<TriMesh> meshes() public IEnumerable<TriMesh> meshes() {
{
return ImmutableArray.Create(new TriMesh(vertices, faces)); return ImmutableArray.Create(new TriMesh(vertices, faces));
} }
@ -134,4 +135,5 @@ public class SimpleInputGeomProvider : InputGeomProvider
} }
} }
} }
}
} }

View File

@ -16,16 +16,19 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public class SingleTrimeshInputGeomProvider : InputGeomProvider public class SingleTrimeshInputGeomProvider : InputGeomProvider
{ {
private readonly float[] bmin; private readonly float[] bmin;
private readonly float[] bmax; private readonly float[] bmax;
private readonly ImmutableArray<TriMesh> _meshes; private readonly TriMesh[] _meshes;
public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces) public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces)
{ {
@ -39,7 +42,7 @@ public class SingleTrimeshInputGeomProvider : InputGeomProvider
RecastVectors.max(bmax, vertices, i * 3); RecastVectors.max(bmax, vertices, i * 3);
} }
_meshes = ImmutableArray.Create(new TriMesh(vertices, faces)); _meshes = new[] { new TriMesh(vertices, faces) };
} }
public float[] getMeshBoundsMin() public float[] getMeshBoundsMin()
@ -61,4 +64,5 @@ public class SingleTrimeshInputGeomProvider : InputGeomProvider
{ {
return ImmutableArray<ConvexVolume>.Empty; return ImmutableArray<ConvexVolume>.Empty;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast.Geom; namespace DotRecast.Recast.Geom
{
public class TriMesh public class TriMesh
{ {
@ -49,4 +51,5 @@ public class TriMesh
{ {
return chunkyTriMesh.getChunksOverlappingRect(bmin, bmax); return chunkyTriMesh.getChunksOverlappingRect(bmin, bmax);
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a heightfield layer within a layer set. */ /** Represents a heightfield layer within a layer set. */
public class Heightfield public class Heightfield
@ -58,4 +60,5 @@ public class Heightfield
this.borderSize = borderSize; this.borderSize = borderSize;
spans = new Span[width * height]; spans = new Span[width * height];
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/// Represents a set of heightfield layers. /// Represents a set of heightfield layers.
/// @ingroup recast /// @ingroup recast
@ -75,4 +77,5 @@ public class HeightfieldLayerSet
} }
public HeightfieldLayer[] layers; /// < The layers in the set. [Size: #nlayers] public HeightfieldLayer[] layers; /// < The layers in the set. [Size: #nlayers]
}
} }

View File

@ -1,5 +1,8 @@
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class InputGeomReader public class InputGeomReader
{ {
}
} }

View File

@ -21,14 +21,16 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using DotRecast.Recast.Geom; using DotRecast.Recast.Geom;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public static class ObjImporter public static class ObjImporter
{ {
public class ObjImporterContext public class ObjImporterContext
{ {
public List<float> vertexPositions = new(); public List<float> vertexPositions = new List<float>();
public List<int> meshFaces = new(); public List<int> meshFaces = new List<int>();
} }
public static InputGeomProvider load(byte[] chunck) public static InputGeomProvider load(byte[] chunck)
@ -135,4 +137,5 @@ public static class ObjImporter
return posi; return posi;
} }
}
} }

View File

@ -1,4 +1,6 @@
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/// < Tessellate edges between areas during contour /// < Tessellate edges between areas during contour
/// simplification. /// simplification.
@ -7,4 +9,5 @@ public enum PartitionType
WATERSHED, WATERSHED,
MONOTONE, MONOTONE,
LAYERS LAYERS
}
} }

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a polygon mesh suitable for use in building a navigation mesh. */ /** Represents a polygon mesh suitable for use in building a navigation mesh. */
public class PolyMesh public class PolyMesh
@ -66,4 +68,5 @@ public class PolyMesh
/** The max error of the polygon edges in the mesh. */ /** The max error of the polygon edges in the mesh. */
public float maxEdgeError; public float maxEdgeError;
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** /**
* Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon * Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon
@ -43,4 +45,5 @@ public class PolyMeshDetail
/** The number of triangles in #tris. */ /** The number of triangles in #tris. */
public int ntris; public int ntris;
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -119,4 +121,5 @@ public class Recast
areas[i] = RC_NULL_AREA; areas[i] = RC_NULL_AREA;
} }
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -582,4 +584,5 @@ public class RecastArea
ctx.stopTimer("MARK_CYLINDER_AREA"); ctx.stopTimer("MARK_CYLINDER_AREA");
} }
}
} }

View File

@ -25,7 +25,9 @@ using System.Threading.Tasks;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Recast.Geom; using DotRecast.Recast.Geom;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class RecastBuilder public class RecastBuilder
{ {
@ -52,7 +54,7 @@ public class RecastBuilder
int[] twh = Recast.calcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ); int[] twh = Recast.calcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ);
int tw = twh[0]; int tw = twh[0];
int th = twh[1]; int th = twh[1];
List<RecastBuilderResult> results = new(); List<RecastBuilderResult> results = new List<RecastBuilderResult>();
if (null != taskFactory) if (null != taskFactory)
{ {
buildMultiThreadAsync(geom, cfg, bmin, bmax, tw, th, results, taskFactory, default); buildMultiThreadAsync(geom, cfg, bmin, bmax, tw, th, results, taskFactory, default);
@ -104,7 +106,7 @@ public class RecastBuilder
{ {
AtomicInteger counter = new AtomicInteger(0); AtomicInteger counter = new AtomicInteger(0);
CountdownEvent latch = new CountdownEvent(tw * th); CountdownEvent latch = new CountdownEvent(tw * th);
List<Task> tasks = new(); List<Task> tasks = new List<Task>();
for (int x = 0; x < tw; ++x) for (int x = 0; x < tw; ++x)
{ {
@ -317,4 +319,5 @@ public class RecastBuilder
CompactHeightfield chf = buildCompactHeightfield(geom, builderCfg.cfg, ctx, solid); CompactHeightfield chf = buildCompactHeightfield(geom, builderCfg.cfg, ctx, solid);
return RecastLayers.buildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight); return RecastLayers.buildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight);
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastVectors; using static RecastVectors;
@ -97,4 +99,5 @@ public class RecastBuilderConfig
height = wh[1]; height = wh[1];
} }
} }
}
} }

View File

@ -1,4 +1,6 @@
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class RecastBuilderResult public class RecastBuilderResult
{ {
@ -54,3 +56,5 @@ public class RecastBuilderResult
return telemetry; return telemetry;
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class RecastCommon public class RecastCommon
{ {
@ -82,4 +84,5 @@ public class RecastCommon
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
using static RecastVectors; using static RecastVectors;
@ -183,4 +185,5 @@ public class RecastCompact
return spanCount; return spanCount;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -183,4 +185,5 @@ public class RecastConfig
{ {
return 3 + (int)Math.Ceiling(agentRadius / cs); return 3 + (int)Math.Ceiling(agentRadius / cs);
} }
}
} }

View File

@ -18,7 +18,9 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public static class RecastConstants public static class RecastConstants
{ {
@ -82,4 +84,5 @@ public static class RecastConstants
public const int RC_LOG_WARNING = 1; public const int RC_LOG_WARNING = 1;
}
} }

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -842,8 +844,8 @@ public class RecastContour
ctx.stopTimer("CONTOURS_TRACE"); ctx.stopTimer("CONTOURS_TRACE");
List<int> verts = new(256); List<int> verts = new List<int>(256);
List<int> simplified = new(64); List<int> simplified = new List<int>(64);
for (int y = 0; y < h; ++y) for (int y = 0; y < h; ++y)
{ {
@ -1017,4 +1019,5 @@ public class RecastContour
ctx.stopTimer("CONTOURS"); ctx.stopTimer("CONTOURS");
return cset; return cset;
} }
}
} }

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
using static RecastVectors; using static RecastVectors;
@ -799,4 +801,5 @@ public class RecastFilledVolumeRasterization
overlap = (amin[2] > bounds[5] || amax[2] < bounds[2]) ? false : overlap; overlap = (amin[2] > bounds[5] || amax[2] < bounds[2]) ? false : overlap;
return overlap; return overlap;
} }
}
} }

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -202,4 +204,5 @@ public class RecastFilter
ctx.stopTimer("FILTER_WALKABLE"); ctx.stopTimer("FILTER_WALKABLE");
} }
}
} }

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastCommon; using static RecastCommon;
using static RecastConstants; using static RecastConstants;
@ -45,8 +47,8 @@ public class RecastLayers {
id = i; id = i;
ymin = 0xFFFF; ymin = 0xFFFF;
layerId = 0xff; layerId = 0xff;
layers = new(); layers = new List<int>();
neis = new(); neis = new List<int>();
} }
}; };
@ -174,7 +176,7 @@ public class RecastLayers {
} }
// Find region neighbours and overlapping regions. // Find region neighbours and overlapping regions.
List<int> lregs = new(); List<int> lregs = new List<int>();
for (int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) { for (int x = 0; x < w; ++x) {
CompactCell c = chf.cells[x + y * w]; CompactCell c = chf.cells[x + y * w];
@ -225,7 +227,7 @@ public class RecastLayers {
// Create 2D layers from regions. // Create 2D layers from regions.
int layerId = 0; int layerId = 0;
List<int> stack = new(); List<int> stack = new List<int>();
for (int i = 0; i < nregs; ++i) { for (int i = 0; i < nregs; ++i) {
LayerRegion root = regs[i]; LayerRegion root = regs[i];
@ -505,3 +507,5 @@ public class RecastLayers {
return lset; return lset;
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -1212,3 +1214,5 @@ public class RecastMesh {
return dst; return dst;
} }
} }
}

View File

@ -22,7 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastCommon; using static RecastCommon;
using static RecastConstants; using static RecastConstants;
@ -454,7 +456,7 @@ public class RecastMeshDetail {
private static void delaunayHull(Telemetry ctx, int npts, float[] pts, int nhull, int[] hull, List<int> tris) { private static void delaunayHull(Telemetry ctx, int npts, float[] pts, int nhull, int[] hull, List<int> tris) {
int nfaces = 0; int nfaces = 0;
int maxEdges = npts * 10; int maxEdges = npts * 10;
List<int> edges = new(64); List<int> edges = new List<int>(64);
for (int i = 0, j = nhull - 1; i < nhull; j = i++) { for (int i = 0, j = nhull - 1; i < nhull; j = i++) {
addEdge(ctx, edges, maxEdges, hull[j], hull[i], EV_HULL, EV_UNDEF); addEdge(ctx, edges, maxEdges, hull[j], hull[i], EV_HULL, EV_UNDEF);
} }
@ -618,7 +620,7 @@ public class RecastMeshDetail {
static int buildPolyDetail(Telemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError, static int buildPolyDetail(Telemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError,
int heightSearchRadius, CompactHeightfield chf, HeightPatch hp, float[] verts, List<int> tris) { int heightSearchRadius, CompactHeightfield chf, HeightPatch hp, float[] verts, List<int> tris) {
List<int> samples = new(512); List<int> samples = new List<int>(512);
int nverts = 0; int nverts = 0;
float[] edge = new float[(MAX_VERTS_PER_EDGE + 1) * 3]; float[] edge = new float[(MAX_VERTS_PER_EDGE + 1) * 3];
@ -988,7 +990,7 @@ public class RecastMeshDetail {
// Note: Reads to the compact heightfield are offset by border size (bs) // Note: Reads to the compact heightfield are offset by border size (bs)
// since border size offset is already removed from the polymesh vertices. // since border size offset is already removed from the polymesh vertices.
List<int> queue = new(512); List<int> queue = new List<int>(512);
Array.Fill(hp.data, RC_UNSET_HEIGHT, 0, (hp.width * hp.height) - (0)); Array.Fill(hp.data, RC_UNSET_HEIGHT, 0, (hp.width * hp.height) - (0));
bool empty = true; bool empty = true;
@ -1127,7 +1129,7 @@ public class RecastMeshDetail {
int borderSize = mesh.borderSize; int borderSize = mesh.borderSize;
int heightSearchRadius = (int) Math.Max(1, Math.Ceiling(mesh.maxEdgeError)); int heightSearchRadius = (int) Math.Max(1, Math.Ceiling(mesh.maxEdgeError));
List<int> tris = new(512); List<int> tris = new List<int>(512);
float[] verts = new float[256 * 3]; float[] verts = new float[256 * 3];
HeightPatch hp = new HeightPatch(); HeightPatch hp = new HeightPatch();
int nPolyVerts = 0; int nPolyVerts = 0;
@ -1333,3 +1335,5 @@ public class RecastMeshDetail {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -481,4 +483,5 @@ public class RecastRasterization
ctx.stopTimer("RASTERIZE_TRIANGLES"); ctx.stopTimer("RASTERIZE_TRIANGLES");
} }
}
} }

View File

@ -22,7 +22,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
using static RecastConstants; using static RecastConstants;
@ -360,7 +362,7 @@ public class RecastRegion {
} }
} }
List<int> dirtyEntries = new(); List<int> dirtyEntries = new List<int>();
int iter = 0; int iter = 0;
while (stack.Count > 0) { while (stack.Count > 0) {
int failed = 0; int failed = 0;
@ -493,8 +495,8 @@ public class RecastRegion {
public Region(int i) { public Region(int i) {
id = i; id = i;
ymin = 0xFFFF; ymin = 0xFFFF;
connections = new(); connections = new List<int>();
floors = new(); floors = new List<int>();
} }
} }
@ -563,7 +565,7 @@ public class RecastRegion {
int bid = regb.id; int bid = regb.id;
// Duplicate current neighbourhood. // Duplicate current neighbourhood.
List<int> acon = new(rega.connections); List<int> acon = new List<int>(rega.connections);
List<int> bcon = regb.connections; List<int> bcon = regb.connections;
// Find insertion point on A. // Find insertion point on A.
@ -770,8 +772,8 @@ public class RecastRegion {
} }
// Remove too small regions. // Remove too small regions.
List<int> stack = new(32); List<int> stack = new List<int>(32);
List<int> trace = new(32); List<int> trace = new List<int>(32);
for (int i = 0; i < nreg; ++i) { for (int i = 0; i < nreg; ++i) {
Region reg = regions[i]; Region reg = regions[i];
if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0) { if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0) {
@ -966,7 +968,7 @@ public class RecastRegion {
} }
// Find region neighbours and overlapping regions. // Find region neighbours and overlapping regions.
List<int> lregs = new(32); List<int> lregs = new List<int>(32);
for (int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) { for (int x = 0; x < w; ++x) {
CompactCell c = chf.cells[x + y * w]; CompactCell c = chf.cells[x + y * w];
@ -1029,7 +1031,7 @@ public class RecastRegion {
} }
// Merge montone regions to create non-overlapping areas. // Merge montone regions to create non-overlapping areas.
List<int> stack = new(32); List<int> stack = new List<int>(32);
for (int i = 1; i < nreg; ++i) { for (int i = 1; i < nreg; ++i) {
Region root = regions[i]; Region root = regions[i];
// Skip already visited. // Skip already visited.
@ -1333,7 +1335,7 @@ public class RecastRegion {
ctx.startTimer("REGIONS_FILTER"); ctx.startTimer("REGIONS_FILTER");
// Merge regions and filter out small regions. // Merge regions and filter out small regions.
List<int> overlaps = new(); List<int> overlaps = new List<int>();
chf.maxRegions = mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, id, chf, srcReg, overlaps); chf.maxRegions = mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, id, chf, srcReg, overlaps);
// Monotone partitioning does not generate overlapping regions. // Monotone partitioning does not generate overlapping regions.
@ -1380,12 +1382,12 @@ public class RecastRegion {
int LOG_NB_STACKS = 3; int LOG_NB_STACKS = 3;
int NB_STACKS = 1 << LOG_NB_STACKS; int NB_STACKS = 1 << LOG_NB_STACKS;
List<List<int>> lvlStacks = new(); List<List<int>> lvlStacks = new List<List<int>>();
for (int i = 0; i < NB_STACKS; ++i) { for (int i = 0; i < NB_STACKS; ++i) {
lvlStacks.Add(new (1024)); lvlStacks.Add(new List<int>(1024));
} }
List<int> stack = new(1024); List<int> stack = new List<int>(1024);
int[] srcReg = new int[chf.spanCount]; int[] srcReg = new int[chf.spanCount];
int[] srcDist = new int[chf.spanCount]; int[] srcDist = new int[chf.spanCount];
@ -1464,7 +1466,7 @@ public class RecastRegion {
ctx.startTimer("REGIONS_FILTER"); ctx.startTimer("REGIONS_FILTER");
// Merge regions and filter out smalle regions. // Merge regions and filter out smalle regions.
List<int> overlaps = new(); List<int> overlaps = new List<int>();
chf.maxRegions = mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, regionId, chf, srcReg, overlaps); chf.maxRegions = mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, regionId, chf, srcReg, overlaps);
// If overlapping regions were found during merging, split those regions. // If overlapping regions were found during merging, split those regions.
@ -1603,7 +1605,7 @@ public class RecastRegion {
ctx.startTimer("REGIONS_FILTER"); ctx.startTimer("REGIONS_FILTER");
// Merge monotone regions to layers and remove small regions. // Merge monotone regions to layers and remove small regions.
List<int> overlaps = new(); List<int> overlaps = new List<int>();
chf.maxRegions = mergeAndFilterLayerRegions(ctx, minRegionArea, id, chf, srcReg, overlaps); chf.maxRegions = mergeAndFilterLayerRegions(ctx, minRegionArea, id, chf, srcReg, overlaps);
ctx.stopTimer("REGIONS_FILTER"); ctx.stopTimer("REGIONS_FILTER");
@ -1617,3 +1619,5 @@ public class RecastRegion {
} }
} }
}

View File

@ -20,7 +20,9 @@ freely, subject to the following restrictions:
using System; using System;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public static class RecastVectors public static class RecastVectors
{ {
@ -95,4 +97,5 @@ public static class RecastVectors
{ {
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
} }
}
} }

View File

@ -19,7 +19,9 @@ freely, subject to the following restrictions:
using System.Collections.Generic; using System.Collections.Generic;
using DotRecast.Recast.Geom; using DotRecast.Recast.Geom;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class RecastVoxelization { public class RecastVoxelization {
@ -71,3 +73,5 @@ public class RecastVoxelization {
} }
} }
}

View File

@ -17,7 +17,9 @@ freely, subject to the following restrictions:
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
namespace DotRecast.Recast; namespace DotRecast.Recast
{
/** Represents a span in a heightfield. */ /** Represents a span in a heightfield. */
public class Span { public class Span {
@ -32,3 +34,5 @@ public class Span {
public Span next; public Span next;
} }
}

View File

@ -23,12 +23,14 @@ using System.Diagnostics;
using System.Threading; using System.Threading;
using DotRecast.Core; using DotRecast.Core;
namespace DotRecast.Recast; namespace DotRecast.Recast
{
public class Telemetry public class Telemetry
{ {
private readonly ThreadLocal<Dictionary<string, AtomicLong>> timerStart = new(() => new Dictionary<string, AtomicLong>()); private readonly ThreadLocal<Dictionary<string, AtomicLong>> timerStart = new ThreadLocal<Dictionary<string, AtomicLong>>(() => new Dictionary<string, AtomicLong>());
private readonly ConcurrentDictionary<string, AtomicLong> timerAccum = new(); private readonly ConcurrentDictionary<string, AtomicLong> timerAccum = new ConcurrentDictionary<string, AtomicLong>();
public void startTimer(string name) public void startTimer(string name)
{ {
@ -54,4 +56,5 @@ public class Telemetry
Console.WriteLine(n + ": " + v.Read() / 1000000); Console.WriteLine(n + ": " + v.Read() / 1000000);
} }
} }
}
} }

View File

@ -345,10 +345,10 @@ public class Crowd4Test : AbstractCrowdTest {
setMoveTarget(endPoss[0], false); setMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q2T.Length; i++) for (int i = 0; i < EXPECTED_A1Q2T.Length; i++)
{ {
if (i == 37) // if (i == 37)
{ // {
int a = 3; // int a = 3;
} // }
crowd.update(1 / 5f, null); crowd.update(1 / 5f, null);
CrowdAgent ag = agents[2]; CrowdAgent ag = agents[2];

View File

@ -67,7 +67,7 @@ public class FindNearestPolyTest : AbstractDetourTest {
float[] startPos = startPoss[i]; float[] startPos = startPoss[i];
Result<FindNearestPolyResult> poly = query.findNearestPoly(startPos, extents, filter); Result<FindNearestPolyResult> poly = query.findNearestPoly(startPos, extents, filter);
Assert.That(poly.succeeded(), Is.True); Assert.That(poly.succeeded(), Is.True);
Assert.That(0L, Is.EqualTo(poly.result.getNearestRef())); Assert.That(poly.result.getNearestRef(), Is.EqualTo(0L));
for (int v = 0; v < POLY_POS[i].Length; v++) { for (int v = 0; v < POLY_POS[i].Length; v++) {
Assert.That(poly.result.getNearestPos()[v], Is.EqualTo(startPos[v]).Within(0.001f)); Assert.That(poly.result.getNearestPos()[v], Is.EqualTo(startPos[v]).Within(0.001f));
} }

View File

@ -300,6 +300,7 @@ public class RecastSoloMeshTest
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
} }
} }
@ -332,6 +333,7 @@ public class RecastSoloMeshTest
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
} }
} }
} }

View File

@ -157,6 +157,7 @@ public class RecastTileMeshTest
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e);
} }
} }