forked from bit/DotRecastNetSim
shared filter
This commit is contained in:
parent
a1d27dec7f
commit
89f4e73abf
|
@ -7,8 +7,6 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
{
|
||||
class NavMeshGroundSampler : AbstractGroundSampler
|
||||
{
|
||||
private readonly IDtQueryFilter filter = new DtQueryNoOpFilter();
|
||||
|
||||
public override void Sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es)
|
||||
{
|
||||
DtNavMeshQuery navMeshQuery = CreateNavMesh(result, acfg.agentRadius, acfg.agentHeight, acfg.agentClimb);
|
||||
|
@ -51,7 +49,7 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
RcAtomicBoolean found = new RcAtomicBoolean();
|
||||
RcAtomicFloat minHeight = new RcAtomicFloat(pt.y);
|
||||
|
||||
navMeshQuery.QueryPolygons(pt, halfExtents, filter, new PolyQueryInvoker((tile, poly, refs) =>
|
||||
navMeshQuery.QueryPolygons(pt, halfExtents, DtQueryNoOpFilter.Shared, new PolyQueryInvoker((tile, poly, refs) =>
|
||||
{
|
||||
var status = navMeshQuery.GetPolyHeight(refs, pt, out var h);
|
||||
if (status.Succeeded())
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace DotRecast.Detour
|
|||
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
|
||||
IDtQueryFilter filter, IRcRand frand, out long randomRef, out RcVec3f randomPt)
|
||||
{
|
||||
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtNoOpDtPolygonByCircleConstraint.Noop, out randomRef, out randomPt);
|
||||
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtNoOpDtPolygonByCircleConstraint.Shared, out randomRef, out randomPt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,7 +221,7 @@ namespace DotRecast.Detour
|
|||
public DtStatus FindRandomPointWithinCircle(long startRef, RcVec3f centerPos, float maxRadius,
|
||||
IDtQueryFilter filter, IRcRand frand, out long randomRef, out RcVec3f randomPt)
|
||||
{
|
||||
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtStrictDtPolygonByCircleConstraint.Strict, out randomRef, out randomPt);
|
||||
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtStrictDtPolygonByCircleConstraint.Shared, out randomRef, out randomPt);
|
||||
}
|
||||
|
||||
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
public class DtNoOpDtPolygonByCircleConstraint : IDtPolygonByCircleConstraint
|
||||
{
|
||||
public static readonly DtNoOpDtPolygonByCircleConstraint Noop = new DtNoOpDtPolygonByCircleConstraint();
|
||||
public static readonly DtNoOpDtPolygonByCircleConstraint Shared = new DtNoOpDtPolygonByCircleConstraint();
|
||||
|
||||
private DtNoOpDtPolygonByCircleConstraint()
|
||||
{
|
||||
|
|
|
@ -4,12 +4,18 @@ namespace DotRecast.Detour
|
|||
{
|
||||
public class DtQueryEmptyFilter : IDtQueryFilter
|
||||
{
|
||||
public static readonly DtQueryEmptyFilter Shared = new DtQueryEmptyFilter();
|
||||
|
||||
private DtQueryEmptyFilter()
|
||||
{
|
||||
}
|
||||
|
||||
public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef,
|
||||
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef,
|
||||
DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -4,6 +4,13 @@ namespace DotRecast.Detour
|
|||
{
|
||||
public class DtQueryNoOpFilter : IDtQueryFilter
|
||||
{
|
||||
public static readonly DtQueryNoOpFilter Shared = new DtQueryNoOpFilter();
|
||||
|
||||
private DtQueryNoOpFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace DotRecast.Detour
|
|||
private const int CIRCLE_SEGMENTS = 12;
|
||||
private static readonly float[] UnitCircle = MakeUnitCircle();
|
||||
|
||||
public static readonly IDtPolygonByCircleConstraint Strict = new DtStrictDtPolygonByCircleConstraint();
|
||||
public static readonly IDtPolygonByCircleConstraint Shared = new DtStrictDtPolygonByCircleConstraint();
|
||||
|
||||
private DtStrictDtPolygonByCircleConstraint()
|
||||
{
|
||||
|
|
|
@ -298,8 +298,8 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
|
||||
IDtPolygonByCircleConstraint constraint = constrainByCircle
|
||||
? DtStrictDtPolygonByCircleConstraint.Strict
|
||||
: DtNoOpDtPolygonByCircleConstraint.Noop;
|
||||
? DtStrictDtPolygonByCircleConstraint.Shared
|
||||
: DtNoOpDtPolygonByCircleConstraint.Shared;
|
||||
|
||||
var frand = new FRand();
|
||||
var navQuery = _sample.GetNavMeshQuery();
|
||||
|
|
|
@ -56,12 +56,11 @@ public class FindNearestPolyTest : AbstractDetourTest
|
|||
[Test]
|
||||
public void ShouldReturnStartPosWhenNoPolyIsValid()
|
||||
{
|
||||
var filter = new DtQueryEmptyFilter();
|
||||
RcVec3f extents = RcVec3f.Of(2, 4, 2);
|
||||
for (int i = 0; i < startRefs.Length; i++)
|
||||
{
|
||||
RcVec3f startPos = startPoss[i];
|
||||
var status = query.FindNearestPoly(startPos, extents, filter, out var nearestRef, out var nearestPt, out var _);
|
||||
var status = query.FindNearestPoly(startPos, extents, DtQueryEmptyFilter.Shared, out var nearestRef, out var nearestPt, out var _);
|
||||
Assert.That(status.Succeeded(), Is.True);
|
||||
Assert.That(nearestRef, Is.EqualTo(0L));
|
||||
for (int v = 0; v < POLY_POS[i].Length; v++)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace DotRecast.Detour.Test;
|
|||
[Parallelizable]
|
||||
public class PolygonByCircleConstraintTest
|
||||
{
|
||||
private readonly IDtPolygonByCircleConstraint _constraint = DtStrictDtPolygonByCircleConstraint.Strict;
|
||||
private readonly IDtPolygonByCircleConstraint _constraint = DtStrictDtPolygonByCircleConstraint.Shared;
|
||||
|
||||
[Test]
|
||||
public void ShouldHandlePolygonFullyInsideCircle()
|
||||
|
|
Loading…
Reference in New Issue