diff --git a/src/DotRecast.Detour.Crowd/DtCrowd.cs b/src/DotRecast.Detour.Crowd/DtCrowd.cs index ac035c6..5f19345 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowd.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowd.cs @@ -832,7 +832,7 @@ namespace DotRecast.Detour.Crowd continue; } - if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO) == 0) + if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO) == 0) { continue; } @@ -950,7 +950,7 @@ namespace DotRecast.Detour.Crowd // Check to see if the corner after the next corner is directly visible, // and short cut to there. - if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0) + if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0) { RcVec3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].pos; ag.corridor.OptimizePathVisibility(target, ag.option.pathOptimizationRange, _navQuery, @@ -1049,7 +1049,7 @@ namespace DotRecast.Detour.Crowd else { // Calculate steering direction. - if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS) != 0) + if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS) != 0) { dvel = ag.CalcSmoothSteerDirection(); } @@ -1067,7 +1067,7 @@ namespace DotRecast.Detour.Crowd } // Separation - if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_SEPARATION) != 0) + if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION) != 0) { float separationDist = ag.option.collisionQueryRange; float invSeparationDist = 1.0f / separationDist; @@ -1132,7 +1132,7 @@ namespace DotRecast.Detour.Crowd continue; } - if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE) != 0) + if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE) != 0) { _obstacleQuery.Reset(); diff --git a/src/DotRecast.Detour.Crowd/DtCrowdAgentConfig.cs b/src/DotRecast.Detour.Crowd/DtCrowdAgentConfig.cs index f25e522..d22a053 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdAgentConfig.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdAgentConfig.cs @@ -16,27 +16,27 @@ int updateFlags = 0; if (anticipateTurns) { - updateFlags |= DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS; + updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS; } if (optimizeVis) { - updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS; + updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS; } if (optimizeTopo) { - updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO; + updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO; } if (obstacleAvoidance) { - updateFlags |= DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; } if (separation) { - updateFlags |= DtCrowdAgentParams.DT_CROWD_SEPARATION; + updateFlags |= DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION; } return updateFlags; diff --git a/src/DotRecast.Detour.Crowd/DtCrowdAgentParams.cs b/src/DotRecast.Detour.Crowd/DtCrowdAgentParams.cs index 010d987..ca78784 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdAgentParams.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdAgentParams.cs @@ -45,18 +45,6 @@ namespace DotRecast.Detour.Crowd /// How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0] public float separationWeight; - /// Crowd agent update flags. - public const int DT_CROWD_ANTICIPATE_TURNS = 1; - - public const int DT_CROWD_OBSTACLE_AVOIDANCE = 2; - public const int DT_CROWD_SEPARATION = 4; - public const int DT_CROWD_OPTIMIZE_VIS = 8; - - /// < Use #dtPathCorridor::OptimizePathVisibility() to optimize - /// the agent path. - public const int DT_CROWD_OPTIMIZE_TOPO = 16; - - /// < Use dtPathCorridor::OptimizePathTopology() to optimize /// the agent path. /// Flags that impact steering behavior. (See: #UpdateFlags) public int updateFlags; diff --git a/src/DotRecast.Detour.Crowd/DtCrowdAgentUpdateFlags.cs b/src/DotRecast.Detour.Crowd/DtCrowdAgentUpdateFlags.cs new file mode 100644 index 0000000..6a69b1b --- /dev/null +++ b/src/DotRecast.Detour.Crowd/DtCrowdAgentUpdateFlags.cs @@ -0,0 +1,14 @@ +namespace DotRecast.Detour.Crowd +{ + /// Crowd agent update flags. + /// @ingroup crowd + /// @see dtCrowdAgentParams::updateFlags + public static class DtCrowdAgentUpdateFlags + { + public const int DT_CROWD_ANTICIPATE_TURNS = 1; + public const int DT_CROWD_OBSTACLE_AVOIDANCE = 2; + public const int DT_CROWD_SEPARATION = 4; + public const int DT_CROWD_OPTIMIZE_VIS = 8; //< Use #dtPathCorridor::optimizePathVisibility() to optimize the agent path. + public const int DT_CROWD_OPTIMIZE_TOPO = 16; //< Use dtPathCorridor::optimizePathTopology() to optimize the agent path. + } +} \ No newline at end of file diff --git a/test/DotRecast.Detour.Crowd.Test/Crowd1Test.cs b/test/DotRecast.Detour.Crowd.Test/Crowd1Test.cs index 40b5a3e..e35c9d7 100644 --- a/test/DotRecast.Detour.Crowd.Test/Crowd1Test.cs +++ b/test/DotRecast.Detour.Crowd.Test/Crowd1Test.cs @@ -565,8 +565,10 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality0TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -588,8 +590,9 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality0TVT() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO; AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -611,7 +614,7 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality0TV() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS; AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -633,7 +636,7 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality0T() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO; AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -655,8 +658,10 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality1TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(1, 0.4f, updateFlags, 1, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -678,8 +683,10 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality2TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(1, 0.4f, updateFlags, 2, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -701,8 +708,10 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality3TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(1, 0.4f, updateFlags, 3, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -724,9 +733,11 @@ public class Crowd1Test : AbstractCrowdTest [Test] public void TestAgent1Quality3TVTAS() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE - | DtCrowdAgentParams.DT_CROWD_SEPARATION; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE | + DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION; AddAgentGrid(1, 0.4f, updateFlags, 3, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -744,4 +755,4 @@ public class Crowd1Test : AbstractCrowdTest } } } -} +} \ No newline at end of file diff --git a/test/DotRecast.Detour.Crowd.Test/Crowd4Test.cs b/test/DotRecast.Detour.Crowd.Test/Crowd4Test.cs index 2d44d04..826bbc8 100644 --- a/test/DotRecast.Detour.Crowd.Test/Crowd4Test.cs +++ b/test/DotRecast.Detour.Crowd.Test/Crowd4Test.cs @@ -308,8 +308,10 @@ public class Crowd4Test : AbstractCrowdTest [Test] public void TestAgent1Quality2TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -329,9 +331,11 @@ public class Crowd4Test : AbstractCrowdTest [Test] public void TestAgent1Quality2TVTAS() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE - | DtCrowdAgentParams.DT_CROWD_SEPARATION; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE | + DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION; AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -351,7 +355,7 @@ public class Crowd4Test : AbstractCrowdTest [Test] public void TestAgent1Quality2T() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO; AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]); SetMoveTarget(endPoss[0], false); @@ -367,4 +371,4 @@ public class Crowd4Test : AbstractCrowdTest Assert.That(ag.nvel.z, Is.EqualTo(EXPECTED_A1Q2T[i][5]).Within(0.00001f), $"{i} - {ag.nvel.z} {EXPECTED_A1Q2T[i][5]}"); } } -} +} \ No newline at end of file diff --git a/test/DotRecast.Detour.Crowd.Test/Crowd4VelocityTest.cs b/test/DotRecast.Detour.Crowd.Test/Crowd4VelocityTest.cs index 4056ace..5dacba5 100644 --- a/test/DotRecast.Detour.Crowd.Test/Crowd4VelocityTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/Crowd4VelocityTest.cs @@ -99,8 +99,10 @@ public class Crowd4VelocityTest : AbstractCrowdTest [Test] public void TestAgent1Quality3TVTA() { - int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS - | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE; + int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS | + DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO | + DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE; AddAgentGrid(2, 0.3f, updateFlags, 3, endPoss[0]); SetMoveTarget(endPoss[4], false);