forked from bit/DotRecastNetSim
move frand
This commit is contained in:
parent
4cb6c1cac7
commit
89eb8554d9
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DotRecast.Core
|
||||||
|
{
|
||||||
|
public class FRand
|
||||||
|
{
|
||||||
|
private readonly Random r;
|
||||||
|
|
||||||
|
public FRand()
|
||||||
|
{
|
||||||
|
r = new Random();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FRand(long seed)
|
||||||
|
{
|
||||||
|
r = new Random((int)seed); // TODO : 랜덤 시드 확인 필요
|
||||||
|
}
|
||||||
|
|
||||||
|
public float frand()
|
||||||
|
{
|
||||||
|
return (float)r.NextDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,26 +73,6 @@ namespace DotRecast.Detour
|
||||||
m_openList = new NodeQueue();
|
m_openList = new NodeQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FRand
|
|
||||||
{
|
|
||||||
private readonly Random r;
|
|
||||||
|
|
||||||
public FRand()
|
|
||||||
{
|
|
||||||
r = new Random();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FRand(long seed)
|
|
||||||
{
|
|
||||||
r = new Random((int)seed); // TODO : 랜덤 시드 확인 필요
|
|
||||||
}
|
|
||||||
|
|
||||||
public float frand()
|
|
||||||
{
|
|
||||||
return (float)r.NextDouble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns random location on navmesh. Polygons are chosen weighted by area. The search runs in linear related to
|
* Returns random location on navmesh. Polygons are chosen weighted by area. The search runs in linear related to
|
||||||
* number of polygon.
|
* number of polygon.
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class CrowdProfilingTool
|
||||||
private Crowd crowd;
|
private Crowd crowd;
|
||||||
private NavMesh navMesh;
|
private NavMesh navMesh;
|
||||||
private CrowdConfig config;
|
private CrowdConfig config;
|
||||||
private NavMeshQuery.FRand rnd;
|
private FRand rnd;
|
||||||
private readonly List<FindRandomPointResult> zones = new();
|
private readonly List<FindRandomPointResult> zones = new();
|
||||||
private long crowdUpdateTime;
|
private long crowdUpdateTime;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class CrowdProfilingTool
|
||||||
{
|
{
|
||||||
if (navMesh != null)
|
if (navMesh != null)
|
||||||
{
|
{
|
||||||
rnd = new NavMeshQuery.FRand(randomSeed);
|
rnd = new FRand(randomSeed);
|
||||||
createCrowd();
|
createCrowd();
|
||||||
createZones();
|
createZones();
|
||||||
NavMeshQuery navquery = new NavMeshQuery(navMesh);
|
NavMeshQuery navquery = new NavMeshQuery(navMesh);
|
||||||
|
|
|
@ -495,7 +495,7 @@ public class TestNavmeshTool : Tool
|
||||||
for (int i = 0; i < 200; i++)
|
for (int i = 0; i < 200; i++)
|
||||||
{
|
{
|
||||||
Result<FindRandomPointResult> result = m_navQuery.findRandomPointAroundCircle(m_startRef, m_spos, dist,
|
Result<FindRandomPointResult> result = m_navQuery.findRandomPointAroundCircle(m_startRef, m_spos, dist,
|
||||||
m_filter, new NavMeshQuery.FRand(), constraint);
|
m_filter, new FRand(), constraint);
|
||||||
if (result.succeeded())
|
if (result.succeeded())
|
||||||
{
|
{
|
||||||
randomPoints.Add(result.result.getRandomPt());
|
randomPoints.Add(result.result.getRandomPt());
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class RandomPointTest : AbstractDetourTest
|
||||||
[Test]
|
[Test]
|
||||||
public void testRandom()
|
public void testRandom()
|
||||||
{
|
{
|
||||||
NavMeshQuery.FRand f = new NavMeshQuery.FRand(1);
|
FRand f = new FRand(1);
|
||||||
QueryFilter filter = new DefaultQueryFilter();
|
QueryFilter filter = new DefaultQueryFilter();
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ public class RandomPointTest : AbstractDetourTest
|
||||||
[Test]
|
[Test]
|
||||||
public void testRandomAroundCircle()
|
public void testRandomAroundCircle()
|
||||||
{
|
{
|
||||||
NavMeshQuery.FRand f = new NavMeshQuery.FRand(1);
|
FRand f = new FRand(1);
|
||||||
QueryFilter filter = new DefaultQueryFilter();
|
QueryFilter filter = new DefaultQueryFilter();
|
||||||
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
|
@ -90,7 +90,7 @@ public class RandomPointTest : AbstractDetourTest
|
||||||
[Test]
|
[Test]
|
||||||
public void testRandomWithinCircle()
|
public void testRandomWithinCircle()
|
||||||
{
|
{
|
||||||
NavMeshQuery.FRand f = new NavMeshQuery.FRand(1);
|
FRand f = new FRand(1);
|
||||||
QueryFilter filter = new DefaultQueryFilter();
|
QueryFilter filter = new DefaultQueryFilter();
|
||||||
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
||||||
float radius = 5f;
|
float radius = 5f;
|
||||||
|
@ -108,7 +108,7 @@ public class RandomPointTest : AbstractDetourTest
|
||||||
[Test]
|
[Test]
|
||||||
public void testPerformance()
|
public void testPerformance()
|
||||||
{
|
{
|
||||||
NavMeshQuery.FRand f = new NavMeshQuery.FRand(1);
|
FRand f = new FRand(1);
|
||||||
QueryFilter filter = new DefaultQueryFilter();
|
QueryFilter filter = new DefaultQueryFilter();
|
||||||
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
FindRandomPointResult point = query.findRandomPoint(filter, f).result;
|
||||||
float radius = 5f;
|
float radius = 5f;
|
||||||
|
|
Loading…
Reference in New Issue