C# style interface naming

This commit is contained in:
ikpil 2023-05-05 09:06:43 +09:00
parent ded8f33ac1
commit 9da140feac
91 changed files with 221 additions and 247 deletions

View File

@ -149,7 +149,7 @@ namespace DotRecast.Detour.Crowd
private readonly ObstacleAvoidanceQuery _obstacleQuery;
private ProximityGrid _grid;
private readonly Vector3f _ext = new Vector3f();
private readonly QueryFilter[] _filters = new QueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE];
private readonly IQueryFilter[] _filters = new IQueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE];
private NavMeshQuery _navQuery;
private NavMesh _navMesh;
private readonly CrowdConfig _config;
@ -161,7 +161,7 @@ namespace DotRecast.Detour.Crowd
{
}
public Crowd(CrowdConfig config, NavMesh nav, Func<int, QueryFilter> queryFilterFactory)
public Crowd(CrowdConfig config, NavMesh nav, Func<int, IQueryFilter> queryFilterFactory)
{
_config = config;
VSet(ref _ext, config.maxAgentRadius * 2.0f, config.maxAgentRadius * 1.5f, config.maxAgentRadius * 2.0f);
@ -364,7 +364,7 @@ namespace DotRecast.Detour.Crowd
return _ext;
}
public QueryFilter GetFilter(int i)
public IQueryFilter GetFilter(int i)
{
return i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE ? _filters[i] : null;
}

View File

@ -98,7 +98,7 @@ namespace DotRecast.Detour.Crowd
}
}
public void Update(long refs, Vector3f pos, float collisionQueryRange, NavMeshQuery navquery, QueryFilter filter)
public void Update(long refs, Vector3f pos, float collisionQueryRange, NavMeshQuery navquery, IQueryFilter filter)
{
if (refs == 0)
{
@ -138,7 +138,7 @@ namespace DotRecast.Detour.Crowd
}
}
public bool IsValid(NavMeshQuery navquery, QueryFilter filter)
public bool IsValid(NavMeshQuery navquery, IQueryFilter filter)
{
if (m_polys.Count == 0)
{

View File

@ -234,7 +234,7 @@ namespace DotRecast.Detour.Crowd
* @param[in] navquery The query object used to build the corridor.
* @return Corners
*/
public List<StraightPathItem> FindCorners(int maxCorners, NavMeshQuery navquery, QueryFilter filter)
public List<StraightPathItem> FindCorners(int maxCorners, NavMeshQuery navquery, IQueryFilter filter)
{
List<StraightPathItem> path = new List<StraightPathItem>();
Result<List<StraightPathItem>> result = navquery.FindStraightPath(m_pos, m_target, m_path, maxCorners, 0);
@ -299,7 +299,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public void OptimizePathVisibility(Vector3f next, float pathOptimizationRange, NavMeshQuery navquery, QueryFilter filter)
public void OptimizePathVisibility(Vector3f next, float pathOptimizationRange, NavMeshQuery navquery, IQueryFilter filter)
{
// Clamp the ray to max distance.
float dist = VDist2D(m_pos, next);
@ -344,7 +344,7 @@ namespace DotRecast.Detour.Crowd
* The filter to apply to the operation.
*
*/
public bool OptimizePathTopology(NavMeshQuery navquery, QueryFilter filter, int maxIterations)
public bool OptimizePathTopology(NavMeshQuery navquery, IQueryFilter filter, int maxIterations)
{
if (m_path.Count < 3)
{
@ -423,7 +423,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public bool MovePosition(Vector3f npos, NavMeshQuery navquery, QueryFilter filter)
public bool MovePosition(Vector3f npos, NavMeshQuery navquery, IQueryFilter filter)
{
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter);
@ -461,7 +461,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public bool MoveTargetPosition(Vector3f npos, NavMeshQuery navquery, QueryFilter filter)
public bool MoveTargetPosition(Vector3f npos, NavMeshQuery navquery, IQueryFilter filter)
{
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter);
@ -516,7 +516,7 @@ namespace DotRecast.Detour.Crowd
}
}
public void TrimInvalidPath(long safeRef, float[] safePos, NavMeshQuery navquery, QueryFilter filter)
public void TrimInvalidPath(long safeRef, float[] safePos, NavMeshQuery navquery, IQueryFilter filter)
{
// Keep valid path as far as possible.
int n = 0;
@ -559,7 +559,7 @@ namespace DotRecast.Detour.Crowd
* The filter to apply to the operation.
* @return
*/
public bool IsValid(int maxLookAhead, NavMeshQuery navquery, QueryFilter filter)
public bool IsValid(int maxLookAhead, NavMeshQuery navquery, IQueryFilter filter)
{
// Check that all polygons still pass query filter.
int n = Math.Min(m_path.Count, maxLookAhead);

View File

@ -30,7 +30,7 @@ namespace DotRecast.Detour.Crowd
public Vector3f endPos = new Vector3f();
public long startRef;
public long endRef;
public QueryFilter filter;
public IQueryFilter filter;
/// < TODO: This is potentially dangerous!
public readonly PathQueryResult result = new PathQueryResult();

View File

@ -79,7 +79,7 @@ namespace DotRecast.Detour.Crowd
}
}
public PathQueryResult Request(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter)
public PathQueryResult Request(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
{
if (queue.Count >= config.pathQueueSize)
{

View File

@ -21,13 +21,13 @@ using DotRecast.Detour.Dynamic.Colliders;
namespace DotRecast.Detour.Dynamic
{
public class AddColliderQueueItem : UpdateQueueItem
public class AddColliderQueueItem : IUpdateQueueItem
{
private readonly long colliderId;
private readonly Collider collider;
private readonly ICollider collider;
private readonly ICollection<DynamicTile> _affectedTiles;
public AddColliderQueueItem(long colliderId, Collider collider, ICollection<DynamicTile> affectedTiles)
public AddColliderQueueItem(long colliderId, ICollider collider, ICollection<DynamicTile> affectedTiles)
{
this.colliderId = colliderId;
this.collider = collider;

View File

@ -20,7 +20,7 @@ using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders
{
public abstract class AbstractCollider : Collider
public abstract class AbstractCollider : ICollider
{
protected readonly int area;
protected readonly float flagMergeThreshold;

View File

@ -23,18 +23,18 @@ using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders
{
public class CompositeCollider : Collider
public class CompositeCollider : ICollider
{
private readonly List<Collider> colliders;
private readonly List<ICollider> colliders;
private readonly float[] _bounds;
public CompositeCollider(List<Collider> colliders)
public CompositeCollider(List<ICollider> colliders)
{
this.colliders = colliders;
_bounds = Bounds(colliders);
}
public CompositeCollider(params Collider[] colliders)
public CompositeCollider(params ICollider[] colliders)
{
this.colliders = colliders.ToList();
_bounds = Bounds(this.colliders);
@ -45,14 +45,14 @@ namespace DotRecast.Detour.Dynamic.Colliders
return _bounds;
}
private static float[] Bounds(List<Collider> colliders)
private static float[] Bounds(List<ICollider> colliders)
{
float[] bounds = new float[]
{
float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity,
float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity
};
foreach (Collider collider in colliders)
foreach (ICollider collider in colliders)
{
float[] b = collider.Bounds();
bounds[0] = Math.Min(bounds[0], b[0]);

View File

@ -20,7 +20,7 @@ using DotRecast.Recast;
namespace DotRecast.Detour.Dynamic.Colliders
{
public interface Collider
public interface ICollider
{
float[] Bounds();
void Rasterize(Heightfield hf, Telemetry telemetry);

View File

@ -6,12 +6,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5"/>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj"/>
<ProjectReference Include="..\DotRecast.Recast\DotRecast.Recast.csproj"/>
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
<ProjectReference Include="..\DotRecast.Recast\DotRecast.Recast.csproj" />
</ItemGroup>
</Project>

View File

@ -37,7 +37,7 @@ namespace DotRecast.Detour.Dynamic
private readonly Dictionary<long, DynamicTile> _tiles = new Dictionary<long, DynamicTile>();
private readonly Telemetry telemetry;
private readonly NavMeshParams navMeshParams;
private readonly BlockingCollection<UpdateQueueItem> updateQueue = new BlockingCollection<UpdateQueueItem>();
private readonly BlockingCollection<IUpdateQueueItem> updateQueue = new BlockingCollection<IUpdateQueueItem>();
private readonly AtomicLong currentColliderId = new AtomicLong(0);
private NavMesh _navMesh;
private bool dirty = true;
@ -93,7 +93,7 @@ namespace DotRecast.Detour.Dynamic
return GetTileAt(x, z)?.checkpoint.heightfield;
}
public long AddCollider(Collider collider)
public long AddCollider(ICollider collider)
{
long cid = currentColliderId.IncrementAndGet();
updateQueue.Add(new AddColliderQueueItem(cid, collider, GetTiles(collider.Bounds())));
@ -140,9 +140,9 @@ namespace DotRecast.Detour.Dynamic
return items.SelectMany(i => i.AffectedTiles()).ToHashSet();
}
private List<UpdateQueueItem> ConsumeQueue()
private List<IUpdateQueueItem> ConsumeQueue()
{
List<UpdateQueueItem> items = new List<UpdateQueueItem>();
List<IUpdateQueueItem> items = new List<IUpdateQueueItem>();
while (updateQueue.TryTake(out var item))
{
items.Add(item);
@ -151,7 +151,7 @@ namespace DotRecast.Detour.Dynamic
return items;
}
private void Process(UpdateQueueItem item)
private void Process(IUpdateQueueItem item)
{
foreach (var tile in item.AffectedTiles())
{

View File

@ -33,7 +33,7 @@ namespace DotRecast.Detour.Dynamic
public DynamicTileCheckpoint checkpoint;
public RecastBuilderResult recastResult;
MeshData meshData;
private readonly ConcurrentDictionary<long, Collider> colliders = new ConcurrentDictionary<long, Collider>();
private readonly ConcurrentDictionary<long, ICollider> colliders = new ConcurrentDictionary<long, ICollider>();
private bool dirty = true;
private long id;
@ -96,7 +96,7 @@ namespace DotRecast.Detour.Dynamic
return r;
}
public void AddCollider(long cid, Collider collider)
public void AddCollider(long cid, ICollider collider)
{
colliders[cid] = collider;
dirty = true;

View File

@ -20,7 +20,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Dynamic
{
public interface UpdateQueueItem
public interface IUpdateQueueItem
{
ICollection<DynamicTile> AffectedTiles();

View File

@ -20,7 +20,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Dynamic
{
public class RemoveColliderQueueItem : UpdateQueueItem
public class RemoveColliderQueueItem : IUpdateQueueItem
{
private readonly long colliderId;
private readonly ICollection<DynamicTile> _affectedTiles;

View File

@ -5,7 +5,7 @@ using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras.Jumplink
{
public abstract class AbstractGroundSampler : GroundSampler
public abstract class AbstractGroundSampler : IGroundSampler
{
protected void SampleGround(JumpLinkBuilderConfig acfg, EdgeSampler es,
Func<Vector3f, float, Tuple<bool, float>> heightFunc)

View File

@ -2,7 +2,7 @@ using DotRecast.Recast;
namespace DotRecast.Detour.Extras.Jumplink
{
public interface GroundSampler
public interface IGroundSampler
{
void Sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es);
}

View File

@ -11,7 +11,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{
private readonly EdgeExtractor edgeExtractor = new EdgeExtractor();
private readonly EdgeSamplerFactory edgeSamplerFactory = new EdgeSamplerFactory();
private readonly GroundSampler groundSampler = new NavMeshGroundSampler();
private readonly IGroundSampler groundSampler = new NavMeshGroundSampler();
private readonly TrajectorySampler trajectorySampler = new TrajectorySampler();
private readonly JumpSegmentBuilder jumpSegmentBuilder = new JumpSegmentBuilder();

View File

@ -7,9 +7,9 @@ namespace DotRecast.Detour.Extras.Jumplink
{
class NavMeshGroundSampler : AbstractGroundSampler
{
private readonly QueryFilter filter = new NoOpFilter();
private readonly IQueryFilter filter = new NoOpFilter();
private class NoOpFilter : QueryFilter
private class NoOpFilter : IQueryFilter
{
public bool PassFilter(long refs, MeshTile tile, Poly poly)
{
@ -55,7 +55,7 @@ namespace DotRecast.Detour.Extras.Jumplink
return new NavMeshQuery(new NavMesh(NavMeshBuilder.CreateNavMeshData(option), option.nvp, 0));
}
public class PolyQueryInvoker : PolyQuery
public class PolyQueryInvoker : IPolyQuery
{
public readonly Action<MeshTile, Poly, long> _callback;

View File

@ -6,11 +6,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5"/>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj"/>
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
</ItemGroup>
</Project>

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public interface TileCacheCompressor
public interface ITileCacheCompressor
{
byte[] Decompress(byte[] buf, int offset, int len, int outputlen);

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public interface TileCacheMeshProcess
public interface ITileCacheMeshProcess
{
void Process(NavMeshDataCreateParams option);
}

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache.Io.Compress
{
public class FastLzTileCacheCompressor : TileCacheCompressor
public class FastLzTileCacheCompressor : ITileCacheCompressor
{
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
{

View File

@ -22,7 +22,7 @@ using K4os.Compression.LZ4;
namespace DotRecast.Detour.TileCache.Io.Compress
{
public class LZ4TileCacheCompressor : TileCacheCompressor
public class LZ4TileCacheCompressor : ITileCacheCompressor
{
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
{

View File

@ -22,7 +22,7 @@ namespace DotRecast.Detour.TileCache.Io.Compress
{
public static class TileCacheCompressorFactory
{
public static TileCacheCompressor Get(bool cCompatibility)
public static ITileCacheCompressor Get(bool cCompatibility)
{
if (cCompatibility)
return new FastLzTileCacheCompressor();

View File

@ -29,13 +29,13 @@ namespace DotRecast.Detour.TileCache.Io
{
private readonly NavMeshParamReader paramReader = new NavMeshParamReader();
public TileCache Read(BinaryReader @is, int maxVertPerPoly, TileCacheMeshProcess meshProcessor)
public TileCache Read(BinaryReader @is, int maxVertPerPoly, ITileCacheMeshProcess meshProcessor)
{
ByteBuffer bb = IOUtils.ToByteBuffer(@is);
return Read(bb, maxVertPerPoly, meshProcessor);
}
public TileCache Read(ByteBuffer bb, int maxVertPerPoly, TileCacheMeshProcess meshProcessor)
public TileCache Read(ByteBuffer bb, int maxVertPerPoly, ITileCacheMeshProcess meshProcessor)
{
TileCacheSetHeader header = new TileCacheSetHeader();
header.magic = bb.GetInt();
@ -64,7 +64,7 @@ namespace DotRecast.Detour.TileCache.Io
header.meshParams = paramReader.Read(bb);
header.cacheParams = ReadCacheParams(bb, cCompatibility);
NavMesh mesh = new NavMesh(header.meshParams, maxVertPerPoly);
TileCacheCompressor compressor = TileCacheCompressorFactory.Get(cCompatibility);
ITileCacheCompressor compressor = TileCacheCompressorFactory.Get(cCompatibility);
TileCache tc = new TileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh,
compressor, meshProcessor);
// Read tiles.

View File

@ -54,8 +54,8 @@ namespace DotRecast.Detour.TileCache
private readonly TileCacheParams m_params;
private readonly TileCacheStorageParams m_storageParams;
private readonly TileCacheCompressor m_tcomp;
private readonly TileCacheMeshProcess m_tmproc;
private readonly ITileCacheCompressor m_tcomp;
private readonly ITileCacheMeshProcess m_tmproc;
private readonly List<TileCacheObstacle> m_obstacles = new List<TileCacheObstacle>();
private TileCacheObstacle m_nextFreeObstacle;
@ -112,7 +112,7 @@ namespace DotRecast.Detour.TileCache
}
public TileCache(TileCacheParams option, TileCacheStorageParams storageParams, NavMesh navmesh,
TileCacheCompressor tcomp, TileCacheMeshProcess tmprocs)
ITileCacheCompressor tcomp, ITileCacheMeshProcess tmprocs)
{
m_params = option;
m_storageParams = storageParams;
@ -726,7 +726,7 @@ namespace DotRecast.Detour.TileCache
return m_params;
}
public TileCacheCompressor GetCompressor()
public ITileCacheCompressor GetCompressor()
{
return m_tcomp;
}

View File

@ -2014,7 +2014,7 @@ namespace DotRecast.Detour.TileCache
}
}
public TileCacheLayer DecompressTileCacheLayer(TileCacheCompressor comp, byte[] compressed, ByteOrder order,
public TileCacheLayer DecompressTileCacheLayer(ITileCacheCompressor comp, byte[] compressed, ByteOrder order,
bool cCompatibility)
{
ByteBuffer buf = new ByteBuffer(compressed);

View File

@ -50,7 +50,7 @@ namespace DotRecast.Detour
*
* @see NavMeshQuery
*/
public class DefaultQueryFilter : QueryFilter
public class DefaultQueryFilter : IQueryFilter
{
private int m_excludeFlags;
private int m_includeFlags;

View File

@ -22,7 +22,7 @@ using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour
{
public class DefaultQueryHeuristic : QueryHeuristic
public class DefaultQueryHeuristic : IQueryHeuristic
{
private readonly float scale;

View File

@ -6,7 +6,7 @@ namespace DotRecast.Detour
{
using static DotRecast.Core.RecastMath;
public class FindNearestPolyQuery : PolyQuery
public class FindNearestPolyQuery : IPolyQuery
{
private readonly NavMeshQuery query;
private readonly Vector3f center;

View File

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

View File

@ -23,21 +23,21 @@ namespace DotRecast.Detour
{
using static DotRecast.Core.RecastMath;
public interface PolygonByCircleConstraint
public interface IPolygonByCircleConstraint
{
float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius);
public static PolygonByCircleConstraint Noop()
public static IPolygonByCircleConstraint Noop()
{
return new NoOpPolygonByCircleConstraint();
}
public static PolygonByCircleConstraint Strict()
public static IPolygonByCircleConstraint Strict()
{
return new StrictPolygonByCircleConstraint();
}
public class NoOpPolygonByCircleConstraint : PolygonByCircleConstraint
public class NoOpPolygonByCircleConstraint : IPolygonByCircleConstraint
{
public float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius)
{
@ -48,7 +48,7 @@ namespace DotRecast.Detour
/**
* Calculate the intersection between a polygon and a circle. A dodecagon is used as an approximation of the circle.
*/
public class StrictPolygonByCircleConstraint : PolygonByCircleConstraint
public class StrictPolygonByCircleConstraint : IPolygonByCircleConstraint
{
private const int CIRCLE_SEGMENTS = 12;
private static float[] unitCircle;

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public interface QueryFilter
public interface IQueryFilter
{
bool PassFilter(long refs, MeshTile tile, Poly poly);

View File

@ -20,7 +20,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public interface QueryHeuristic
public interface IQueryHeuristic
{
float GetCost(Vector3f neighbourPos, Vector3f endPos);
}

View File

@ -34,13 +34,13 @@ namespace DotRecast.Detour
{
}
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
int options, float raycastLimit)
{
return FindPath(startRef, endRef, startPos, endPos, filter);
}
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter)
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter)
@ -645,7 +645,7 @@ namespace DotRecast.Detour
return Results.Of(status, path);
}
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, QueryFilter filter)
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, IQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0

View File

@ -83,7 +83,7 @@ namespace DotRecast.Detour
* Function returning a random number [0..1).
* @return Random location
*/
public Result<FindRandomPointResult> FindRandomPoint(QueryFilter filter, FRand frand)
public Result<FindRandomPointResult> FindRandomPoint(IQueryFilter filter, FRand frand)
{
// Randomly pick one tile. Assume that all tiles cover roughly the same area.
if (null == filter || null == frand)
@ -197,9 +197,9 @@ namespace DotRecast.Detour
* @return Random location
*/
public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius,
QueryFilter filter, FRand frand)
IQueryFilter filter, FRand frand)
{
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, PolygonByCircleConstraint.Noop());
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Noop());
}
/**
@ -218,13 +218,13 @@ namespace DotRecast.Detour
* @return Random location
*/
public Result<FindRandomPointResult> FindRandomPointWithinCircle(long startRef, Vector3f centerPos, float maxRadius,
QueryFilter filter, FRand frand)
IQueryFilter filter, FRand frand)
{
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, PolygonByCircleConstraint.Strict());
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Strict());
}
public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius,
QueryFilter filter, FRand frand, PolygonByCircleConstraint constraint)
IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0
@ -561,7 +561,7 @@ namespace DotRecast.Detour
* The polygon filter to apply to the query.
* @return FindNearestPolyResult containing nearestRef, nearestPt and overPoly
*/
public Result<FindNearestPolyResult> FindNearestPoly(Vector3f center, Vector3f halfExtents, QueryFilter filter)
public Result<FindNearestPolyResult> FindNearestPoly(Vector3f center, Vector3f halfExtents, IQueryFilter filter)
{
// Get nearby polygons from proximity grid.
FindNearestPolyQuery query = new FindNearestPolyQuery(this, center);
@ -575,7 +575,7 @@ namespace DotRecast.Detour
}
// FIXME: (PP) duplicate?
protected void QueryPolygonsInTile(MeshTile tile, Vector3f qmin, Vector3f qmax, QueryFilter filter, PolyQuery query)
protected void QueryPolygonsInTile(MeshTile tile, Vector3f qmin, Vector3f qmax, IQueryFilter filter, IPolyQuery query)
{
if (tile.data.bvTree != null)
{
@ -682,7 +682,7 @@ namespace DotRecast.Detour
* The polygon filter to apply to the query.
* @return The reference ids of the polygons that overlap the query box.
*/
public Status QueryPolygons(Vector3f center, Vector3f halfExtents, QueryFilter filter, PolyQuery query)
public Status QueryPolygons(Vector3f center, Vector3f halfExtents, IQueryFilter filter, IPolyQuery query)
{
if (!VIsFinite(center) || !VIsFinite(halfExtents) || null == filter)
{
@ -750,19 +750,19 @@ namespace DotRecast.Detour
* The polygon filter to apply to the query.
* @return Found path
*/
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter)
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
{
return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), 0, 0);
}
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
int options, float raycastLimit)
{
return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), options, raycastLimit);
}
public Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
QueryHeuristic heuristic, int options, float raycastLimit)
public Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
IQueryHeuristic heuristic, int options, float raycastLimit)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter)
@ -1022,20 +1022,20 @@ namespace DotRecast.Detour
* query options (see: #FindPathOptions)
* @return
*/
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
int options)
{
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), -1.0f);
}
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
int options, float raycastLimit)
{
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), raycastLimit);
}
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, QueryFilter filter,
int options, QueryHeuristic heuristic, float raycastLimit)
public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter,
int options, IQueryHeuristic heuristic, float raycastLimit)
{
// Init path state.
m_query = new QueryData();
@ -1800,7 +1800,7 @@ namespace DotRecast.Detour
/// @param[in] endPos The desired end position of the mover. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query.
/// @returns Path
public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, QueryFilter filter)
public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(startPos)
@ -2192,7 +2192,7 @@ namespace DotRecast.Detour
/// @param[out] pathCount The number of visited polygons. [opt]
/// @param[in] maxPath The maximum number of polygons the @p path array can hold.
/// @returns The status flags for the query.
public Result<RaycastHit> Raycast(long startRef, Vector3f startPos, Vector3f endPos, QueryFilter filter, int options,
public Result<RaycastHit> Raycast(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, int options,
long prevRef)
{
// Validate input
@ -2460,7 +2460,7 @@ namespace DotRecast.Detour
/// @param[out] resultCount The number of polygons found. [opt]
/// @param[in] maxResult The maximum number of polygons the result arrays can hold.
/// @returns The status flags for the query.
public Result<FindPolysAroundResult> FindPolysAroundCircle(long startRef, Vector3f centerPos, float radius, QueryFilter filter)
public Result<FindPolysAroundResult> FindPolysAroundCircle(long startRef, Vector3f centerPos, float radius, IQueryFilter filter)
{
// Validate input
@ -2638,7 +2638,7 @@ namespace DotRecast.Detour
/// @param[out] resultCount The number of polygons found.
/// @param[in] maxResult The maximum number of polygons the result arrays can hold.
/// @returns The status flags for the query.
public Result<FindPolysAroundResult> FindPolysAroundShape(long startRef, float[] verts, QueryFilter filter)
public Result<FindPolysAroundResult> FindPolysAroundShape(long startRef, float[] verts, IQueryFilter filter)
{
// Validate input
int nverts = verts.Length / 3;
@ -2830,7 +2830,7 @@ namespace DotRecast.Detour
/// @param[in] maxResult The maximum number of polygons the result arrays can hold.
/// @returns The status flags for the query.
public Result<FindLocalNeighbourhoodResult> FindLocalNeighbourhood(long startRef, Vector3f centerPos, float radius,
QueryFilter filter)
IQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || radius < 0
@ -3044,7 +3044,7 @@ namespace DotRecast.Detour
/// @param[out] segmentCount The number of segments returned.
/// @param[in] maxSegments The maximum number of segments the result arrays can hold.
/// @returns The status flags for the query.
public Result<GetPolyWallSegmentsResult> GetPolyWallSegments(long refs, bool storePortals, QueryFilter filter)
public Result<GetPolyWallSegmentsResult> GetPolyWallSegments(long refs, bool storePortals, IQueryFilter filter)
{
Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(refs);
if (tileAndPoly.Failed())
@ -3182,7 +3182,7 @@ namespace DotRecast.Detour
/// source point. [(x, y, z)]
/// @returns The status flags for the query.
public virtual Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius,
QueryFilter filter)
IQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0
@ -3393,7 +3393,7 @@ namespace DotRecast.Detour
/// Returns true if the polygon reference is valid and passes the filter restrictions.
/// @param[in] ref The polygon reference to check.
/// @param[in] filter The filter to apply.
public bool IsValidPolyRef(long refs, QueryFilter filter)
public bool IsValidPolyRef(long refs, IQueryFilter filter)
{
Result<Tuple<MeshTile, Poly>> tileAndPolyResult = m_nav.GetTileAndPolyByRef(refs);
if (tileAndPolyResult.Failed())

View File

@ -30,9 +30,9 @@ namespace DotRecast.Detour
public long startRef, endRef;
public Vector3f startPos = new Vector3f();
public Vector3f endPos = new Vector3f();
public QueryFilter filter;
public IQueryFilter filter;
public int options;
public float raycastLimitSqr;
public QueryHeuristic heuristic;
public IQueryHeuristic heuristic;
}
}

View File

@ -28,7 +28,7 @@ namespace DotRecast.Recast.Demo.Draw;
public class DebugDraw
{
private readonly GLCheckerTexture g_tex;
private readonly OpenGLDraw openGlDraw;
private readonly IOpenGLDraw openGlDraw;
private readonly int[] boxIndices = { 7, 6, 5, 4, 0, 1, 2, 3, 1, 5, 6, 2, 3, 7, 4, 0, 2, 6, 7, 3, 0, 4, 5, 1, };
private readonly float[][] frustumPlanes = ArrayUtils.Of<float>(6, 4);
@ -604,7 +604,7 @@ public class DebugDraw
return _viewMatrix;
}
private OpenGLDraw GetOpenGlDraw()
private IOpenGLDraw GetOpenGlDraw()
{
return openGlDraw;
}

View File

@ -3,7 +3,7 @@ using Silk.NET.OpenGL;
namespace DotRecast.Recast.Demo.Draw;
public interface OpenGLDraw
public interface IOpenGLDraw
{
void Init();

View File

@ -6,7 +6,7 @@ using Silk.NET.OpenGL;
namespace DotRecast.Recast.Demo.Draw;
public class ModernOpenGLDraw : OpenGLDraw
public class ModernOpenGLDraw : IOpenGLDraw
{
private GL _gl;
private uint program;

View File

@ -27,7 +27,7 @@ using DotRecast.Recast.Geom;
namespace DotRecast.Recast.Demo.Geom;
public class DemoInputGeomProvider : InputGeomProvider
public class DemoInputGeomProvider : IInputGeomProvider
{
public readonly float[] vertices;
public readonly int[] faces;

View File

@ -83,7 +83,7 @@ public class CrowdProfilingTool
CreateCrowd();
CreateZones();
NavMeshQuery navquery = new NavMeshQuery(navMesh);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < agents; i++)
{
float tr = rnd.Frand();
@ -146,7 +146,7 @@ public class CrowdProfilingTool
}
}
private Vector3f? GetMobPosition(NavMeshQuery navquery, QueryFilter filter)
private Vector3f? GetMobPosition(NavMeshQuery navquery, IQueryFilter filter)
{
Result<FindRandomPointResult> result = navquery.FindRandomPoint(filter, rnd);
if (result.Succeeded())
@ -157,7 +157,7 @@ public class CrowdProfilingTool
return null;
}
private Vector3f? GetVillagerPosition(NavMeshQuery navquery, QueryFilter filter)
private Vector3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter)
{
if (0 < zones.Count)
{
@ -176,7 +176,7 @@ public class CrowdProfilingTool
private void CreateZones()
{
zones.Clear();
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
NavMeshQuery navquery = new NavMeshQuery(navMesh);
for (int i = 0; i < numberOfZones; i++)
{
@ -252,7 +252,7 @@ public class CrowdProfilingTool
if (crowd != null)
{
NavMeshQuery navquery = new NavMeshQuery(navMesh);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
foreach (CrowdAgent ag in crowd.GetActiveAgents())
{
if (NeedsNewTarget(ag))
@ -277,7 +277,7 @@ public class CrowdProfilingTool
crowdUpdateTime = (endTime - startTime) / TimeSpan.TicksPerMillisecond;
}
private void MoveMob(NavMeshQuery navquery, QueryFilter filter, CrowdAgent ag, AgentData agentData)
private void MoveMob(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
{
// Move somewhere
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
@ -292,7 +292,7 @@ public class CrowdProfilingTool
}
}
private void MoveVillager(NavMeshQuery navquery, QueryFilter filter, CrowdAgent ag, AgentData agentData)
private void MoveVillager(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
{
// Move somewhere close
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
@ -307,7 +307,7 @@ public class CrowdProfilingTool
}
}
private void MoveTraveller(NavMeshQuery navquery, QueryFilter filter, CrowdAgent ag, AgentData agentData)
private void MoveTraveller(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
{
// Move to another zone
List<FindRandomPointResult> potentialTargets = new();

View File

@ -192,7 +192,7 @@ public class CrowdTool : Tool
NavMeshQuery navquery = sample.GetNavMeshQuery();
if (nav != null && navquery != null)
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
Vector3f halfExtents = crowd.GetQueryExtents();
Result<FindNearestPolyResult> result = navquery.FindNearestPoly(p, halfExtents, filter);
long refs = result.result.GetNearestRef();
@ -304,7 +304,7 @@ public class CrowdTool : Tool
// Find nearest point on navmesh and set move request to that location.
NavMeshQuery navquery = sample.GetNavMeshQuery();
QueryFilter filter = crowd.GetFilter(0);
IQueryFilter filter = crowd.GetFilter(0);
Vector3f halfExtents = crowd.GetQueryExtents();
if (adjust)

View File

@ -110,8 +110,8 @@ public class DynamicUpdateTool : Tool
private DynamicNavMesh dynaMesh;
private readonly TaskFactory executor;
private readonly Dictionary<long, Collider> colliders = new();
private readonly Dictionary<long, ColliderGizmo> colliderGizmos = new();
private readonly Dictionary<long, ICollider> colliders = new();
private readonly Dictionary<long, IColliderGizmo> colliderGizmos = new();
private readonly Random random = Random.Shared;
private readonly DemoInputGeomProvider bridgeGeom;
private readonly DemoInputGeomProvider houseGeom;
@ -142,7 +142,7 @@ public class DynamicUpdateTool : Tool
{
if (!shift)
{
Tuple<Collider, ColliderGizmo> colliderWithGizmo = null;
Tuple<ICollider, IColliderGizmo> colliderWithGizmo = null;
if (dynaMesh != null)
{
if (colliderShape == ColliderShape.SPHERE)
@ -217,15 +217,15 @@ public class DynamicUpdateTool : Tool
}
}
private Tuple<Collider, ColliderGizmo> SphereCollider(Vector3f p)
private Tuple<ICollider, IColliderGizmo> SphereCollider(Vector3f p)
{
float radius = 1 + (float)random.NextDouble() * 10;
return Tuple.Create<Collider, ColliderGizmo>(
return Tuple.Create<ICollider, IColliderGizmo>(
new SphereCollider(p, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb),
GizmoFactory.Sphere(p, radius));
}
private Tuple<Collider, ColliderGizmo> CapsuleCollider(Vector3f p)
private Tuple<ICollider, IColliderGizmo> CapsuleCollider(Vector3f p)
{
float radius = 0.4f + (float)random.NextDouble() * 4f;
Vector3f a = Vector3f.Of(
@ -240,11 +240,11 @@ public class DynamicUpdateTool : Tool
a.z *= len;
Vector3f start = Vector3f.Of(p.x, p.y, p.z);
Vector3f end = Vector3f.Of(p.x + a.x, p.y + a.y, p.z + a.z);
return Tuple.Create<Collider, ColliderGizmo>(new CapsuleCollider(
return Tuple.Create<ICollider, IColliderGizmo>(new CapsuleCollider(
start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Capsule(start, end, radius));
}
private Tuple<Collider, ColliderGizmo> BoxCollider(Vector3f p)
private Tuple<ICollider, IColliderGizmo> BoxCollider(Vector3f p)
{
Vector3f extent = Vector3f.Of(
0.5f + (float)random.NextDouble() * 6f,
@ -254,11 +254,11 @@ public class DynamicUpdateTool : Tool
Vector3f forward = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble()));
Vector3f up = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble()));
Vector3f[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent);
return Tuple.Create<Collider, ColliderGizmo>(
return Tuple.Create<ICollider, IColliderGizmo>(
new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Box(p, halfEdges));
}
private Tuple<Collider, ColliderGizmo> CylinderCollider(Vector3f p)
private Tuple<ICollider, IColliderGizmo> CylinderCollider(Vector3f p)
{
float radius = 0.7f + (float)random.NextDouble() * 4f;
float[] a = new float[] { (1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble()) };
@ -269,11 +269,11 @@ public class DynamicUpdateTool : Tool
a[2] *= len;
Vector3f start = Vector3f.Of(p.x, p.y, p.z);
Vector3f end = Vector3f.Of(p.x + a[0], p.y + a[1], p.z + a[2]);
return Tuple.Create<Collider, ColliderGizmo>(new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER,
return Tuple.Create<ICollider, IColliderGizmo>(new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER,
dynaMesh.config.walkableClimb), GizmoFactory.Cylinder(start, end, radius));
}
private Tuple<Collider, ColliderGizmo> CompositeCollider(Vector3f p)
private Tuple<ICollider, IColliderGizmo> CompositeCollider(Vector3f p)
{
Vector3f baseExtent = Vector3f.Of(5, 3, 8);
Vector3f baseCenter = Vector3f.Of(p.x, p.y + 3, p.z);
@ -305,38 +305,38 @@ public class DynamicUpdateTool : Tool
SphereCollider crown = new SphereCollider(crownCenter, 4f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GRASS,
dynaMesh.config.walkableClimb);
CompositeCollider collider = new CompositeCollider(@base, roof, trunk, crown);
ColliderGizmo baseGizmo = GizmoFactory.Box(baseCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(baseUp, forward, baseExtent));
ColliderGizmo roofGizmo = GizmoFactory.Box(roofCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(roofUp, forward, roofExtent));
ColliderGizmo trunkGizmo = GizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f);
ColliderGizmo crownGizmo = GizmoFactory.Sphere(crownCenter, 4f);
ColliderGizmo gizmo = GizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo);
return Tuple.Create<Collider, ColliderGizmo>(collider, gizmo);
IColliderGizmo baseGizmo = GizmoFactory.Box(baseCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(baseUp, forward, baseExtent));
IColliderGizmo roofGizmo = GizmoFactory.Box(roofCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(roofUp, forward, roofExtent));
IColliderGizmo trunkGizmo = GizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f);
IColliderGizmo crownGizmo = GizmoFactory.Sphere(crownCenter, 4f);
IColliderGizmo gizmo = GizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo);
return Tuple.Create<ICollider, IColliderGizmo>(collider, gizmo);
}
private Tuple<Collider, ColliderGizmo> TrimeshBridge(Vector3f p)
private Tuple<ICollider, IColliderGizmo> TrimeshBridge(Vector3f p)
{
return TrimeshCollider(p, bridgeGeom);
}
private Tuple<Collider, ColliderGizmo> TrimeshHouse(Vector3f p)
private Tuple<ICollider, IColliderGizmo> TrimeshHouse(Vector3f p)
{
return TrimeshCollider(p, houseGeom);
}
private Tuple<Collider, ColliderGizmo> ConvexTrimesh(Vector3f p)
private Tuple<ICollider, IColliderGizmo> ConvexTrimesh(Vector3f p)
{
float[] verts = TransformVertices(p, convexGeom, 360);
ConvexTrimeshCollider collider = new ConvexTrimeshCollider(verts, convexGeom.faces,
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb * 10);
return Tuple.Create<Collider, ColliderGizmo>(collider, GizmoFactory.Trimesh(verts, convexGeom.faces));
return Tuple.Create<ICollider, IColliderGizmo>(collider, GizmoFactory.Trimesh(verts, convexGeom.faces));
}
private Tuple<Collider, ColliderGizmo> TrimeshCollider(Vector3f p, DemoInputGeomProvider geom)
private Tuple<ICollider, IColliderGizmo> TrimeshCollider(Vector3f p, DemoInputGeomProvider geom)
{
float[] verts = TransformVertices(p, geom, 0);
TrimeshCollider collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
dynaMesh.config.walkableClimb * 10);
return Tuple.Create<Collider, ColliderGizmo>(collider, GizmoFactory.Trimesh(verts, geom.faces));
return Tuple.Create<ICollider, IColliderGizmo>(collider, GizmoFactory.Trimesh(verts, geom.faces));
}
private float[] TransformVertices(Vector3f p, DemoInputGeomProvider geom, float ax)

View File

@ -4,7 +4,7 @@ using DotRecast.Recast.Demo.Draw;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class BoxGizmo : ColliderGizmo
public class BoxGizmo : IColliderGizmo
{
private static readonly int[] TRIANLGES =
{

View File

@ -6,7 +6,7 @@ using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class CapsuleGizmo : ColliderGizmo
public class CapsuleGizmo : IColliderGizmo
{
private readonly float[] vertices;
private readonly int[] triangles;

View File

@ -4,11 +4,11 @@ using DotRecast.Recast.Demo.Draw;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class CompositeGizmo : ColliderGizmo
public class CompositeGizmo : IColliderGizmo
{
private readonly ColliderGizmo[] gizmos;
private readonly IColliderGizmo[] gizmos;
public CompositeGizmo(params ColliderGizmo[] gizmos)
public CompositeGizmo(params IColliderGizmo[] gizmos)
{
this.gizmos = gizmos;
}

View File

@ -7,7 +7,7 @@ using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class CylinderGizmo : ColliderGizmo
public class CylinderGizmo : IColliderGizmo
{
private readonly float[] vertices;
private readonly int[] triangles;

View File

@ -4,32 +4,32 @@ namespace DotRecast.Recast.Demo.Tools.Gizmos;
public static class GizmoFactory
{
public static ColliderGizmo Box(Vector3f center, Vector3f[] halfEdges)
public static IColliderGizmo Box(Vector3f center, Vector3f[] halfEdges)
{
return new BoxGizmo(center, halfEdges);
}
public static ColliderGizmo Sphere(Vector3f center, float radius)
public static IColliderGizmo Sphere(Vector3f center, float radius)
{
return new SphereGizmo(center, radius);
}
public static ColliderGizmo Capsule(Vector3f start, Vector3f end, float radius)
public static IColliderGizmo Capsule(Vector3f start, Vector3f end, float radius)
{
return new CapsuleGizmo(start, end, radius);
}
public static ColliderGizmo Cylinder(Vector3f start, Vector3f end, float radius)
public static IColliderGizmo Cylinder(Vector3f start, Vector3f end, float radius)
{
return new CylinderGizmo(start, end, radius);
}
public static ColliderGizmo Trimesh(float[] verts, int[] faces)
public static IColliderGizmo Trimesh(float[] verts, int[] faces)
{
return new TrimeshGizmo(verts, faces);
}
public static ColliderGizmo Composite(params ColliderGizmo[] gizmos)
public static IColliderGizmo Composite(params IColliderGizmo[] gizmos)
{
return new CompositeGizmo(gizmos);
}

View File

@ -2,7 +2,7 @@ using DotRecast.Recast.Demo.Draw;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public interface ColliderGizmo
public interface IColliderGizmo
{
void Render(RecastDebugDraw debugDraw);
}

View File

@ -6,7 +6,7 @@ using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class SphereGizmo : ColliderGizmo
public class SphereGizmo : IColliderGizmo
{
private readonly float[] vertices;
private readonly int[] triangles;

View File

@ -2,7 +2,7 @@
namespace DotRecast.Recast.Demo.Tools.Gizmos;
public class TrimeshGizmo : ColliderGizmo
public class TrimeshGizmo : IColliderGizmo
{
private readonly float[] vertices;
private readonly int[] triangles;

View File

@ -489,9 +489,9 @@ public class TestNavmeshTool : Tool
float dx = m_epos.x - m_spos.x;
float dz = m_epos.z - m_spos.z;
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
PolygonByCircleConstraint constraint = constrainByCircle
? PolygonByCircleConstraint.Strict()
: PolygonByCircleConstraint.Noop();
IPolygonByCircleConstraint constraint = constrainByCircle
? IPolygonByCircleConstraint.Strict()
: IPolygonByCircleConstraint.Noop();
for (int i = 0; i < 200; i++)
{
Result<FindRandomPointResult> result = m_navQuery.FindRandomPointAroundCircle(m_startRef, m_spos, dist,

View File

@ -1,26 +0,0 @@
/*
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using Silk.NET.Windowing;
namespace DotRecast.Recast.Demo.Tools;
public interface ToolUIModule
{
void Layout(IWindow ctx);
}

View File

@ -20,7 +20,7 @@ using System.Collections.Generic;
namespace DotRecast.Recast.Geom
{
public interface ConvexVolumeProvider
public interface IConvexVolumeProvider
{
IList<ConvexVolume> ConvexVolumes();
}

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast.Geom
{
public interface InputGeomProvider : ConvexVolumeProvider
public interface IInputGeomProvider : IConvexVolumeProvider
{
Vector3f GetMeshBoundsMin();

View File

@ -25,7 +25,7 @@ using DotRecast.Core;
namespace DotRecast.Recast.Geom
{
public class SimpleInputGeomProvider : InputGeomProvider
public class SimpleInputGeomProvider : IInputGeomProvider
{
public readonly float[] vertices;
public readonly int[] faces;

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast.Geom
{
public class SingleTrimeshInputGeomProvider : InputGeomProvider
public class SingleTrimeshInputGeomProvider : IInputGeomProvider
{
private readonly Vector3f bmin;
private readonly Vector3f bmax;

View File

@ -31,7 +31,7 @@ namespace DotRecast.Recast
public List<int> meshFaces = new List<int>();
}
public static InputGeomProvider Load(byte[] chunck)
public static IInputGeomProvider Load(byte[] chunck)
{
var context = LoadContext(chunck);
return new SimpleInputGeomProvider(context.vertexPositions, context.meshFaces);

View File

@ -29,24 +29,24 @@ namespace DotRecast.Recast
{
public class RecastBuilder
{
public interface RecastBuilderProgressListener
public interface IRecastBuilderProgressListener
{
void OnProgress(int completed, int total);
}
private readonly RecastBuilderProgressListener progressListener;
private readonly IRecastBuilderProgressListener progressListener;
public RecastBuilder()
{
progressListener = null;
}
public RecastBuilder(RecastBuilderProgressListener progressListener)
public RecastBuilder(IRecastBuilderProgressListener progressListener)
{
this.progressListener = progressListener;
}
public List<RecastBuilderResult> BuildTiles(InputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory)
public List<RecastBuilderResult> BuildTiles(IInputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory)
{
Vector3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax();
@ -67,7 +67,7 @@ namespace DotRecast.Recast
}
public Task BuildTilesAsync(InputGeomProvider geom, RecastConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
public Task BuildTilesAsync(IInputGeomProvider geom, RecastConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{
Vector3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax();
@ -87,7 +87,7 @@ namespace DotRecast.Recast
return task;
}
private Task BuildSingleThreadAsync(InputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax,
private Task BuildSingleThreadAsync(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax,
int tw, int th, List<RecastBuilderResult> results)
{
AtomicInteger counter = new AtomicInteger(0);
@ -102,7 +102,7 @@ namespace DotRecast.Recast
return Task.CompletedTask;
}
private Task BuildMultiThreadAsync(InputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax,
private Task BuildMultiThreadAsync(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax,
int tw, int th, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{
AtomicInteger counter = new AtomicInteger(0);
@ -152,7 +152,7 @@ namespace DotRecast.Recast
return Task.WhenAll(tasks.ToArray());
}
private RecastBuilderResult BuildTile(InputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax, int tx,
private RecastBuilderResult BuildTile(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax, int tx,
int ty, AtomicInteger counter, int total)
{
RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty));
@ -164,7 +164,7 @@ namespace DotRecast.Recast
return result;
}
public RecastBuilderResult Build(InputGeomProvider geom, RecastBuilderConfig builderCfg)
public RecastBuilderResult Build(IInputGeomProvider geom, RecastBuilderConfig builderCfg)
{
RecastConfig cfg = builderCfg.cfg;
Telemetry ctx = new Telemetry();
@ -175,7 +175,7 @@ namespace DotRecast.Recast
return Build(builderCfg.tileX, builderCfg.tileZ, geom, cfg, solid, ctx);
}
public RecastBuilderResult Build(int tileX, int tileZ, ConvexVolumeProvider geom, RecastConfig cfg, Heightfield solid,
public RecastBuilderResult Build(int tileX, int tileZ, IConvexVolumeProvider geom, RecastConfig cfg, Heightfield solid,
Telemetry ctx)
{
FilterHeightfield(solid, cfg, ctx);
@ -290,7 +290,7 @@ namespace DotRecast.Recast
/*
* Step 3. Partition walkable surface to simple regions.
*/
private CompactHeightfield BuildCompactHeightfield(ConvexVolumeProvider volumeProvider, RecastConfig cfg, Telemetry ctx,
private CompactHeightfield BuildCompactHeightfield(IConvexVolumeProvider volumeProvider, RecastConfig cfg, Telemetry ctx,
Heightfield solid)
{
// Compact the heightfield so that it is faster to handle from now on.
@ -312,7 +312,7 @@ namespace DotRecast.Recast
return chf;
}
public HeightfieldLayerSet BuildLayers(InputGeomProvider geom, RecastBuilderConfig builderCfg)
public HeightfieldLayerSet BuildLayers(IInputGeomProvider geom, RecastBuilderConfig builderCfg)
{
Telemetry ctx = new Telemetry();
Heightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx);

View File

@ -23,7 +23,7 @@ namespace DotRecast.Recast
{
public class RecastVoxelization
{
public static Heightfield BuildSolidHeightfield(InputGeomProvider geomProvider, RecastBuilderConfig builderCfg,
public static Heightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg,
Telemetry ctx)
{
RecastConfig cfg = builderCfg.cfg;

View File

@ -132,7 +132,7 @@ public class AbstractCrowdTest
protected void SetMoveTarget(Vector3f pos, bool adjust)
{
Vector3f ext = crowd.GetQueryExtents();
QueryFilter filter = crowd.GetFilter(0);
IQueryFilter filter = crowd.GetFilter(0);
if (adjust)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())

View File

@ -28,7 +28,7 @@ namespace DotRecast.Detour.Crowd.Test;
public class PathCorridorTest
{
private readonly PathCorridor corridor = new PathCorridor();
private readonly QueryFilter filter = new DefaultQueryFilter();
private readonly IQueryFilter filter = new DefaultQueryFilter();
[SetUp]
public void SetUp()

View File

@ -46,7 +46,7 @@ public class RecastTestMeshBuilder
{
}
public RecastTestMeshBuilder(InputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize,
public RecastTestMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize,
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope,
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
float m_detailSampleDist, float m_detailSampleMaxError)

View File

@ -36,7 +36,7 @@ public class DynamicNavMeshTest
bool _ = future.Result;
// create new query
NavMeshQuery query = new NavMeshQuery(mesh.NavMesh());
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
// find path
FindNearestPolyResult start = query.FindNearestPoly(START_POS, EXTENT, filter).result;
FindNearestPolyResult end = query.FindNearestPoly(END_POS, EXTENT, filter).result;
@ -45,7 +45,7 @@ public class DynamicNavMeshTest
// check path length without any obstacles
Assert.That(path.Count, Is.EqualTo(16));
// place obstacle
Collider colldier = new SphereCollider(SPHERE_POS, 20, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GROUND, 0.1f);
ICollider colldier = new SphereCollider(SPHERE_POS, 20, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GROUND, 0.1f);
long colliderId = mesh.AddCollider(colldier);
// update navmesh asynchronously
future = mesh.Update(Task.Factory);

View File

@ -93,7 +93,7 @@ public class UnityAStarPathfindingImporterTest
{
// Perform a simple pathfinding
NavMeshQuery query = new NavMeshQuery(mesh);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
FindNearestPolyResult[] polys = GetNearestPolys(mesh, startPos, endPos);
return query.FindPath(polys[0].GetNearestRef(), polys[1].GetNearestRef(), startPos, endPos, filter);
@ -102,7 +102,7 @@ public class UnityAStarPathfindingImporterTest
private FindNearestPolyResult[] GetNearestPolys(NavMesh mesh, params Vector3f[] positions)
{
NavMeshQuery query = new NavMeshQuery(mesh);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
Vector3f extents = Vector3f.Of(0.1f, 0.1f, 0.1f);
FindNearestPolyResult[] results = new FindNearestPolyResult[positions.Length];

View File

@ -48,7 +48,7 @@ public class FindDistanceToWallTest : AbstractDetourTest
[Test]
public void TestFindDistanceToWall()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
Vector3f startPos = startPoss[i];

View File

@ -54,7 +54,7 @@ public class FindLocalNeighbourhoodTest : AbstractDetourTest
[Test]
public void TestFindNearestPoly()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
Vector3f startPos = startPoss[i];

View File

@ -37,7 +37,7 @@ public class FindNearestPolyTest : AbstractDetourTest
[Test]
public void TestFindNearestPoly()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
Vector3f extents = Vector3f.Of(2, 4, 2);
for (int i = 0; i < startRefs.Length; i++)
{
@ -52,7 +52,7 @@ public class FindNearestPolyTest : AbstractDetourTest
}
}
public class EmptyQueryFilter : QueryFilter
public class EmptyQueryFilter : IQueryFilter
{
public bool PassFilter(long refs, MeshTile tile, Poly poly)
{

View File

@ -131,7 +131,7 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPath()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
@ -151,7 +151,7 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPathSliced()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
@ -179,7 +179,7 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPathStraight()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < STRAIGHT_PATHS.Length; i++)
{
// startRefs.Length; i++) {

View File

@ -101,7 +101,7 @@ public class FindPolysAroundCircleTest : AbstractDetourTest
[Test]
public void TestFindPolysAroundCircle()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -128,7 +128,7 @@ public class FindPolysAroundShapeTest : AbstractDetourTest
[Test]
public void TestFindPolysAroundShape()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -77,7 +77,7 @@ public class GetPolyWallSegmentsTest : AbstractDetourTest
[Test]
public void TestFindDistanceToWall()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
Result<GetPolyWallSegmentsResult> result = query.GetPolyWallSegments(startRefs[i], true, filter);

View File

@ -54,7 +54,7 @@ public class MeshSetReaderWriterTest
[Test]
public void Test()
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
NavMeshSetHeader header = new NavMeshSetHeader();
header.magic = NavMeshSetHeader.NAVMESHSET_MAGIC;

View File

@ -68,7 +68,7 @@ public class MoveAlongSurfaceTest : AbstractDetourTest
[Test]
public void TestMoveAlongSurface()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.Test;
[Parallelizable]
public class PolygonByCircleConstraintTest
{
private readonly PolygonByCircleConstraint constraint = new PolygonByCircleConstraint.StrictPolygonByCircleConstraint();
private readonly IPolygonByCircleConstraint constraint = new IPolygonByCircleConstraint.StrictPolygonByCircleConstraint();
[Test]
public void ShouldHandlePolygonFullyInsideCircle()

View File

@ -32,7 +32,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandom()
{
FRand f = new FRand(1);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < 1000; i++)
{
Result<FindRandomPointResult> point = query.FindRandomPoint(filter, f);
@ -60,7 +60,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandomAroundCircle()
{
FRand f = new FRand(1);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
for (int i = 0; i < 1000; i++)
{
@ -91,7 +91,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandomWithinCircle()
{
FRand f = new FRand(1);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
float radius = 5f;
for (int i = 0; i < 1000; i++)
@ -109,7 +109,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestPerformance()
{
FRand f = new FRand(1);
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
float radius = 5f;
// jvm warmup

View File

@ -47,7 +47,7 @@ public class RecastTestMeshBuilder
{
}
public RecastTestMeshBuilder(InputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize,
public RecastTestMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize,
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope,
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
float m_detailSampleDist, float m_detailSampleMaxError)

View File

@ -23,7 +23,7 @@ namespace DotRecast.Detour.Test;
public class TestDetourBuilder : DetourBuilder
{
public MeshData Build(InputGeomProvider geom, RecastBuilderConfig rcConfig, float agentHeight, float agentRadius,
public MeshData Build(IInputGeomProvider geom, RecastBuilderConfig rcConfig, float agentHeight, float agentRadius,
float agentMaxClimb, int x, int y, bool applyRecastDemoFlags)
{
RecastBuilder rcBuilder = new RecastBuilder();

View File

@ -52,7 +52,7 @@ public class TestTiledNavMeshBuilder
{
}
public TestTiledNavMeshBuilder(InputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize, float m_cellHeight,
public TestTiledNavMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize, float m_cellHeight,
float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope, int m_regionMinSize,
int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, float m_detailSampleDist,
float m_detailSampleMaxError, int m_tileSize)

View File

@ -64,7 +64,7 @@ public class TiledFindPathTest
[Test]
public void TestFindPath()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < START_REFS.Length; i++)
{
long startRef = START_REFS[i];

View File

@ -39,7 +39,7 @@ public class AbstractTileCacheTest
private readonly float m_edgeMaxError = 1.3f;
private readonly int m_tileSize = 48;
protected class TestTileCacheMeshProcess : TileCacheMeshProcess
protected class TestTileCacheMeshProcess : ITileCacheMeshProcess
{
public void Process(NavMeshDataCreateParams option)
{
@ -50,7 +50,7 @@ public class AbstractTileCacheTest
}
}
public TileCache GetTileCache(InputGeomProvider geom, ByteOrder order, bool cCompatibility)
public TileCache GetTileCache(IInputGeomProvider geom, ByteOrder order, bool cCompatibility)
{
TileCacheParams option = new TileCacheParams();
int[] twh = Recast.Recast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize);

View File

@ -50,7 +50,7 @@ public class TileCacheReaderWriterTest : AbstractTileCacheTest
private void TestDungeon(bool cCompatibility)
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(ByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, ByteOrder.LITTLE_ENDIAN, cCompatibility);

View File

@ -33,7 +33,7 @@ public class TempObstaclesTest : AbstractTileCacheTest
public void TestDungeon()
{
bool cCompatibility = true;
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(ByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, ByteOrder.LITTLE_ENDIAN, cCompatibility);
@ -67,7 +67,7 @@ public class TempObstaclesTest : AbstractTileCacheTest
public void TestDungeonBox()
{
bool cCompatibility = true;
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(ByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, ByteOrder.LITTLE_ENDIAN, cCompatibility);

View File

@ -45,11 +45,11 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
private const float m_detailSampleMaxError = 1.0f;
private readonly RecastConfig rcConfig;
private const int m_tileSize = 48;
protected readonly InputGeomProvider geom;
protected readonly IInputGeomProvider geom;
private readonly int tw;
private readonly int th;
public TestTileLayerBuilder(InputGeomProvider geom)
public TestTileLayerBuilder(IInputGeomProvider geom)
{
this.geom = geom;
rcConfig = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize),

View File

@ -47,7 +47,7 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
[Test]
public void TestFindPath()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
Vector3f extents = Vector3f.Of(2f, 4f, 2f);
Result<FindNearestPolyResult> findPolyStart = query.FindNearestPoly(start, extents, filter);
Result<FindNearestPolyResult> findPolyEnd = query.FindNearestPoly(end, extents, filter);

View File

@ -56,7 +56,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
public void SetUp()
{
bool cCompatibility = true;
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(ByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, ByteOrder.LITTLE_ENDIAN, cCompatibility);
@ -83,7 +83,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
[Test]
public void TestFindPathWithDefaultHeuristic()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
@ -103,7 +103,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
[Test]
public void TestFindPathWithNoHeuristic()
{
QueryFilter filter = new DefaultQueryFilter();
IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -59,7 +59,7 @@ public class TileCacheTest : AbstractTileCacheTest
private void TestDungeon(ByteOrder order, bool cCompatibility)
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TileCache tc = GetTileCache(geom, order, cCompatibility);
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(order, cCompatibility, 1);
@ -155,7 +155,7 @@ public class TileCacheTest : AbstractTileCacheTest
private void Test(ByteOrder order, bool cCompatibility)
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("nav_test.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("nav_test.obj"));
TileCache tc = GetTileCache(geom, order, cCompatibility);
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(order, cCompatibility, 1);
@ -181,7 +181,7 @@ public class TileCacheTest : AbstractTileCacheTest
int threads = 4;
ByteOrder order = ByteOrder.LITTLE_ENDIAN;
bool cCompatibility = false;
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
for (int i = 0; i < 4; i++)
{

View File

@ -145,7 +145,7 @@ public class RecastLayersTest
private HeightfieldLayerSet Build(string filename, int x, int y)
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,

View File

@ -96,7 +96,7 @@ public class RecastSoloMeshTest
int expContours, int expVerts, int expPolys, int expDetMeshes, int expDetVerts, int expDetTris)
{
m_partitionType = partitionType;
InputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename));
IInputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename));
long time = FrequencyWatch.Ticks;
Vector3f bmin = geomProvider.GetMeshBoundsMin();
Vector3f bmax = geomProvider.GetMeshBoundsMax();

View File

@ -60,7 +60,7 @@ public class RecastTileMeshTest
public void TestBuild(string filename)
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
@ -95,7 +95,7 @@ public class RecastTileMeshTest
[Test]
public void TestPerformance()
{
InputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
@ -124,7 +124,7 @@ public class RecastTileMeshTest
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
}
private void Build(InputGeomProvider geom, RecastBuilder builder, RecastConfig cfg, int threads, bool validate)
private void Build(IInputGeomProvider geom, RecastBuilder builder, RecastConfig cfg, int threads, bool validate)
{
CancellationTokenSource cts = new CancellationTokenSource();
List<RecastBuilderResult> tiles = new();