From 8bc3afa2ec050816e786f812a1b02384bfecd408 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 1 Jul 2023 12:50:25 +0900 Subject: [PATCH] rename Telemetry -> RcTelemetry, add RcTelemetryTick --- .../DtCrowdTelemetry.cs | 1 + .../Colliders/AbstractCollider.cs | 2 +- .../Colliders/BoxCollider.cs | 2 +- .../Colliders/CapsuleCollider.cs | 2 +- .../Colliders/CompositeCollider.cs | 2 +- .../Colliders/ConvexTrimeshCollider.cs | 2 +- .../Colliders/CylinderCollider.cs | 2 +- .../Colliders/ICollider.cs | 2 +- .../Colliders/SphereCollider.cs | 2 +- .../Colliders/TrimeshCollider.cs | 2 +- .../DynamicNavMesh.cs | 4 +-- src/DotRecast.Detour.Dynamic/DynamicTile.cs | 6 ++-- src/DotRecast.Recast.Demo/RecastDemo.cs | 4 +-- .../{Telemetry.cs => RcTelemetry.cs} | 28 +++++++++++-------- src/DotRecast.Recast/RcTelemetryTick.cs | 17 +++++++++++ src/DotRecast.Recast/Recast.cs | 4 +-- src/DotRecast.Recast/RecastArea.cs | 10 +++---- src/DotRecast.Recast/RecastBuilder.cs | 10 +++---- src/DotRecast.Recast/RecastBuilderResult.cs | 6 ++-- src/DotRecast.Recast/RecastCompact.cs | 2 +- src/DotRecast.Recast/RecastContour.cs | 4 +-- .../RecastFilledVolumeRasterization.cs | 10 +++---- src/DotRecast.Recast/RecastFilter.cs | 6 ++-- src/DotRecast.Recast/RecastLayers.cs | 2 +- src/DotRecast.Recast/RecastMesh.cs | 10 +++---- src/DotRecast.Recast/RecastMeshDetail.cs | 16 +++++------ src/DotRecast.Recast/RecastRasterization.cs | 6 ++-- src/DotRecast.Recast/RecastRegion.cs | 12 ++++---- src/DotRecast.Recast/RecastVoxelization.cs | 2 +- .../RecastSoloMeshTest.cs | 6 ++-- test/DotRecast.Recast.Test/RecastTest.cs | 2 +- 31 files changed, 105 insertions(+), 81 deletions(-) rename src/DotRecast.Recast/{Telemetry.cs => RcTelemetry.cs} (67%) create mode 100644 src/DotRecast.Recast/RcTelemetryTick.cs diff --git a/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs b/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs index 7009687..8017b37 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs @@ -29,6 +29,7 @@ namespace DotRecast.Detour.Crowd public const int TIMING_SAMPLES = 10; private float _maxTimeToEnqueueRequest; private float _maxTimeToFindPath; + private readonly Dictionary _executionTimings = new Dictionary(); private readonly Dictionary> _executionTimingSamples = new Dictionary>(); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/AbstractCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/AbstractCollider.cs index 36c7709..e5ad8d1 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/AbstractCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/AbstractCollider.cs @@ -38,6 +38,6 @@ namespace DotRecast.Detour.Dynamic.Colliders return _bounds; } - public abstract void Rasterize(RcHeightfield hf, Telemetry telemetry); + public abstract void Rasterize(RcHeightfield hf, RcTelemetry telemetry); } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs index e7fa087..b9872b9 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs @@ -60,7 +60,7 @@ namespace DotRecast.Detour.Dynamic.Colliders return bounds; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { RecastFilledVolumeRasterization.RasterizeBox( hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs index 8a0830c..144c580 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs @@ -36,7 +36,7 @@ namespace DotRecast.Detour.Dynamic.Colliders this.radius = radius; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { RecastFilledVolumeRasterization.RasterizeCapsule(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/CompositeCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/CompositeCollider.cs index df14135..571ff72 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/CompositeCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/CompositeCollider.cs @@ -66,7 +66,7 @@ namespace DotRecast.Detour.Dynamic.Colliders return bounds; } - public void Rasterize(RcHeightfield hf, Telemetry telemetry) + public void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { foreach (var c in colliders) c.Rasterize(hf, telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/ConvexTrimeshCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/ConvexTrimeshCollider.cs index 4e0f46e..54bb289 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/ConvexTrimeshCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/ConvexTrimeshCollider.cs @@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders this.triangles = triangles; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { RecastFilledVolumeRasterization.RasterizeConvex(hf, vertices, triangles, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs index b62f313..883f121 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs @@ -36,7 +36,7 @@ namespace DotRecast.Detour.Dynamic.Colliders this.radius = radius; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { RecastFilledVolumeRasterization.RasterizeCylinder(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/ICollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/ICollider.cs index 4d466fd..c2f6aa5 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/ICollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/ICollider.cs @@ -23,6 +23,6 @@ namespace DotRecast.Detour.Dynamic.Colliders public interface ICollider { float[] Bounds(); - void Rasterize(RcHeightfield hf, Telemetry telemetry); + void Rasterize(RcHeightfield hf, RcTelemetry telemetry); } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs index 6a573de..34dace1 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs @@ -34,7 +34,7 @@ namespace DotRecast.Detour.Dynamic.Colliders this.radius = radius; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { RecastFilledVolumeRasterization.RasterizeSphere(hf, center, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); diff --git a/src/DotRecast.Detour.Dynamic/Colliders/TrimeshCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/TrimeshCollider.cs index b9f4ff0..ad1ec62 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/TrimeshCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/TrimeshCollider.cs @@ -56,7 +56,7 @@ namespace DotRecast.Detour.Dynamic.Colliders return bounds; } - public override void Rasterize(RcHeightfield hf, Telemetry telemetry) + public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry) { for (int i = 0; i < triangles.Length; i += 3) { diff --git a/src/DotRecast.Detour.Dynamic/DynamicNavMesh.cs b/src/DotRecast.Detour.Dynamic/DynamicNavMesh.cs index 9021446..afa3add 100644 --- a/src/DotRecast.Detour.Dynamic/DynamicNavMesh.cs +++ b/src/DotRecast.Detour.Dynamic/DynamicNavMesh.cs @@ -35,7 +35,7 @@ namespace DotRecast.Detour.Dynamic public readonly DynamicNavMeshConfig config; private readonly RecastBuilder builder; private readonly Dictionary _tiles = new Dictionary(); - private readonly Telemetry telemetry; + private readonly RcTelemetry telemetry; private readonly DtNavMeshParams navMeshParams; private readonly BlockingCollection updateQueue = new BlockingCollection(); private readonly RcAtomicLong currentColliderId = new RcAtomicLong(0); @@ -72,7 +72,7 @@ namespace DotRecast.Detour.Dynamic } ; - telemetry = new Telemetry(); + telemetry = new RcTelemetry(); } public DtNavMesh NavMesh() diff --git a/src/DotRecast.Detour.Dynamic/DynamicTile.cs b/src/DotRecast.Detour.Dynamic/DynamicTile.cs index 14b1e1c..83dda02 100644 --- a/src/DotRecast.Detour.Dynamic/DynamicTile.cs +++ b/src/DotRecast.Detour.Dynamic/DynamicTile.cs @@ -42,7 +42,7 @@ namespace DotRecast.Detour.Dynamic this.voxelTile = voxelTile; } - public bool Build(RecastBuilder builder, DynamicNavMeshConfig config, Telemetry telemetry) + public bool Build(RecastBuilder builder, DynamicNavMeshConfig config, RcTelemetry telemetry) { if (dirty) { @@ -57,7 +57,7 @@ namespace DotRecast.Detour.Dynamic return false; } - private RcHeightfield BuildHeightfield(DynamicNavMeshConfig config, Telemetry telemetry) + private RcHeightfield BuildHeightfield(DynamicNavMeshConfig config, RcTelemetry telemetry) { ICollection rasterizedColliders = checkpoint != null ? checkpoint.colliders : ImmutableHashSet.Empty; RcHeightfield heightfield = checkpoint != null ? checkpoint.heightfield : voxelTile.Heightfield(); @@ -79,7 +79,7 @@ namespace DotRecast.Detour.Dynamic } private RecastBuilderResult BuildRecast(RecastBuilder builder, DynamicNavMeshConfig config, VoxelTile vt, - RcHeightfield heightfield, Telemetry telemetry) + RcHeightfield heightfield, RcTelemetry telemetry) { RcConfig rcConfig = new RcConfig(config.useTiles, config.tileSizeX, config.tileSizeZ, vt.borderSize, config.partitionType, vt.cellSize, vt.cellHeight, config.walkableSlopeAngle, true, true, true, diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index 8aa7e7d..a4b6bda 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -611,8 +611,8 @@ public class RecastDemo var telemetries = buildResult.RecastBuilderResults .Select(x => x.GetTelemetry()) .SelectMany(x => x.ToList()) - .GroupBy(x => x.Item1) - .ToImmutableSortedDictionary(x => x.Key, x => x.Sum(y => y.Item2)); + .GroupBy(x => x.Key) + .ToImmutableSortedDictionary(x => x.Key, x => x.Sum(y => y.Millis)); foreach (var (key, millis) in telemetries) { diff --git a/src/DotRecast.Recast/Telemetry.cs b/src/DotRecast.Recast/RcTelemetry.cs similarity index 67% rename from src/DotRecast.Recast/Telemetry.cs rename to src/DotRecast.Recast/RcTelemetry.cs index 8bc2981..b23bf8a 100644 --- a/src/DotRecast.Recast/Telemetry.cs +++ b/src/DotRecast.Recast/RcTelemetry.cs @@ -26,32 +26,38 @@ using DotRecast.Core; namespace DotRecast.Recast { - public class Telemetry + public class RcTelemetry { - private readonly ThreadLocal> timerStart = new ThreadLocal>(() => new Dictionary()); - private readonly ConcurrentDictionary timerAccum = new ConcurrentDictionary(); + private readonly ThreadLocal> _timerStart; + private readonly ConcurrentDictionary _timerAccum; + + public RcTelemetry() + { + _timerStart = new ThreadLocal>(() => new Dictionary()); + _timerAccum = new ConcurrentDictionary(); + } public void StartTimer(string name) { - timerStart.Value[name] = new RcAtomicLong(RcFrequency.Ticks); + _timerStart.Value[name] = new RcAtomicLong(RcFrequency.Ticks); } public void StopTimer(string name) { - timerAccum + _timerAccum .GetOrAdd(name, _ => new RcAtomicLong(0)) - .AddAndGet(RcFrequency.Ticks - timerStart.Value?[name].Read() ?? 0); + .AddAndGet(RcFrequency.Ticks - _timerStart.Value?[name].Read() ?? 0); } - public void Warn(string @string) + public void Warn(string message) { - Console.WriteLine(@string); + Console.WriteLine(message); } - public List> ToList() + public List ToList() { - return timerAccum - .Select(x => Tuple.Create(x.Key, x.Value.Read() / TimeSpan.TicksPerMillisecond)) + return _timerAccum + .Select(x => new RcTelemetryTick(x.Key, x.Value.Read())) .ToList(); } } diff --git a/src/DotRecast.Recast/RcTelemetryTick.cs b/src/DotRecast.Recast/RcTelemetryTick.cs new file mode 100644 index 0000000..5f096a2 --- /dev/null +++ b/src/DotRecast.Recast/RcTelemetryTick.cs @@ -0,0 +1,17 @@ +using System; + +namespace DotRecast.Recast +{ + public readonly struct RcTelemetryTick + { + public readonly string Key; + public readonly long Ticks; + public long Millis => Ticks / TimeSpan.TicksPerMillisecond; + + public RcTelemetryTick(string key, long ticks) + { + Key = key; + Ticks = ticks; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/Recast.cs b/src/DotRecast.Recast/Recast.cs index c85df63..826f1d2 100644 --- a/src/DotRecast.Recast/Recast.cs +++ b/src/DotRecast.Recast/Recast.cs @@ -67,7 +67,7 @@ namespace DotRecast.Recast /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles - public static int[] MarkWalkableTriangles(Telemetry ctx, float walkableSlopeAngle, float[] verts, int[] tris, int nt, AreaModification areaMod) + public static int[] MarkWalkableTriangles(RcTelemetry ctx, float walkableSlopeAngle, float[] verts, int[] tris, int nt, AreaModification areaMod) { int[] areas = new int[nt]; float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); @@ -103,7 +103,7 @@ namespace DotRecast.Recast /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles - public static void ClearUnwalkableTriangles(Telemetry ctx, float walkableSlopeAngle, float[] verts, int nv, int[] tris, int nt, int[] areas) + public static void ClearUnwalkableTriangles(RcTelemetry ctx, float walkableSlopeAngle, float[] verts, int nv, int[] tris, int nt, int[] areas) { float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); diff --git a/src/DotRecast.Recast/RecastArea.cs b/src/DotRecast.Recast/RecastArea.cs index 8a1235c..5504155 100644 --- a/src/DotRecast.Recast/RecastArea.cs +++ b/src/DotRecast.Recast/RecastArea.cs @@ -35,7 +35,7 @@ namespace DotRecast.Recast /// This method is usually called immediately after the heightfield has been built. /// /// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius - public static void ErodeWalkableArea(Telemetry ctx, int radius, RcCompactHeightfield chf) + public static void ErodeWalkableArea(RcTelemetry ctx, int radius, RcCompactHeightfield chf) { int w = chf.width; int h = chf.height; @@ -215,7 +215,7 @@ namespace DotRecast.Recast /// such as #rcMarkBoxArea, #rcMarkConvexPolyArea, and #rcMarkCylinderArea. /// /// @see rcCompactHeightfield - public static bool MedianFilterWalkableArea(Telemetry ctx, RcCompactHeightfield chf) + public static bool MedianFilterWalkableArea(RcTelemetry ctx, RcCompactHeightfield chf) { int w = chf.width; int h = chf.height; @@ -283,7 +283,7 @@ namespace DotRecast.Recast /// The value of spacial parameters are in world units. /// /// @see rcCompactHeightfield, rcMedianFilterWalkableArea - public static void MarkBoxArea(Telemetry ctx, float[] bmin, float[] bmax, AreaModification areaMod, RcCompactHeightfield chf) + public static void MarkBoxArea(RcTelemetry ctx, float[] bmin, float[] bmax, AreaModification areaMod, RcCompactHeightfield chf) { ctx.StartTimer("MARK_BOX_AREA"); @@ -357,7 +357,7 @@ namespace DotRecast.Recast /// projected onto the xz-plane at @p hmin, then extruded to @p hmax. /// /// @see rcCompactHeightfield, rcMedianFilterWalkableArea - public static void MarkConvexPolyArea(Telemetry ctx, float[] verts, float hmin, float hmax, AreaModification areaMod, + public static void MarkConvexPolyArea(RcTelemetry ctx, float[] verts, float hmin, float hmax, AreaModification areaMod, RcCompactHeightfield chf) { ctx.StartTimer("MARK_CONVEXPOLY_AREA"); @@ -513,7 +513,7 @@ namespace DotRecast.Recast /// The value of spacial parameters are in world units. /// /// @see rcCompactHeightfield, rcMedianFilterWalkableArea - public static void MarkCylinderArea(Telemetry ctx, float[] pos, float r, float h, AreaModification areaMod, RcCompactHeightfield chf) + public static void MarkCylinderArea(RcTelemetry ctx, float[] pos, float r, float h, AreaModification areaMod, RcCompactHeightfield chf) { ctx.StartTimer("MARK_CYLINDER_AREA"); diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index 43f05a1..00998cf 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -158,7 +158,7 @@ namespace DotRecast.Recast public RecastBuilderResult Build(IInputGeomProvider geom, RecastBuilderConfig builderCfg) { RcConfig cfg = builderCfg.cfg; - Telemetry ctx = new Telemetry(); + RcTelemetry ctx = new RcTelemetry(); // // Step 1. Rasterize input polygon soup. // @@ -167,7 +167,7 @@ namespace DotRecast.Recast } public RecastBuilderResult Build(int tileX, int tileZ, IConvexVolumeProvider geom, RcConfig cfg, RcHeightfield solid, - Telemetry ctx) + RcTelemetry ctx) { FilterHeightfield(solid, cfg, ctx); RcCompactHeightfield chf = BuildCompactHeightfield(geom, cfg, ctx, solid); @@ -257,7 +257,7 @@ namespace DotRecast.Recast /* * Step 2. Filter walkable surfaces. */ - private void FilterHeightfield(RcHeightfield solid, RcConfig cfg, Telemetry ctx) + private void FilterHeightfield(RcHeightfield solid, RcConfig cfg, RcTelemetry ctx) { // Once all geometry is rasterized, we do initial pass of filtering to // remove unwanted overhangs caused by the conservative rasterization @@ -281,7 +281,7 @@ namespace DotRecast.Recast /* * Step 3. Partition walkable surface to simple regions. */ - private RcCompactHeightfield BuildCompactHeightfield(IConvexVolumeProvider volumeProvider, RcConfig cfg, Telemetry ctx, + private RcCompactHeightfield BuildCompactHeightfield(IConvexVolumeProvider volumeProvider, RcConfig cfg, RcTelemetry ctx, RcHeightfield solid) { // Compact the heightfield so that it is faster to handle from now on. @@ -305,7 +305,7 @@ namespace DotRecast.Recast public RcHeightfieldLayerSet BuildLayers(IInputGeomProvider geom, RecastBuilderConfig builderCfg) { - Telemetry ctx = new Telemetry(); + RcTelemetry ctx = new RcTelemetry(); RcHeightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx); FilterHeightfield(solid, builderCfg.cfg, ctx); RcCompactHeightfield chf = BuildCompactHeightfield(geom, builderCfg.cfg, ctx, solid); diff --git a/src/DotRecast.Recast/RecastBuilderResult.cs b/src/DotRecast.Recast/RecastBuilderResult.cs index 4f36763..2e792c9 100644 --- a/src/DotRecast.Recast/RecastBuilderResult.cs +++ b/src/DotRecast.Recast/RecastBuilderResult.cs @@ -9,9 +9,9 @@ private readonly RcPolyMesh pmesh; private readonly RcPolyMeshDetail dmesh; private readonly RcHeightfield solid; - private readonly Telemetry telemetry; + private readonly RcTelemetry telemetry; - public RecastBuilderResult(int tileX, int tileZ, RcHeightfield solid, RcCompactHeightfield chf, RcContourSet cs, RcPolyMesh pmesh, RcPolyMeshDetail dmesh, Telemetry ctx) + public RecastBuilderResult(int tileX, int tileZ, RcHeightfield solid, RcCompactHeightfield chf, RcContourSet cs, RcPolyMesh pmesh, RcPolyMeshDetail dmesh, RcTelemetry ctx) { this.tileX = tileX; this.tileZ = tileZ; @@ -48,7 +48,7 @@ return solid; } - public Telemetry GetTelemetry() + public RcTelemetry GetTelemetry() { return telemetry; } diff --git a/src/DotRecast.Recast/RecastCompact.cs b/src/DotRecast.Recast/RecastCompact.cs index 504575a..68c70c2 100644 --- a/src/DotRecast.Recast/RecastCompact.cs +++ b/src/DotRecast.Recast/RecastCompact.cs @@ -37,7 +37,7 @@ namespace DotRecast.Recast /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig - public static RcCompactHeightfield BuildCompactHeightfield(Telemetry ctx, int walkableHeight, int walkableClimb, + public static RcCompactHeightfield BuildCompactHeightfield(RcTelemetry ctx, int walkableHeight, int walkableClimb, RcHeightfield hf) { ctx.StartTimer("BUILD_COMPACTHEIGHTFIELD"); diff --git a/src/DotRecast.Recast/RecastContour.cs b/src/DotRecast.Recast/RecastContour.cs index b9e4bf2..666de2f 100644 --- a/src/DotRecast.Recast/RecastContour.cs +++ b/src/DotRecast.Recast/RecastContour.cs @@ -607,7 +607,7 @@ namespace DotRecast.Recast return new int[] { minx, minz, leftmost }; } - private static void MergeRegionHoles(Telemetry ctx, RcContourRegion region) + private static void MergeRegionHoles(RcTelemetry ctx, RcContourRegion region) { // Sort holes from left to right. for (int i = 0; i < region.nholes; i++) @@ -713,7 +713,7 @@ namespace DotRecast.Recast /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig - public static RcContourSet BuildContours(Telemetry ctx, RcCompactHeightfield chf, float maxError, int maxEdgeLen, + public static RcContourSet BuildContours(RcTelemetry ctx, RcCompactHeightfield chf, float maxError, int maxEdgeLen, int buildFlags) { int w = chf.width; diff --git a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs index 44f6c7a..c92e2a0 100644 --- a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs +++ b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs @@ -29,7 +29,7 @@ namespace DotRecast.Recast private const float EPSILON = 0.00001f; private static readonly int[] BOX_EDGES = new[] { 0, 1, 0, 2, 0, 4, 1, 3, 1, 5, 2, 3, 2, 6, 3, 7, 4, 5, 4, 6, 5, 7, 6, 7 }; - public static void RasterizeSphere(RcHeightfield hf, RcVec3f center, float radius, int area, int flagMergeThr, Telemetry ctx) + public static void RasterizeSphere(RcHeightfield hf, RcVec3f center, float radius, int area, int flagMergeThr, RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_SPHERE"); float[] bounds = @@ -43,7 +43,7 @@ namespace DotRecast.Recast } public static void RasterizeCapsule(RcHeightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, - Telemetry ctx) + RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_CAPSULE"); float[] bounds = @@ -59,7 +59,7 @@ namespace DotRecast.Recast } public static void RasterizeCylinder(RcHeightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, - Telemetry ctx) + RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_CYLINDER"); float[] bounds = @@ -75,7 +75,7 @@ namespace DotRecast.Recast } public static void RasterizeBox(RcHeightfield hf, RcVec3f center, RcVec3f[] halfEdges, int area, int flagMergeThr, - Telemetry ctx) + RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_BOX"); RcVec3f[] normals = @@ -127,7 +127,7 @@ namespace DotRecast.Recast } public static void RasterizeConvex(RcHeightfield hf, float[] vertices, int[] triangles, int area, int flagMergeThr, - Telemetry ctx) + RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_CONVEX"); float[] bounds = new float[] { vertices[0], vertices[1], vertices[2], vertices[0], vertices[1], vertices[2] }; diff --git a/src/DotRecast.Recast/RecastFilter.cs b/src/DotRecast.Recast/RecastFilter.cs index 7a7e1ec..089233c 100644 --- a/src/DotRecast.Recast/RecastFilter.cs +++ b/src/DotRecast.Recast/RecastFilter.cs @@ -37,7 +37,7 @@ namespace DotRecast.Recast /// #rcFilterLedgeSpans after calling this filter. /// /// @see rcHeightfield, rcConfig - public static void FilterLowHangingWalkableObstacles(Telemetry ctx, int walkableClimb, RcHeightfield solid) + public static void FilterLowHangingWalkableObstacles(RcTelemetry ctx, int walkableClimb, RcHeightfield solid) { ctx.StartTimer("FILTER_LOW_OBSTACLES"); @@ -84,7 +84,7 @@ namespace DotRecast.Recast /// A span is a ledge if: RcAbs(currentSpan.smax - neighborSpan.smax) > walkableClimb /// /// @see rcHeightfield, rcConfig - public static void FilterLedgeSpans(Telemetry ctx, int walkableHeight, int walkableClimb, RcHeightfield solid) + public static void FilterLedgeSpans(RcTelemetry ctx, int walkableHeight, int walkableClimb, RcHeightfield solid) { ctx.StartTimer("FILTER_LEDGE"); @@ -177,7 +177,7 @@ namespace DotRecast.Recast /// maximum to the next higher span's minimum. (Same grid column.) /// /// @see rcHeightfield, rcConfig - public static void FilterWalkableLowHeightSpans(Telemetry ctx, int walkableHeight, RcHeightfield solid) + public static void FilterWalkableLowHeightSpans(RcTelemetry ctx, int walkableHeight, RcHeightfield solid) { ctx.StartTimer("FILTER_WALKABLE"); diff --git a/src/DotRecast.Recast/RecastLayers.cs b/src/DotRecast.Recast/RecastLayers.cs index 6ed4dcc..5b4a4c2 100644 --- a/src/DotRecast.Recast/RecastLayers.cs +++ b/src/DotRecast.Recast/RecastLayers.cs @@ -51,7 +51,7 @@ namespace DotRecast.Recast return (amin > bmax || amax < bmin) ? false : true; } - public static RcHeightfieldLayerSet BuildHeightfieldLayers(Telemetry ctx, RcCompactHeightfield chf, int walkableHeight) + public static RcHeightfieldLayerSet BuildHeightfieldLayers(RcTelemetry ctx, RcCompactHeightfield chf, int walkableHeight) { ctx.StartTimer("RC_TIMER_BUILD_LAYERS"); int w = chf.width; diff --git a/src/DotRecast.Recast/RecastMesh.cs b/src/DotRecast.Recast/RecastMesh.cs index d37d0f5..653c84a 100644 --- a/src/DotRecast.Recast/RecastMesh.cs +++ b/src/DotRecast.Recast/RecastMesh.cs @@ -574,7 +574,7 @@ namespace DotRecast.Recast return an; } - private static bool CanRemoveVertex(Telemetry ctx, RcPolyMesh mesh, int rem) + private static bool CanRemoveVertex(RcTelemetry ctx, RcPolyMesh mesh, int rem) { int nvp = mesh.nvp; @@ -677,7 +677,7 @@ namespace DotRecast.Recast return true; } - private static void RemoveVertex(Telemetry ctx, RcPolyMesh mesh, int rem, int maxTris) + private static void RemoveVertex(RcTelemetry ctx, RcPolyMesh mesh, int rem, int maxTris) { int nvp = mesh.nvp; @@ -964,7 +964,7 @@ namespace DotRecast.Recast /// limit must be retricted to <= #DT_VERTS_PER_POLYGON. /// /// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig - public static RcPolyMesh BuildPolyMesh(Telemetry ctx, RcContourSet cset, int nvp) + public static RcPolyMesh BuildPolyMesh(RcTelemetry ctx, RcContourSet cset, int nvp) { ctx.StartTimer("POLYMESH"); RcPolyMesh mesh = new RcPolyMesh(); @@ -1209,7 +1209,7 @@ namespace DotRecast.Recast } /// @see rcAllocPolyMesh, rcPolyMesh - public static RcPolyMesh MergePolyMeshes(Telemetry ctx, RcPolyMesh[] meshes, int nmeshes) + public static RcPolyMesh MergePolyMeshes(RcTelemetry ctx, RcPolyMesh[] meshes, int nmeshes) { if (nmeshes == 0 || meshes == null) return null; @@ -1338,7 +1338,7 @@ namespace DotRecast.Recast return mesh; } - public static RcPolyMesh CopyPolyMesh(Telemetry ctx, RcPolyMesh src) + public static RcPolyMesh CopyPolyMesh(RcTelemetry ctx, RcPolyMesh src) { RcPolyMesh dst = new RcPolyMesh(); diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs index 6f53415..3f3760d 100644 --- a/src/DotRecast.Recast/RecastMeshDetail.cs +++ b/src/DotRecast.Recast/RecastMeshDetail.cs @@ -442,7 +442,7 @@ namespace DotRecast.Recast return EV_UNDEF; } - private static void AddEdge(Telemetry ctx, List edges, int maxEdges, int s, int t, int l, int r) + private static void AddEdge(RcTelemetry ctx, List edges, int maxEdges, int s, int t, int l, int r) { if (edges.Count / 4 >= maxEdges) { @@ -510,7 +510,7 @@ namespace DotRecast.Recast return false; } - static int CompleteFacet(Telemetry ctx, float[] pts, int npts, List edges, int maxEdges, int nfaces, int e) + static int CompleteFacet(RcTelemetry ctx, float[] pts, int npts, List edges, int maxEdges, int nfaces, int e) { const float EPS = 1e-5f; @@ -627,7 +627,7 @@ namespace DotRecast.Recast return nfaces; } - private static void DelaunayHull(Telemetry ctx, int npts, float[] pts, int nhull, int[] hull, List tris) + private static void DelaunayHull(RcTelemetry ctx, int npts, float[] pts, int nhull, int[] hull, List tris) { int nfaces = 0; int maxEdges = npts * 10; @@ -831,7 +831,7 @@ namespace DotRecast.Recast return (((i * 0xd8163841) & 0xffff) / 65535.0f * 2.0f) - 1.0f; } - static int BuildPolyDetail(Telemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError, + static int BuildPolyDetail(RcTelemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError, int heightSearchRadius, RcCompactHeightfield chf, RcHeightPatch hp, float[] verts, List tris) { List samples = new List(512); @@ -1113,7 +1113,7 @@ namespace DotRecast.Recast return nverts; } - static void SeedArrayWithPolyCenter(Telemetry ctx, RcCompactHeightfield chf, int[] meshpoly, int poly, int npoly, + static void SeedArrayWithPolyCenter(RcTelemetry ctx, RcCompactHeightfield chf, int[] meshpoly, int poly, int npoly, int[] verts, int bs, RcHeightPatch hp, List array) { // Note: Reads to the compact heightfield are offset by border size (bs) @@ -1271,7 +1271,7 @@ namespace DotRecast.Recast queue.Add(v3); } - static void GetHeightData(Telemetry ctx, RcCompactHeightfield chf, int[] meshpolys, int poly, int npoly, int[] verts, + static void GetHeightData(RcTelemetry ctx, RcCompactHeightfield chf, int[] meshpolys, int poly, int npoly, int[] verts, int bs, RcHeightPatch hp, int region) { // Note: Reads to the compact heightfield are offset by border size (bs) @@ -1423,7 +1423,7 @@ namespace DotRecast.Recast /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig - public static RcPolyMeshDetail BuildPolyMeshDetail(Telemetry ctx, RcPolyMesh mesh, RcCompactHeightfield chf, + public static RcPolyMeshDetail BuildPolyMeshDetail(RcTelemetry ctx, RcPolyMesh mesh, RcCompactHeightfield chf, float sampleDist, float sampleMaxError) { ctx.StartTimer("POLYMESHDETAIL"); @@ -1615,7 +1615,7 @@ namespace DotRecast.Recast } /// @see rcAllocPolyMeshDetail, rcPolyMeshDetail - private static RcPolyMeshDetail MergePolyMeshDetails(Telemetry ctx, RcPolyMeshDetail[] meshes, int nmeshes) + private static RcPolyMeshDetail MergePolyMeshDetails(RcTelemetry ctx, RcPolyMeshDetail[] meshes, int nmeshes) { RcPolyMeshDetail mesh = new RcPolyMeshDetail(); diff --git a/src/DotRecast.Recast/RecastRasterization.cs b/src/DotRecast.Recast/RecastRasterization.cs index 8e1dbd1..16c9975 100644 --- a/src/DotRecast.Recast/RecastRasterization.cs +++ b/src/DotRecast.Recast/RecastRasterization.cs @@ -398,7 +398,7 @@ namespace DotRecast.Recast * @see Heightfield */ public static void RasterizeTriangle(RcHeightfield heightfield, float[] verts, int v0, int v1, int v2, int area, - int flagMergeThreshold, Telemetry ctx) + int flagMergeThreshold, RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_TRIANGLES"); @@ -429,7 +429,7 @@ namespace DotRecast.Recast * @see Heightfield */ public static void RasterizeTriangles(RcHeightfield heightfield, float[] verts, int[] tris, int[] areaIds, int numTris, - int flagMergeThreshold, Telemetry ctx) + int flagMergeThreshold, RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_TRIANGLES"); @@ -466,7 +466,7 @@ namespace DotRecast.Recast * @see Heightfield */ public static void RasterizeTriangles(RcHeightfield heightfield, float[] verts, int[] areaIds, int numTris, - int flagMergeThreshold, Telemetry ctx) + int flagMergeThreshold, RcTelemetry ctx) { ctx.StartTimer("RASTERIZE_TRIANGLES"); diff --git a/src/DotRecast.Recast/RecastRegion.cs b/src/DotRecast.Recast/RecastRegion.cs index 05885eb..109ae3e 100644 --- a/src/DotRecast.Recast/RecastRegion.cs +++ b/src/DotRecast.Recast/RecastRegion.cs @@ -847,7 +847,7 @@ namespace DotRecast.Recast } } - private static int MergeAndFilterRegions(Telemetry ctx, int minRegionArea, int mergeRegionSize, int maxRegionId, + private static int MergeAndFilterRegions(RcTelemetry ctx, int minRegionArea, int mergeRegionSize, int maxRegionId, RcCompactHeightfield chf, int[] srcReg, List overlaps) { int w = chf.width; @@ -1169,7 +1169,7 @@ namespace DotRecast.Recast } } - private static int MergeAndFilterLayerRegions(Telemetry ctx, int minRegionArea, int maxRegionId, + private static int MergeAndFilterLayerRegions(RcTelemetry ctx, int minRegionArea, int maxRegionId, RcCompactHeightfield chf, int[] srcReg, List overlaps) { int w = chf.width; @@ -1415,7 +1415,7 @@ namespace DotRecast.Recast /// and rcCompactHeightfield::dist fields. /// /// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone - public static void BuildDistanceField(Telemetry ctx, RcCompactHeightfield chf) + public static void BuildDistanceField(RcTelemetry ctx, RcCompactHeightfield chf) { ctx.StartTimer("DISTANCEFIELD"); int[] src = new int[chf.spanCount]; @@ -1478,7 +1478,7 @@ namespace DotRecast.Recast /// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions. /// /// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig - public static void BuildRegionsMonotone(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea, + public static void BuildRegionsMonotone(RcTelemetry ctx, RcCompactHeightfield chf, int minRegionArea, int mergeRegionArea) { ctx.StartTimer("REGIONS"); @@ -1661,7 +1661,7 @@ namespace DotRecast.Recast /// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions. /// /// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig - public static void BuildRegions(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea, + public static void BuildRegions(RcTelemetry ctx, RcCompactHeightfield chf, int minRegionArea, int mergeRegionArea) { ctx.StartTimer("REGIONS"); @@ -1786,7 +1786,7 @@ namespace DotRecast.Recast ctx.StopTimer("REGIONS"); } - public static void BuildLayerRegions(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea) + public static void BuildLayerRegions(RcTelemetry ctx, RcCompactHeightfield chf, int minRegionArea) { ctx.StartTimer("REGIONS"); diff --git a/src/DotRecast.Recast/RecastVoxelization.cs b/src/DotRecast.Recast/RecastVoxelization.cs index 3f2ecac..8a5b3f6 100644 --- a/src/DotRecast.Recast/RecastVoxelization.cs +++ b/src/DotRecast.Recast/RecastVoxelization.cs @@ -23,7 +23,7 @@ namespace DotRecast.Recast { public static class RecastVoxelization { - public static RcHeightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg, Telemetry ctx) + public static RcHeightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg, RcTelemetry ctx) { RcConfig cfg = builderCfg.cfg; diff --git a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs index a697da5..8eb50b9 100644 --- a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs @@ -100,7 +100,7 @@ public class RecastSoloMeshTest long time = RcFrequency.Ticks; RcVec3f bmin = geomProvider.GetMeshBoundsMin(); RcVec3f bmax = geomProvider.GetMeshBoundsMax(); - Telemetry m_ctx = new Telemetry(); + RcTelemetry m_ctx = new RcTelemetry(); // // Step 1. Initialize build config. // @@ -262,9 +262,9 @@ public class RecastSoloMeshTest 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 + ".obj", m_pmesh); - foreach (var (key, millis) in m_ctx.ToList()) + foreach (var rtt in m_ctx.ToList()) { - Console.WriteLine($"{key} : {millis} ms"); + Console.WriteLine($"{rtt.Key} : {rtt.Millis} ms"); } } diff --git a/test/DotRecast.Recast.Test/RecastTest.cs b/test/DotRecast.Recast.Test/RecastTest.cs index ebb1735..432ca90 100644 --- a/test/DotRecast.Recast.Test/RecastTest.cs +++ b/test/DotRecast.Recast.Test/RecastTest.cs @@ -35,7 +35,7 @@ public class RecastTest int[] unwalkable_tri = { 0, 2, 1 }; int nt = 1; - Telemetry ctx = new Telemetry(); + RcTelemetry ctx = new RcTelemetry(); { int[] areas = { 42 }; Recast.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, unwalkable_tri, nt, areas);