remove Tuple<IList<RecastBuilderResult>, DtNavMesh>

This commit is contained in:
ikpil 2023-07-01 11:47:42 +09:00
parent e053f57571
commit 3878fd0b95
4 changed files with 32 additions and 19 deletions

View File

@ -551,7 +551,7 @@ public class RecastDemo
Logger.Information($"build");
Tuple<IList<RecastBuilderResult>, 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)

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
using DotRecast.Detour;
namespace DotRecast.Recast.DemoTool.Builder
{
public class NavMeshBuildResult
{
public readonly IList<RecastBuilderResult> RecastBuilderResults;
public readonly DtNavMesh NavMesh;
public NavMeshBuildResult(IList<RecastBuilderResult> recastBuilderResults, DtNavMesh navMesh)
{
RecastBuilderResults = recastBuilderResults;
NavMesh = navMesh;
}
}
}

View File

@ -26,7 +26,7 @@ namespace DotRecast.Recast.DemoTool.Builder
{
public class SoloNavMeshBuilder : AbstractNavMeshBuilder
{
public Tuple<IList<RecastBuilderResult>, 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<RecastBuilderResult>,
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)

View File

@ -32,20 +32,19 @@ namespace DotRecast.Recast.DemoTool.Builder
{
}
public Tuple<IList<RecastBuilderResult>, 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<RecastBuilderResult> rcResult = BuildRecastResult(geom, partitionType, cellSize, cellHeight, agentHeight,
List<RecastBuilderResult> 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<RecastBuilderResult>)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<RecastBuilderResult> 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<DtMeshData> meshData, float cellSize, int tileSize,
int vertsPerPoly)
private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> 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;