forked from bit/DotRecastNetSim
remove Tuple<IList<RecastBuilderResult>, DtNavMesh>
This commit is contained in:
parent
e053f57571
commit
3878fd0b95
|
@ -551,7 +551,7 @@ public class RecastDemo
|
||||||
|
|
||||||
Logger.Information($"build");
|
Logger.Information($"build");
|
||||||
|
|
||||||
Tuple<IList<RecastBuilderResult>, DtNavMesh> buildResult;
|
NavMeshBuildResult buildResult;
|
||||||
if (settings.tiled)
|
if (settings.tiled)
|
||||||
{
|
{
|
||||||
buildResult = tileNavMeshBuilder.Build(
|
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);
|
sample.SetChanged(false);
|
||||||
settingsView.SetBuildTime((RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond);
|
settingsView.SetBuildTime((RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond);
|
||||||
//settingsUI.SetBuildTelemetry(buildResult.Item1.Select(x => x.GetTelemetry()).ToList());
|
//settingsUI.SetBuildTelemetry(buildResult.Item1.Select(x => x.GetTelemetry()).ToList());
|
||||||
|
@ -608,7 +608,7 @@ public class RecastDemo
|
||||||
|
|
||||||
Logger.Information($"build times");
|
Logger.Information($"build times");
|
||||||
Logger.Information($"-----------------------------------------");
|
Logger.Information($"-----------------------------------------");
|
||||||
var telemetries = buildResult.Item1
|
var telemetries = buildResult.RecastBuilderResults
|
||||||
.Select(x => x.GetTelemetry())
|
.Select(x => x.GetTelemetry())
|
||||||
.SelectMany(x => x.ToList())
|
.SelectMany(x => x.ToList())
|
||||||
.GroupBy(x => x.Item1)
|
.GroupBy(x => x.Item1)
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ namespace DotRecast.Recast.DemoTool.Builder
|
||||||
{
|
{
|
||||||
public class SoloNavMeshBuilder : AbstractNavMeshBuilder
|
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 cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
|
||||||
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
|
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
|
||||||
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
|
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
|
||||||
|
@ -36,10 +36,10 @@ namespace DotRecast.Recast.DemoTool.Builder
|
||||||
agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError,
|
agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError,
|
||||||
vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans,
|
vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans,
|
||||||
filterWalkableLowHeightSpans);
|
filterWalkableLowHeightSpans);
|
||||||
return Tuple.Create(ImmutableArray.Create(rcResult) as IList<RecastBuilderResult>,
|
|
||||||
BuildNavMesh(
|
var meshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult);
|
||||||
BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult),
|
var navMesh = BuildNavMesh(meshData, vertsPerPoly);
|
||||||
vertsPerPoly));
|
return new NavMeshBuildResult(ImmutableArray.Create(rcResult), navMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DtNavMesh BuildNavMesh(DtMeshData meshData, int vertsPerPoly)
|
private DtNavMesh BuildNavMesh(DtMeshData meshData, int vertsPerPoly)
|
||||||
|
|
|
@ -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 cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
|
||||||
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
|
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
|
||||||
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
|
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
|
||||||
bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize)
|
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,
|
agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError,
|
||||||
vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans,
|
vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans,
|
||||||
filterWalkableLowHeightSpans, tileSize);
|
filterWalkableLowHeightSpans, tileSize);
|
||||||
return Tuple.Create((IList<RecastBuilderResult>)rcResult,
|
var tileMeshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, results);
|
||||||
BuildNavMesh(geom,
|
var tileNavMesh = BuildNavMesh(geom, tileMeshData, cellSize, tileSize, vertsPerPoly);
|
||||||
BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult),
|
return new NavMeshBuildResult(results, tileNavMesh);
|
||||||
cellSize, tileSize, vertsPerPoly));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType,
|
private List<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType,
|
||||||
|
@ -64,13 +63,10 @@ namespace DotRecast.Recast.DemoTool.Builder
|
||||||
return rcBuilder.BuildTiles(geom, cfg, Task.Factory);
|
return rcBuilder.BuildTiles(geom, cfg, Task.Factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize,
|
private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize, int vertsPerPoly)
|
||||||
int vertsPerPoly)
|
|
||||||
{
|
{
|
||||||
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
||||||
navMeshParams.orig.x = geom.GetMeshBoundsMin().x;
|
navMeshParams.orig = geom.GetMeshBoundsMin();
|
||||||
navMeshParams.orig.y = geom.GetMeshBoundsMin().y;
|
|
||||||
navMeshParams.orig.z = geom.GetMeshBoundsMin().z;
|
|
||||||
navMeshParams.tileWidth = tileSize * cellSize;
|
navMeshParams.tileWidth = tileSize * cellSize;
|
||||||
navMeshParams.tileHeight = tileSize * cellSize;
|
navMeshParams.tileHeight = tileSize * cellSize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue