forked from bit/DotRecastNetSim
rename for unity3d
This commit is contained in:
parent
94e1922e02
commit
cab865f747
|
@ -202,7 +202,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, NoOpPolygonByCircleConstraint.Noop, out randomRef, out randomPt);
|
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtNoOpDtPolygonByCircleConstraint.Noop, out randomRef, out randomPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -223,11 +223,11 @@ 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, StrictPolygonByCircleConstraint.Strict, out randomRef, out randomPt);
|
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, DtStrictDtPolygonByCircleConstraint.Strict, out randomRef, out randomPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
|
public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
|
||||||
IDtQueryFilter filter, IRcRand frand, IPolygonByCircleConstraint constraint,
|
IDtQueryFilter filter, IRcRand frand, IDtPolygonByCircleConstraint constraint,
|
||||||
out long randomRef, out RcVec3f randomPt)
|
out long randomRef, out RcVec3f randomPt)
|
||||||
{
|
{
|
||||||
randomRef = startRef;
|
randomRef = startRef;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
using DotRecast.Core;
|
||||||
|
|
||||||
|
namespace DotRecast.Detour
|
||||||
|
{
|
||||||
|
public class DtNoOpDtPolygonByCircleConstraint : IDtPolygonByCircleConstraint
|
||||||
|
{
|
||||||
|
public static readonly DtNoOpDtPolygonByCircleConstraint Noop = new DtNoOpDtPolygonByCircleConstraint();
|
||||||
|
|
||||||
|
private DtNoOpDtPolygonByCircleConstraint()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] Apply(float[] polyVerts, RcVec3f circleCenter, float radius)
|
||||||
|
{
|
||||||
|
return polyVerts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,14 +6,14 @@ namespace DotRecast.Detour
|
||||||
/**
|
/**
|
||||||
* Calculate the intersection between a polygon and a circle. A dodecagon is used as an approximation of the circle.
|
* Calculate the intersection between a polygon and a circle. A dodecagon is used as an approximation of the circle.
|
||||||
*/
|
*/
|
||||||
public class StrictPolygonByCircleConstraint : IPolygonByCircleConstraint
|
public class DtStrictDtPolygonByCircleConstraint : IDtPolygonByCircleConstraint
|
||||||
{
|
{
|
||||||
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 IPolygonByCircleConstraint Strict = new StrictPolygonByCircleConstraint();
|
public static readonly IDtPolygonByCircleConstraint Strict = new DtStrictDtPolygonByCircleConstraint();
|
||||||
|
|
||||||
private StrictPolygonByCircleConstraint()
|
private DtStrictDtPolygonByCircleConstraint()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ using DotRecast.Core;
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public interface IPolygonByCircleConstraint
|
public interface IDtPolygonByCircleConstraint
|
||||||
{
|
{
|
||||||
float[] Apply(float[] polyVerts, RcVec3f circleCenter, float radius);
|
float[] Apply(float[] polyVerts, RcVec3f circleCenter, float radius);
|
||||||
}
|
}
|
|
@ -1,18 +0,0 @@
|
||||||
using DotRecast.Core;
|
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
|
||||||
{
|
|
||||||
public class NoOpPolygonByCircleConstraint : IPolygonByCircleConstraint
|
|
||||||
{
|
|
||||||
public static readonly NoOpPolygonByCircleConstraint Noop = new NoOpPolygonByCircleConstraint();
|
|
||||||
|
|
||||||
private NoOpPolygonByCircleConstraint()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public float[] Apply(float[] polyVerts, RcVec3f circleCenter, float radius)
|
|
||||||
{
|
|
||||||
return polyVerts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -297,9 +297,9 @@ namespace DotRecast.Recast.DemoTool.Tools
|
||||||
float dz = epos.z - spos.z;
|
float dz = epos.z - spos.z;
|
||||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||||
|
|
||||||
IPolygonByCircleConstraint constraint = constrainByCircle
|
IDtPolygonByCircleConstraint constraint = constrainByCircle
|
||||||
? StrictPolygonByCircleConstraint.Strict
|
? DtStrictDtPolygonByCircleConstraint.Strict
|
||||||
: NoOpPolygonByCircleConstraint.Noop;
|
: DtNoOpDtPolygonByCircleConstraint.Noop;
|
||||||
|
|
||||||
var frand = new FRand();
|
var frand = new FRand();
|
||||||
var navQuery = _sample.GetNavMeshQuery();
|
var navQuery = _sample.GetNavMeshQuery();
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace DotRecast.Detour.Test;
|
||||||
[Parallelizable]
|
[Parallelizable]
|
||||||
public class PolygonByCircleConstraintTest
|
public class PolygonByCircleConstraintTest
|
||||||
{
|
{
|
||||||
private readonly IPolygonByCircleConstraint _constraint = StrictPolygonByCircleConstraint.Strict;
|
private readonly IDtPolygonByCircleConstraint _constraint = DtStrictDtPolygonByCircleConstraint.Strict;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldHandlePolygonFullyInsideCircle()
|
public void ShouldHandlePolygonFullyInsideCircle()
|
||||||
|
|
Loading…
Reference in New Issue