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