diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index 11dfeb4..8aa7e7d 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -551,7 +551,7 @@ public class RecastDemo Logger.Information($"build"); - Tuple, DtNavMesh> buildResult; + NavMeshBuildResult buildResult; if (settings.tiled) { buildResult = tileNavMeshBuilder.Build( @@ -600,7 +600,7 @@ public class RecastDemo ); } - sample.Update(sample.GetInputGeom(), buildResult.Item1, buildResult.Item2); + sample.Update(sample.GetInputGeom(), buildResult.RecastBuilderResults, buildResult.NavMesh); sample.SetChanged(false); settingsView.SetBuildTime((RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond); //settingsUI.SetBuildTelemetry(buildResult.Item1.Select(x => x.GetTelemetry()).ToList()); @@ -608,7 +608,7 @@ public class RecastDemo Logger.Information($"build times"); Logger.Information($"-----------------------------------------"); - var telemetries = buildResult.Item1 + var telemetries = buildResult.RecastBuilderResults .Select(x => x.GetTelemetry()) .SelectMany(x => x.ToList()) .GroupBy(x => x.Item1) diff --git a/src/DotRecast.Recast.DemoTool/Builder/NavMeshBuildResult.cs b/src/DotRecast.Recast.DemoTool/Builder/NavMeshBuildResult.cs new file mode 100644 index 0000000..f735b51 --- /dev/null +++ b/src/DotRecast.Recast.DemoTool/Builder/NavMeshBuildResult.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using DotRecast.Detour; + +namespace DotRecast.Recast.DemoTool.Builder +{ + public class NavMeshBuildResult + { + public readonly IList RecastBuilderResults; + public readonly DtNavMesh NavMesh; + + public NavMeshBuildResult(IList recastBuilderResults, DtNavMesh navMesh) + { + RecastBuilderResults = recastBuilderResults; + NavMesh = navMesh; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs index f5f090d..6de7da2 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs @@ -26,7 +26,7 @@ namespace DotRecast.Recast.DemoTool.Builder { public class SoloNavMeshBuilder : AbstractNavMeshBuilder { - public Tuple, DtNavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType, + public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, @@ -36,10 +36,10 @@ namespace DotRecast.Recast.DemoTool.Builder agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError, vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans, filterWalkableLowHeightSpans); - return Tuple.Create(ImmutableArray.Create(rcResult) as IList, - BuildNavMesh( - BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult), - vertsPerPoly)); + + var meshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult); + var navMesh = BuildNavMesh(meshData, vertsPerPoly); + return new NavMeshBuildResult(ImmutableArray.Create(rcResult), navMesh); } private DtNavMesh BuildNavMesh(DtMeshData meshData, int vertsPerPoly) diff --git a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs index 11ae927..9b98dc9 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs @@ -32,20 +32,19 @@ namespace DotRecast.Recast.DemoTool.Builder { } - public Tuple, DtNavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType, + public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize) { - List rcResult = BuildRecastResult(geom, partitionType, cellSize, cellHeight, agentHeight, + List results = BuildRecastResult(geom, partitionType, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError, vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans, filterWalkableLowHeightSpans, tileSize); - return Tuple.Create((IList)rcResult, - BuildNavMesh(geom, - BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult), - cellSize, tileSize, vertsPerPoly)); + var tileMeshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, results); + var tileNavMesh = BuildNavMesh(geom, tileMeshData, cellSize, tileSize, vertsPerPoly); + return new NavMeshBuildResult(results, tileNavMesh); } private List BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, @@ -64,13 +63,10 @@ namespace DotRecast.Recast.DemoTool.Builder return rcBuilder.BuildTiles(geom, cfg, Task.Factory); } - private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List meshData, float cellSize, int tileSize, - int vertsPerPoly) + private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List meshData, float cellSize, int tileSize, int vertsPerPoly) { DtNavMeshParams navMeshParams = new DtNavMeshParams(); - navMeshParams.orig.x = geom.GetMeshBoundsMin().x; - navMeshParams.orig.y = geom.GetMeshBoundsMin().y; - navMeshParams.orig.z = geom.GetMeshBoundsMin().z; + navMeshParams.orig = geom.GetMeshBoundsMin(); navMeshParams.tileWidth = tileSize * cellSize; navMeshParams.tileHeight = tileSize * cellSize;