forked from bit/DotRecastNetSim
crowd updage flags
This commit is contained in:
parent
c76d87380a
commit
07a7f4960b
|
@ -386,7 +386,7 @@ public class RecastDemo : IRecastDemoChannel
|
||||||
new ObstacleSampleTool(),
|
new ObstacleSampleTool(),
|
||||||
new OffMeshConnectionSampleTool(),
|
new OffMeshConnectionSampleTool(),
|
||||||
new ConvexVolumeSampleTool(),
|
new ConvexVolumeSampleTool(),
|
||||||
new CrowdampleTool(),
|
new CrowdSampleTool(),
|
||||||
new CrowdProfilingSampleTool(),
|
new CrowdProfilingSampleTool(),
|
||||||
new JumpLinkBuilderSampleTool(),
|
new JumpLinkBuilderSampleTool(),
|
||||||
new DynamicUpdateSampleTool()
|
new DynamicUpdateSampleTool()
|
||||||
|
|
|
@ -94,45 +94,12 @@ public class CrowdProfilingSampleTool : ISampleTool
|
||||||
ap.maxSpeed = settings.agentMaxSpeed;
|
ap.maxSpeed = settings.agentMaxSpeed;
|
||||||
ap.collisionQueryRange = ap.radius * 12.0f;
|
ap.collisionQueryRange = ap.radius * 12.0f;
|
||||||
ap.pathOptimizationRange = ap.radius * 30.0f;
|
ap.pathOptimizationRange = ap.radius * 30.0f;
|
||||||
ap.updateFlags = GetUpdateFlags();
|
ap.updateFlags = _option.GetUpdateFlags();
|
||||||
ap.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
ap.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
||||||
ap.separationWeight = _option.separationWeight;
|
ap.separationWeight = _option.separationWeight;
|
||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int GetUpdateFlags()
|
|
||||||
{
|
|
||||||
int updateFlags = 0;
|
|
||||||
if (_option.anticipateTurns)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.optimizeVis)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.optimizeTopo)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.obstacleAvoidance)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.separation)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_SEPARATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IRcToolable GetTool()
|
public IRcToolable GetTool()
|
||||||
{
|
{
|
||||||
return _tool;
|
return _tool;
|
||||||
|
@ -537,7 +504,6 @@ public class CrowdProfilingSampleTool : ISampleTool
|
||||||
|
|
||||||
private void UpdateAgentParams()
|
private void UpdateAgentParams()
|
||||||
{
|
{
|
||||||
int updateFlags = GetUpdateFlags();
|
|
||||||
if (crowd != null)
|
if (crowd != null)
|
||||||
{
|
{
|
||||||
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
|
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
|
||||||
|
@ -551,7 +517,7 @@ public class CrowdProfilingSampleTool : ISampleTool
|
||||||
option.pathOptimizationRange = ag.option.pathOptimizationRange;
|
option.pathOptimizationRange = ag.option.pathOptimizationRange;
|
||||||
option.queryFilterType = ag.option.queryFilterType;
|
option.queryFilterType = ag.option.queryFilterType;
|
||||||
option.userData = ag.option.userData;
|
option.userData = ag.option.userData;
|
||||||
option.updateFlags = updateFlags;
|
option.updateFlags = _option.GetUpdateFlags();
|
||||||
option.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
option.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
||||||
option.separationWeight = _option.separationWeight;
|
option.separationWeight = _option.separationWeight;
|
||||||
crowd.UpdateAgentParameters(ag, option);
|
crowd.UpdateAgentParameters(ag, option);
|
||||||
|
|
|
@ -35,9 +35,9 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
||||||
|
|
||||||
namespace DotRecast.Recast.Demo.Tools;
|
namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class CrowdampleTool : ISampleTool
|
public class CrowdSampleTool : ISampleTool
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Log.ForContext<CrowdampleTool>();
|
private static readonly ILogger Logger = Log.ForContext<CrowdSampleTool>();
|
||||||
|
|
||||||
private DemoSample _sample;
|
private DemoSample _sample;
|
||||||
private readonly RcCrowdTool _tool;
|
private readonly RcCrowdTool _tool;
|
||||||
|
@ -69,7 +69,7 @@ public class CrowdampleTool : ISampleTool
|
||||||
private bool m_showDetailAll;
|
private bool m_showDetailAll;
|
||||||
|
|
||||||
|
|
||||||
public CrowdampleTool()
|
public CrowdSampleTool()
|
||||||
{
|
{
|
||||||
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
|
||||||
_tool = new();
|
_tool = new();
|
||||||
|
@ -237,7 +237,7 @@ public class CrowdampleTool : ISampleTool
|
||||||
ap.maxSpeed = settings.agentMaxSpeed;
|
ap.maxSpeed = settings.agentMaxSpeed;
|
||||||
ap.collisionQueryRange = ap.radius * 12.0f;
|
ap.collisionQueryRange = ap.radius * 12.0f;
|
||||||
ap.pathOptimizationRange = ap.radius * 30.0f;
|
ap.pathOptimizationRange = ap.radius * 30.0f;
|
||||||
ap.updateFlags = GetUpdateFlags();
|
ap.updateFlags = _option.GetUpdateFlags();
|
||||||
ap.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
ap.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
||||||
ap.separationWeight = _option.separationWeight;
|
ap.separationWeight = _option.separationWeight;
|
||||||
return ap;
|
return ap;
|
||||||
|
@ -742,7 +742,6 @@ public class CrowdampleTool : ISampleTool
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int updateFlags = GetUpdateFlags();
|
|
||||||
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
|
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
|
||||||
{
|
{
|
||||||
DtCrowdAgentParams option = new DtCrowdAgentParams();
|
DtCrowdAgentParams option = new DtCrowdAgentParams();
|
||||||
|
@ -755,44 +754,13 @@ public class CrowdampleTool : ISampleTool
|
||||||
option.obstacleAvoidanceType = ag.option.obstacleAvoidanceType;
|
option.obstacleAvoidanceType = ag.option.obstacleAvoidanceType;
|
||||||
option.queryFilterType = ag.option.queryFilterType;
|
option.queryFilterType = ag.option.queryFilterType;
|
||||||
option.userData = ag.option.userData;
|
option.userData = ag.option.userData;
|
||||||
option.updateFlags = updateFlags;
|
option.updateFlags = _option.GetUpdateFlags();
|
||||||
option.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
option.obstacleAvoidanceType = _option.obstacleAvoidanceType;
|
||||||
option.separationWeight = _option.separationWeight;
|
option.separationWeight = _option.separationWeight;
|
||||||
crowd.UpdateAgentParameters(ag, option);
|
crowd.UpdateAgentParameters(ag, option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetUpdateFlags()
|
|
||||||
{
|
|
||||||
int updateFlags = 0;
|
|
||||||
if (_option.anticipateTurns)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.optimizeVis)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.optimizeTopo)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.obstacleAvoidance)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_option.separation)
|
|
||||||
{
|
|
||||||
updateFlags |= DtCrowdAgentParams.DT_CROWD_SEPARATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||||
{
|
{
|
|
@ -1,3 +1,5 @@
|
||||||
|
using DotRecast.Detour.Crowd;
|
||||||
|
|
||||||
namespace DotRecast.Recast.Toolset.Tools
|
namespace DotRecast.Recast.Toolset.Tools
|
||||||
{
|
{
|
||||||
public class CrowdOption
|
public class CrowdOption
|
||||||
|
@ -10,5 +12,36 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
public int obstacleAvoidanceType = 3;
|
public int obstacleAvoidanceType = 3;
|
||||||
public bool separation;
|
public bool separation;
|
||||||
public float separationWeight = 2f;
|
public float separationWeight = 2f;
|
||||||
|
|
||||||
|
public int GetUpdateFlags()
|
||||||
|
{
|
||||||
|
int updateFlags = 0;
|
||||||
|
if (anticipateTurns)
|
||||||
|
{
|
||||||
|
updateFlags |= DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optimizeVis)
|
||||||
|
{
|
||||||
|
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optimizeTopo)
|
||||||
|
{
|
||||||
|
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obstacleAvoidance)
|
||||||
|
{
|
||||||
|
updateFlags |= DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (separation)
|
||||||
|
{
|
||||||
|
updateFlags |= DtCrowdAgentParams.DT_CROWD_SEPARATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
return updateFlags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue