diff --git a/src/DotRecast.Detour.Crowd/Crowd.cs b/src/DotRecast.Detour.Crowd/Crowd.cs index a65127e..9715d87 100644 --- a/src/DotRecast.Detour.Crowd/Crowd.cs +++ b/src/DotRecast.Detour.Crowd/Crowd.cs @@ -145,7 +145,7 @@ namespace DotRecast.Detour.Crowd private readonly AtomicInteger agentId = new AtomicInteger(); private readonly List 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) { diff --git a/src/DotRecast.Detour.Crowd/DotRecast.Detour.Crowd.csproj b/src/DotRecast.Detour.Crowd/DotRecast.Detour.Crowd.csproj index 586f0a4..4d6a344 100644 --- a/src/DotRecast.Detour.Crowd/DotRecast.Detour.Crowd.csproj +++ b/src/DotRecast.Detour.Crowd/DotRecast.Detour.Crowd.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceParams.cs b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceParams.cs new file mode 100644 index 0000000..6f202ab --- /dev/null +++ b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceParams.cs @@ -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; + } + }; +} \ No newline at end of file diff --git a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs index 4487a89..d08b634 100644 --- a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs +++ b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs @@ -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; diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index 3ee32bc..45b3016 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -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; diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 526f124..61236fc 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -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; diff --git a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs index 65de701..8043325 100644 --- a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs @@ -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;