forked from bit/DotRecastNetSim
add detail build times
This commit is contained in:
parent
dcc13b6199
commit
762e62b757
|
@ -597,6 +597,7 @@ public class RecastDemo
|
||||||
sample.update(sample.getInputGeom(), buildResult.Item1, buildResult.Item2);
|
sample.update(sample.getInputGeom(), buildResult.Item1, buildResult.Item2);
|
||||||
sample.setChanged(false);
|
sample.setChanged(false);
|
||||||
settingsUI.setBuildTime((Stopwatch.GetTimestamp() - t) / TimeSpan.TicksPerMillisecond);
|
settingsUI.setBuildTime((Stopwatch.GetTimestamp() - t) / TimeSpan.TicksPerMillisecond);
|
||||||
|
settingsUI.setBuildTelemetry(buildResult.Item1.Select(x => x.getTelemetry()).ToList());
|
||||||
toolsUI.setSample(sample);
|
toolsUI.setSample(sample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@ freely, subject to the following restrictions:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using DotRecast.Core;
|
using DotRecast.Core;
|
||||||
using DotRecast.Recast.Demo.Draw;
|
using DotRecast.Recast.Demo.Draw;
|
||||||
using DotRecast.Recast.Demo.UI;
|
using DotRecast.Recast.Demo.UI;
|
||||||
|
@ -61,6 +63,7 @@ public class RcSettingsView : IRcView
|
||||||
// public readonly NkColor transparent = NkColor.create();
|
// public readonly NkColor transparent = NkColor.create();
|
||||||
private bool buildTriggered;
|
private bool buildTriggered;
|
||||||
private long buildTime;
|
private long buildTime;
|
||||||
|
private Dictionary<string, long> telemetries = new();
|
||||||
private readonly int[] voxels = new int[2];
|
private readonly int[] voxels = new int[2];
|
||||||
private readonly int[] tiles = new int[2];
|
private readonly int[] tiles = new int[2];
|
||||||
private int maxTiles;
|
private int maxTiles;
|
||||||
|
@ -177,6 +180,10 @@ public class RcSettingsView : IRcView
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
|
|
||||||
ImGui.Text($"Build Time: {buildTime} ms");
|
ImGui.Text($"Build Time: {buildTime} ms");
|
||||||
|
foreach (var (key, millis) in telemetries)
|
||||||
|
{
|
||||||
|
ImGui.Text($"{key}: {millis} ms");
|
||||||
|
}
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
buildTriggered = ImGui.Button("Build");
|
buildTriggered = ImGui.Button("Build");
|
||||||
const string strLoadNavMesh = "Load Nav Mesh...";
|
const string strLoadNavMesh = "Load Nav Mesh...";
|
||||||
|
@ -289,6 +296,15 @@ public class RcSettingsView : IRcView
|
||||||
this.buildTime = buildTime;
|
this.buildTime = buildTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBuildTelemetry(IList<Telemetry> telemetries)
|
||||||
|
{
|
||||||
|
this.telemetries = telemetries
|
||||||
|
.SelectMany(x => x.ToList())
|
||||||
|
.GroupBy(x => x.Item1)
|
||||||
|
.ToDictionary(x => x.Key, x => x.Sum(y => y.Item2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public DrawMode getDrawMode()
|
public DrawMode getDrawMode()
|
||||||
{
|
{
|
||||||
return drawMode;
|
return drawMode;
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
private readonly Heightfield solid;
|
private readonly Heightfield solid;
|
||||||
private readonly Telemetry telemetry;
|
private readonly Telemetry telemetry;
|
||||||
|
|
||||||
public RecastBuilderResult(int tileX, int tileZ, Heightfield solid, CompactHeightfield chf, ContourSet cs, PolyMesh pmesh,
|
public RecastBuilderResult(int tileX, int tileZ, Heightfield solid, CompactHeightfield chf, ContourSet cs, PolyMesh pmesh, PolyMeshDetail dmesh, Telemetry ctx)
|
||||||
PolyMeshDetail dmesh, Telemetry ctx)
|
|
||||||
{
|
{
|
||||||
this.tileX = tileX;
|
this.tileX = tileX;
|
||||||
this.tileZ = tileZ;
|
this.tileZ = tileZ;
|
||||||
|
|
|
@ -20,6 +20,7 @@ using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using DotRecast.Core;
|
using DotRecast.Core;
|
||||||
|
|
||||||
|
@ -47,12 +48,11 @@ namespace DotRecast.Recast
|
||||||
Console.WriteLine(@string);
|
Console.WriteLine(@string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print()
|
public List<Tuple<string, long>> ToList()
|
||||||
{
|
{
|
||||||
foreach (var (n, v) in timerAccum)
|
return timerAccum
|
||||||
{
|
.Select(x => Tuple.Create(x.Key, x.Value.Read() / TimeSpan.TicksPerMillisecond))
|
||||||
Console.WriteLine(n + ": " + v.Read() / TimeSpan.TicksPerMillisecond);
|
.ToList();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -261,7 +261,10 @@ public class RecastSoloMeshTest
|
||||||
Console.WriteLine(" " + (time3 - time) / TimeSpan.TicksPerMillisecond + " ms");
|
Console.WriteLine(" " + (time3 - time) / TimeSpan.TicksPerMillisecond + " ms");
|
||||||
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + "_detail.obj", m_dmesh);
|
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + "_detail.obj", m_dmesh);
|
||||||
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + ".obj", m_pmesh);
|
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + ".obj", m_pmesh);
|
||||||
m_ctx.print();
|
foreach (var (key, millis) in m_ctx.ToList())
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{key} : {millis} ms");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveObj(string filename, PolyMesh mesh)
|
private void saveObj(string filename, PolyMesh mesh)
|
||||||
|
|
Loading…
Reference in New Issue