forked from bit/DotRecastNetSim
move ObstacleAvoidanceParams
This commit is contained in:
parent
546a9d0b97
commit
7e4150d7ee
|
@ -145,7 +145,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
private readonly AtomicInteger agentId = new AtomicInteger();
|
private readonly AtomicInteger agentId = new AtomicInteger();
|
||||||
private readonly List<CrowdAgent> m_agents;
|
private readonly List<CrowdAgent> m_agents;
|
||||||
private readonly PathQueue m_pathq;
|
private readonly PathQueue m_pathq;
|
||||||
private readonly ObstacleAvoidanceQuery.ObstacleAvoidanceParams[] m_obstacleQueryParams = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS];
|
private readonly ObstacleAvoidanceParams[] m_obstacleQueryParams = new ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS];
|
||||||
private readonly ObstacleAvoidanceQuery m_obstacleQuery;
|
private readonly ObstacleAvoidanceQuery m_obstacleQuery;
|
||||||
private ProximityGrid m_grid;
|
private ProximityGrid m_grid;
|
||||||
private readonly Vector3f m_ext = new Vector3f();
|
private readonly Vector3f m_ext = new Vector3f();
|
||||||
|
@ -176,7 +176,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Init obstacle query option.
|
// Init obstacle query option.
|
||||||
for (int i = 0; i < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS; ++i)
|
for (int i = 0; i < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS; ++i)
|
||||||
{
|
{
|
||||||
m_obstacleQueryParams[i] = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
m_obstacleQueryParams[i] = new ObstacleAvoidanceParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate temp buffer for merging paths.
|
// Allocate temp buffer for merging paths.
|
||||||
|
@ -198,11 +198,11 @@ namespace DotRecast.Detour.Crowd
|
||||||
/// @param[in] idx The index. [Limits: 0 <= value <
|
/// @param[in] idx The index. [Limits: 0 <= value <
|
||||||
/// #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
/// #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
||||||
/// @param[in] option The new configuration.
|
/// @param[in] option The new configuration.
|
||||||
public void setObstacleAvoidanceParams(int idx, ObstacleAvoidanceQuery.ObstacleAvoidanceParams option)
|
public void setObstacleAvoidanceParams(int idx, ObstacleAvoidanceParams option)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
|
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
|
||||||
{
|
{
|
||||||
m_obstacleQueryParams[idx] = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams(option);
|
m_obstacleQueryParams[idx] = new ObstacleAvoidanceParams(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
/// @param[in] idx The index of the configuration to retreive.
|
/// @param[in] idx The index of the configuration to retreive.
|
||||||
/// [Limits: 0 <= value < #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
/// [Limits: 0 <= value < #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
||||||
/// @return The requested configuration.
|
/// @return The requested configuration.
|
||||||
public ObstacleAvoidanceQuery.ObstacleAvoidanceParams getObstacleAvoidanceParams(int idx)
|
public ObstacleAvoidanceParams getObstacleAvoidanceParams(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
|
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
|
||||||
{
|
{
|
||||||
|
@ -1177,7 +1177,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
bool adaptive = true;
|
bool adaptive = true;
|
||||||
int ns = 0;
|
int ns = 0;
|
||||||
|
|
||||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = m_obstacleQueryParams[ag.option.obstacleAvoidanceType];
|
ObstacleAvoidanceParams option = m_obstacleQueryParams[ag.option.obstacleAvoidanceType];
|
||||||
|
|
||||||
if (adaptive)
|
if (adaptive)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj"/>
|
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
namespace DotRecast.Detour.Crowd
|
||||||
|
{
|
||||||
|
public class ObstacleAvoidanceParams
|
||||||
|
{
|
||||||
|
public float velBias;
|
||||||
|
public float weightDesVel;
|
||||||
|
public float weightCurVel;
|
||||||
|
public float weightSide;
|
||||||
|
public float weightToi;
|
||||||
|
public float horizTime;
|
||||||
|
public int gridSize;
|
||||||
|
|
||||||
|
/// < grid
|
||||||
|
public int adaptiveDivs;
|
||||||
|
|
||||||
|
/// < adaptive
|
||||||
|
public int adaptiveRings;
|
||||||
|
|
||||||
|
/// < adaptive
|
||||||
|
public int adaptiveDepth;
|
||||||
|
|
||||||
|
/// < adaptive
|
||||||
|
public ObstacleAvoidanceParams()
|
||||||
|
{
|
||||||
|
velBias = 0.4f;
|
||||||
|
weightDesVel = 2.0f;
|
||||||
|
weightCurVel = 0.75f;
|
||||||
|
weightSide = 0.75f;
|
||||||
|
weightToi = 2.5f;
|
||||||
|
horizTime = 2.5f;
|
||||||
|
gridSize = 33;
|
||||||
|
adaptiveDivs = 7;
|
||||||
|
adaptiveRings = 2;
|
||||||
|
adaptiveDepth = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObstacleAvoidanceParams(ObstacleAvoidanceParams option)
|
||||||
|
{
|
||||||
|
velBias = option.velBias;
|
||||||
|
weightDesVel = option.weightDesVel;
|
||||||
|
weightCurVel = option.weightCurVel;
|
||||||
|
weightSide = option.weightSide;
|
||||||
|
weightToi = option.weightToi;
|
||||||
|
horizTime = option.horizTime;
|
||||||
|
gridSize = option.gridSize;
|
||||||
|
adaptiveDivs = option.adaptiveDivs;
|
||||||
|
adaptiveRings = option.adaptiveRings;
|
||||||
|
adaptiveDepth = option.adaptiveDepth;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -66,55 +66,6 @@ namespace DotRecast.Detour.Crowd
|
||||||
public bool touch;
|
public bool touch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObstacleAvoidanceParams
|
|
||||||
{
|
|
||||||
public float velBias;
|
|
||||||
public float weightDesVel;
|
|
||||||
public float weightCurVel;
|
|
||||||
public float weightSide;
|
|
||||||
public float weightToi;
|
|
||||||
public float horizTime;
|
|
||||||
public int gridSize;
|
|
||||||
|
|
||||||
/// < grid
|
|
||||||
public int adaptiveDivs;
|
|
||||||
|
|
||||||
/// < adaptive
|
|
||||||
public int adaptiveRings;
|
|
||||||
|
|
||||||
/// < adaptive
|
|
||||||
public int adaptiveDepth;
|
|
||||||
|
|
||||||
/// < adaptive
|
|
||||||
public ObstacleAvoidanceParams()
|
|
||||||
{
|
|
||||||
velBias = 0.4f;
|
|
||||||
weightDesVel = 2.0f;
|
|
||||||
weightCurVel = 0.75f;
|
|
||||||
weightSide = 0.75f;
|
|
||||||
weightToi = 2.5f;
|
|
||||||
horizTime = 2.5f;
|
|
||||||
gridSize = 33;
|
|
||||||
adaptiveDivs = 7;
|
|
||||||
adaptiveRings = 2;
|
|
||||||
adaptiveDepth = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObstacleAvoidanceParams(ObstacleAvoidanceParams option)
|
|
||||||
{
|
|
||||||
velBias = option.velBias;
|
|
||||||
weightDesVel = option.weightDesVel;
|
|
||||||
weightCurVel = option.weightCurVel;
|
|
||||||
weightSide = option.weightSide;
|
|
||||||
weightToi = option.weightToi;
|
|
||||||
horizTime = option.horizTime;
|
|
||||||
gridSize = option.gridSize;
|
|
||||||
adaptiveDivs = option.adaptiveDivs;
|
|
||||||
adaptiveRings = option.adaptiveRings;
|
|
||||||
adaptiveDepth = option.adaptiveDepth;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private ObstacleAvoidanceParams m_params;
|
private ObstacleAvoidanceParams m_params;
|
||||||
private float m_invHorizTime;
|
private float m_invHorizTime;
|
||||||
private float m_vmax;
|
private float m_vmax;
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class CrowdProfilingTool
|
||||||
crowd = new Crowd(config, navMesh, __ => new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
crowd = new Crowd(config, navMesh, __ => new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
||||||
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f }));
|
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f }));
|
||||||
|
|
||||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams(crowd.getObstacleAvoidanceParams(0));
|
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams(crowd.getObstacleAvoidanceParams(0));
|
||||||
// Low (11)
|
// Low (11)
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
option.adaptiveDivs = 5;
|
option.adaptiveDivs = 5;
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class CrowdTool : Tool
|
||||||
|
|
||||||
// Setup local avoidance option to different qualities.
|
// Setup local avoidance option to different qualities.
|
||||||
// Use mostly default settings, copy from dtCrowd.
|
// Use mostly default settings, copy from dtCrowd.
|
||||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams(crowd.getObstacleAvoidanceParams(0));
|
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams(crowd.getObstacleAvoidanceParams(0));
|
||||||
|
|
||||||
// Low (11)
|
// Low (11)
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
|
|
|
@ -70,25 +70,25 @@ public class AbstractCrowdTest
|
||||||
query = new NavMeshQuery(navmesh);
|
query = new NavMeshQuery(navmesh);
|
||||||
CrowdConfig config = new CrowdConfig(0.6f);
|
CrowdConfig config = new CrowdConfig(0.6f);
|
||||||
crowd = new Crowd(config, navmesh);
|
crowd = new Crowd(config, navmesh);
|
||||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams();
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
option.adaptiveDivs = 5;
|
option.adaptiveDivs = 5;
|
||||||
option.adaptiveRings = 2;
|
option.adaptiveRings = 2;
|
||||||
option.adaptiveDepth = 1;
|
option.adaptiveDepth = 1;
|
||||||
crowd.setObstacleAvoidanceParams(0, option);
|
crowd.setObstacleAvoidanceParams(0, option);
|
||||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
option = new ObstacleAvoidanceParams();
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
option.adaptiveDivs = 5;
|
option.adaptiveDivs = 5;
|
||||||
option.adaptiveRings = 2;
|
option.adaptiveRings = 2;
|
||||||
option.adaptiveDepth = 2;
|
option.adaptiveDepth = 2;
|
||||||
crowd.setObstacleAvoidanceParams(1, option);
|
crowd.setObstacleAvoidanceParams(1, option);
|
||||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
option = new ObstacleAvoidanceParams();
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
option.adaptiveDivs = 7;
|
option.adaptiveDivs = 7;
|
||||||
option.adaptiveRings = 2;
|
option.adaptiveRings = 2;
|
||||||
option.adaptiveDepth = 3;
|
option.adaptiveDepth = 3;
|
||||||
crowd.setObstacleAvoidanceParams(2, option);
|
crowd.setObstacleAvoidanceParams(2, option);
|
||||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
option = new ObstacleAvoidanceParams();
|
||||||
option.velBias = 0.5f;
|
option.velBias = 0.5f;
|
||||||
option.adaptiveDivs = 7;
|
option.adaptiveDivs = 7;
|
||||||
option.adaptiveRings = 3;
|
option.adaptiveRings = 3;
|
||||||
|
|
Loading…
Reference in New Issue