forked from mirror/DotRecast
remove class FindRandomPointResult
This commit is contained in:
parent
3d2cb74e2c
commit
a0877d3dc6
|
@ -0,0 +1,16 @@
|
|||
using DotRecast.Core;
|
||||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
public readonly struct DtPolyPoint
|
||||
{
|
||||
public readonly long refs;
|
||||
public readonly RcVec3f pt;
|
||||
|
||||
public DtPolyPoint(long polyRefs, RcVec3f polyPt)
|
||||
{
|
||||
refs = polyRefs;
|
||||
pt = polyPt;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
||||
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
|
||||
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
|
||||
|
||||
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 DotRecast.Core;
|
||||
|
||||
namespace DotRecast.Detour.QueryResults
|
||||
{
|
||||
//TODO: (PP) Add comments
|
||||
public class FindRandomPointResult
|
||||
{
|
||||
private readonly long randomRef;
|
||||
private readonly RcVec3f randomPt;
|
||||
|
||||
public FindRandomPointResult(long randomRef, RcVec3f randomPt)
|
||||
{
|
||||
this.randomRef = randomRef;
|
||||
this.randomPt = randomPt;
|
||||
}
|
||||
|
||||
/// @param[out] randomRef The reference id of the random location.
|
||||
public long GetRandomRef()
|
||||
{
|
||||
return randomRef;
|
||||
}
|
||||
|
||||
/// @param[out] randomPt The random location.
|
||||
public RcVec3f GetRandomPt()
|
||||
{
|
||||
return randomPt;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ public class CrowdProfilingTool
|
|||
private DtNavMesh navMesh;
|
||||
private DtCrowdConfig config;
|
||||
private FRand rnd;
|
||||
private readonly List<FindRandomPointResult> zones = new();
|
||||
private readonly List<DtPolyPoint> _polyPoints = new();
|
||||
private long crowdUpdateTime;
|
||||
|
||||
public CrowdProfilingTool(Func<DtCrowdAgentParams> agentParamsSupplier)
|
||||
|
@ -158,10 +158,10 @@ public class CrowdProfilingTool
|
|||
|
||||
private RcVec3f? GetVillagerPosition(DtNavMeshQuery navquery, IDtQueryFilter filter)
|
||||
{
|
||||
if (0 < zones.Count)
|
||||
if (0 < _polyPoints.Count)
|
||||
{
|
||||
int zone = (int)(rnd.Next() * zones.Count);
|
||||
var status = navquery.FindRandomPointWithinCircle(zones[zone].GetRandomRef(), zones[zone].GetRandomPt(), zoneRadius, filter, rnd,
|
||||
int zone = (int)(rnd.Next() * _polyPoints.Count);
|
||||
var status = navquery.FindRandomPointWithinCircle(_polyPoints[zone].refs, _polyPoints[zone].pt, zoneRadius, filter, rnd,
|
||||
out var randomRef, out var randomPt);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ public class CrowdProfilingTool
|
|||
|
||||
private void CreateZones()
|
||||
{
|
||||
zones.Clear();
|
||||
_polyPoints.Clear();
|
||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||
DtNavMeshQuery navquery = new DtNavMeshQuery(navMesh);
|
||||
for (int i = 0; i < numberOfZones; i++)
|
||||
|
@ -186,9 +186,9 @@ public class CrowdProfilingTool
|
|||
if (status.Succeeded())
|
||||
{
|
||||
bool valid = true;
|
||||
foreach (var zone in zones)
|
||||
foreach (var zone in _polyPoints)
|
||||
{
|
||||
if (RcVec3f.DistSqr(zone.GetRandomPt(), randomPt) < zoneSeparation)
|
||||
if (RcVec3f.DistSqr(zone.pt, randomPt) < zoneSeparation)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
|
@ -197,7 +197,7 @@ public class CrowdProfilingTool
|
|||
|
||||
if (valid)
|
||||
{
|
||||
zones.Add(new FindRandomPointResult(randomRef, randomPt));
|
||||
_polyPoints.Add(new DtPolyPoint(randomRef, randomPt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -309,10 +309,10 @@ public class CrowdProfilingTool
|
|||
private void MoveTraveller(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData)
|
||||
{
|
||||
// Move to another zone
|
||||
List<FindRandomPointResult> potentialTargets = new();
|
||||
foreach (FindRandomPointResult zone in zones)
|
||||
List<DtPolyPoint> potentialTargets = new();
|
||||
foreach (var zone in _polyPoints)
|
||||
{
|
||||
if (RcVec3f.DistSqr(zone.GetRandomPt(), ag.npos) > zoneRadius * zoneRadius)
|
||||
if (RcVec3f.DistSqr(zone.pt, ag.npos) > zoneRadius * zoneRadius)
|
||||
{
|
||||
potentialTargets.Add(zone);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class CrowdProfilingTool
|
|||
if (0 < potentialTargets.Count)
|
||||
{
|
||||
potentialTargets.Shuffle();
|
||||
crowd.RequestMoveTarget(ag, potentialTargets[0].GetRandomRef(), potentialTargets[0].GetRandomPt());
|
||||
crowd.RequestMoveTarget(ag, potentialTargets[0].refs, potentialTargets[0].pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue