From ee5d3fd8c7e62e8dd7faf4bd812ac71983943651 Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 14 Jul 2023 22:42:48 +0900 Subject: [PATCH] add IRcRand for unity3d --- src/DotRecast.Core/FRand.cs | 2 +- src/DotRecast.Core/IRcRand.cs | 7 +++++++ src/DotRecast.Detour/DtNavMeshQuery.cs | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/DotRecast.Core/IRcRand.cs diff --git a/src/DotRecast.Core/FRand.cs b/src/DotRecast.Core/FRand.cs index 3acee4c..c57c563 100644 --- a/src/DotRecast.Core/FRand.cs +++ b/src/DotRecast.Core/FRand.cs @@ -2,7 +2,7 @@ namespace DotRecast.Core { - public class FRand + public class FRand : IRcRand { private readonly Random _r; diff --git a/src/DotRecast.Core/IRcRand.cs b/src/DotRecast.Core/IRcRand.cs new file mode 100644 index 0000000..499e14c --- /dev/null +++ b/src/DotRecast.Core/IRcRand.cs @@ -0,0 +1,7 @@ +namespace DotRecast.Core +{ + public interface IRcRand + { + float Next(); + } +} \ No newline at end of file diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 5842d3e..ca94f5b 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -78,7 +78,7 @@ namespace DotRecast.Detour /// @param[out] randomRef The reference id of the random location. /// @param[out] randomPt The random location. /// @returns The status flags for the query. - public DtStatus FindRandomPoint(IDtQueryFilter filter, FRand frand, out long randomRef, out RcVec3f randomPt) + public DtStatus FindRandomPoint(IDtQueryFilter filter, IRcRand frand, out long randomRef, out RcVec3f randomPt) { randomRef = 0; randomPt = RcVec3f.Zero; @@ -199,7 +199,7 @@ namespace DotRecast.Detour * @return Random location */ public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, - IDtQueryFilter filter, FRand 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); } @@ -220,13 +220,13 @@ namespace DotRecast.Detour * @return Random location */ public DtStatus FindRandomPointWithinCircle(long startRef, RcVec3f centerPos, float maxRadius, - IDtQueryFilter filter, FRand 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); } public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, - IDtQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint, + IDtQueryFilter filter, IRcRand frand, IPolygonByCircleConstraint constraint, out long randomRef, out RcVec3f randomPt) { randomRef = startRef;