diff --git a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs index e97d9f3..d26b7d3 100644 --- a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs @@ -19,11 +19,8 @@ freely, subject to the following restrictions: */ using System; -using System.Collections.Generic; using DotRecast.Core.Numerics; using DotRecast.Detour; -using DotRecast.Detour.Crowd; -using DotRecast.Detour.Dynamic.Colliders; using DotRecast.Recast.Toolset.Builder; using Silk.NET.OpenGL; diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs index a2b06d5..0adef28 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs @@ -18,12 +18,9 @@ freely, subject to the following restrictions: */ using System; -using System.Collections.Generic; -using System.Linq; using DotRecast.Core.Numerics; using DotRecast.Detour; using DotRecast.Detour.Crowd; -using DotRecast.Recast.Toolset.Builder; using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Toolset; using DotRecast.Recast.Toolset.Tools; @@ -98,6 +95,11 @@ public class CrowdAgentProfilingSampleTool : ISampleTool ImGui.SliderInt("Max Iterations", ref toolCfg.maxIterations, 0, 4000); ImGui.NewLine(); + ImGui.Text("Debug Draw"); + ImGui.Separator(); + ImGui.Checkbox("Show Agents", ref toolCfg.showAgents); + ImGui.NewLine(); + if (ImGui.Button("Start Crowd Profiling")) { var settings = _sample.GetSettings(); @@ -118,11 +120,11 @@ public class CrowdAgentProfilingSampleTool : ISampleTool ImGui.Text($"{rtt.Key}: {rtt.Micros} us"); } - ImGui.Text($"Sampling Time: {_tool.GetCrowdUpdateSamplingTime()} ms"); - ImGui.Text($"Current Update Time: {_tool.GetCrowdUpdateTime()} ms"); - ImGui.Text($"Avg Update Time: {_tool.GetCrowdUpdateAvgTime()} ms"); - ImGui.Text($"Max Update Time: {_tool.GetCrowdUpdateMaxTime()} ms"); - ImGui.Text($"Min Update Time: {_tool.GetCrowdUpdateMinTime()} ms"); + ImGui.Text($"Sampling Time: {_tool.GetCrowdUpdateSamplingTime():0.00} ms"); + ImGui.Text($"Current Update Time: {_tool.GetCrowdUpdateTime():0.00} ms"); + ImGui.Text($"Avg Update Time: {_tool.GetCrowdUpdateAvgTime():0.00} ms"); + ImGui.Text($"Max Update Time: {_tool.GetCrowdUpdateMaxTime():0.00} ms"); + ImGui.Text($"Min Update Time: {_tool.GetCrowdUpdateMinTime():0.00} ms"); } } @@ -132,7 +134,7 @@ public class CrowdAgentProfilingSampleTool : ISampleTool dd.DepthMask(false); var crowd = _tool.GetCrowd(); - if (crowd != null) + if (crowd != null && _tool.GetToolConfig().showAgents) { foreach (DtCrowdAgent ag in crowd.GetActiveAgents()) { diff --git a/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs index 6a5227b..4f4adea 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -26,12 +26,12 @@ namespace DotRecast.Recast.Toolset.Tools private readonly List _polyPoints; private const int SamplingCount = 500; - private long _samplingUpdateTime; + private double _samplingUpdateTime; private readonly RcCyclicBuffer _updateTimes; - private long _curUpdateTime; - private long _avgUpdateTime; - private long _minUpdateTime; - private long _maxUpdateTime; + private double _curUpdateTime; + private double _avgUpdateTime; + private double _minUpdateTime; + private double _maxUpdateTime; public RcCrowdAgentProfilingTool() { @@ -269,11 +269,11 @@ namespace DotRecast.Recast.Toolset.Tools _updateTimes.PushBack(currentTime); // for benchmark - _samplingUpdateTime = _updateTimes.Sum() / TimeSpan.TicksPerMillisecond; - _curUpdateTime = currentTime / TimeSpan.TicksPerMillisecond; - _avgUpdateTime = (long)(_updateTimes.Average() / TimeSpan.TicksPerMillisecond); - _minUpdateTime = _updateTimes.Min() / TimeSpan.TicksPerMillisecond; - _maxUpdateTime = _updateTimes.Max() / TimeSpan.TicksPerMillisecond; + _samplingUpdateTime = _updateTimes.Sum() / (double)TimeSpan.TicksPerMillisecond; + _curUpdateTime = currentTime / (double)TimeSpan.TicksPerMillisecond; + _avgUpdateTime = (_updateTimes.Average() / (double)TimeSpan.TicksPerMillisecond); + _minUpdateTime = _updateTimes.Min() / (double)TimeSpan.TicksPerMillisecond; + _maxUpdateTime = _updateTimes.Max() / (double)TimeSpan.TicksPerMillisecond; } private void MoveMob(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, RcCrowdAgentData crowAgentData) @@ -374,27 +374,27 @@ namespace DotRecast.Recast.Toolset.Tools } } - public long GetCrowdUpdateSamplingTime() + public double GetCrowdUpdateSamplingTime() { return _samplingUpdateTime; } - public long GetCrowdUpdateTime() + public double GetCrowdUpdateTime() { return _curUpdateTime; } - public long GetCrowdUpdateAvgTime() + public double GetCrowdUpdateAvgTime() { return _avgUpdateTime; } - public long GetCrowdUpdateMinTime() + public double GetCrowdUpdateMinTime() { return _minUpdateTime; } - public long GetCrowdUpdateMaxTime() + public double GetCrowdUpdateMaxTime() { return _maxUpdateTime; } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs index 65794d1..6b6e753 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs @@ -1,4 +1,4 @@ -namespace DotRecast.Recast.Toolset.Tools +namespace DotRecast.Recast.Toolset.Tools { public class RcCrowdAgentProfilingToolConfig { @@ -12,5 +12,7 @@ public float percentTravellers = 15f; public int pathQueueSize = 32; public int maxIterations = 300; + + public bool showAgents = true; } } \ No newline at end of file