forked from mirror/DotRecast
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 List<CrowdAgent> m_agents;
|
||||
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 ProximityGrid m_grid;
|
||||
private readonly Vector3f m_ext = new Vector3f();
|
||||
|
@ -176,7 +176,7 @@ namespace DotRecast.Detour.Crowd
|
|||
// Init obstacle query option.
|
||||
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.
|
||||
|
@ -198,11 +198,11 @@ namespace DotRecast.Detour.Crowd
|
|||
/// @param[in] idx The index. [Limits: 0 <= value <
|
||||
/// #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
||||
/// @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)
|
||||
{
|
||||
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.
|
||||
/// [Limits: 0 <= value < #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
|
||||
/// @return The requested configuration.
|
||||
public ObstacleAvoidanceQuery.ObstacleAvoidanceParams getObstacleAvoidanceParams(int idx)
|
||||
public ObstacleAvoidanceParams getObstacleAvoidanceParams(int idx)
|
||||
{
|
||||
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
|
||||
{
|
||||
|
@ -1177,7 +1177,7 @@ namespace DotRecast.Detour.Crowd
|
|||
bool adaptive = true;
|
||||
int ns = 0;
|
||||
|
||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = m_obstacleQueryParams[ag.option.obstacleAvoidanceType];
|
||||
ObstacleAvoidanceParams option = m_obstacleQueryParams[ag.option.obstacleAvoidanceType];
|
||||
|
||||
if (adaptive)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj"/>
|
||||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</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;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -65,56 +65,7 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
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 float m_invHorizTime;
|
||||
private float m_vmax;
|
||||
|
|
|
@ -211,7 +211,7 @@ public class CrowdProfilingTool
|
|||
crowd = new Crowd(config, navMesh, __ => new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
||||
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)
|
||||
option.velBias = 0.5f;
|
||||
option.adaptiveDivs = 5;
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CrowdTool : Tool
|
|||
|
||||
// Setup local avoidance option to different qualities.
|
||||
// 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)
|
||||
option.velBias = 0.5f;
|
||||
|
|
|
@ -70,25 +70,25 @@ public class AbstractCrowdTest
|
|||
query = new NavMeshQuery(navmesh);
|
||||
CrowdConfig config = new CrowdConfig(0.6f);
|
||||
crowd = new Crowd(config, navmesh);
|
||||
ObstacleAvoidanceQuery.ObstacleAvoidanceParams option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
||||
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams();
|
||||
option.velBias = 0.5f;
|
||||
option.adaptiveDivs = 5;
|
||||
option.adaptiveRings = 2;
|
||||
option.adaptiveDepth = 1;
|
||||
crowd.setObstacleAvoidanceParams(0, option);
|
||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
||||
option = new ObstacleAvoidanceParams();
|
||||
option.velBias = 0.5f;
|
||||
option.adaptiveDivs = 5;
|
||||
option.adaptiveRings = 2;
|
||||
option.adaptiveDepth = 2;
|
||||
crowd.setObstacleAvoidanceParams(1, option);
|
||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
||||
option = new ObstacleAvoidanceParams();
|
||||
option.velBias = 0.5f;
|
||||
option.adaptiveDivs = 7;
|
||||
option.adaptiveRings = 2;
|
||||
option.adaptiveDepth = 3;
|
||||
crowd.setObstacleAvoidanceParams(2, option);
|
||||
option = new ObstacleAvoidanceQuery.ObstacleAvoidanceParams();
|
||||
option = new ObstacleAvoidanceParams();
|
||||
option.velBias = 0.5f;
|
||||
option.adaptiveDivs = 7;
|
||||
option.adaptiveRings = 3;
|
||||
|
|
Loading…
Reference in New Issue