reformat api

This commit is contained in:
ikpil 2023-09-02 14:24:47 +09:00
parent c62cfb0985
commit 3915a4418c
2 changed files with 45 additions and 23 deletions

View File

@ -31,38 +31,59 @@ namespace DotRecast.Recast.Toolset.Builder
{ {
} }
public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcNavMeshBuildSettings settings) public NavMeshBuildResult Build(IInputGeomProvider geom, RcNavMeshBuildSettings settings)
{ {
return Build(geom, return Build(geom,
RcPartitionType.OfValue(settings.partitioning), settings.cellSize, settings.cellHeight, settings.agentHeight, settings.tileSize,
settings.agentRadius, settings.agentMaxClimb, settings.agentMaxSlope, RcPartitionType.OfValue(settings.partitioning),
settings.cellSize, settings.cellHeight,
settings.agentMaxSlope, settings.agentHeight, settings.agentRadius, settings.agentMaxClimb,
settings.minRegionSize, settings.mergedRegionSize, settings.minRegionSize, settings.mergedRegionSize,
settings.edgeMaxLen, settings.edgeMaxError, settings.edgeMaxLen, settings.edgeMaxError,
settings.vertsPerPoly, settings.detailSampleDist, settings.detailSampleMaxError, settings.vertsPerPoly, settings.detailSampleDist, settings.detailSampleMaxError,
settings.filterLowHangingObstacles, settings.filterLedgeSpans, settings.filterWalkableLowHeightSpans, settings.filterLowHangingObstacles, settings.filterLedgeSpans, settings.filterWalkableLowHeightSpans);
settings.tileSize);
} }
public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcPartition partitionType, public NavMeshBuildResult Build(IInputGeomProvider geom,
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, int tileSize,
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, RcPartition partitionType,
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, float cellSize, float cellHeight,
bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize) float agentMaxSlope, float agentHeight, float agentRadius, float agentMaxClimb,
int regionMinSize, int regionMergeSize,
float edgeMaxLen, float edgeMaxError,
int vertsPerPoly,
float detailSampleDist, float detailSampleMaxError,
bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans)
{ {
List<RecastBuilderResult> results = BuildRecastResult(geom, partitionType, cellSize, cellHeight, agentHeight, List<RecastBuilderResult> results = BuildRecastResult(
agentRadius, agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError, geom,
vertsPerPoly, detailSampleDist, detailSampleMaxError, filterLowHangingObstacles, filterLedgeSpans, tileSize,
filterWalkableLowHeightSpans, tileSize); partitionType,
cellSize, cellHeight,
agentMaxSlope, agentHeight, agentRadius, agentMaxClimb,
regionMinSize, regionMergeSize,
edgeMaxLen, edgeMaxError,
vertsPerPoly,
detailSampleDist, detailSampleMaxError,
filterLowHangingObstacles, filterLedgeSpans, filterWalkableLowHeightSpans
);
var tileMeshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, results); var tileMeshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, results);
var tileNavMesh = BuildNavMesh(geom, tileMeshData, cellSize, tileSize, vertsPerPoly); var tileNavMesh = BuildNavMesh(geom, tileMeshData, cellSize, tileSize, vertsPerPoly);
return new NavMeshBuildResult(results, tileNavMesh); return new NavMeshBuildResult(results, tileNavMesh);
} }
public List<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, RcPartition partitionType, public List<RecastBuilderResult> BuildRecastResult(IInputGeomProvider geom,
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, int tileSize,
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, RcPartition partitionType,
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, float cellSize, float cellHeight,
bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize) float agentMaxSlope, float agentHeight, float agentRadius, float agentMaxClimb,
int regionMinSize, int regionMergeSize,
float edgeMaxLen, float edgeMaxError,
int vertsPerPoly,
float detailSampleDist, float detailSampleMaxError,
bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans)
{ {
RcConfig cfg = new RcConfig(true, tileSize, tileSize, RcConfig cfg = new RcConfig(true, tileSize, tileSize,
RcConfig.CalcBorder(agentRadius, cellSize), RcConfig.CalcBorder(agentRadius, cellSize),
@ -79,7 +100,7 @@ namespace DotRecast.Recast.Toolset.Builder
return rcBuilder.BuildTiles(geom, cfg, Task.Factory); return rcBuilder.BuildTiles(geom, cfg, Task.Factory);
} }
public DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize, int vertsPerPoly) public DtNavMesh BuildNavMesh(IInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize, int vertsPerPoly)
{ {
DtNavMeshParams navMeshParams = new DtNavMeshParams(); DtNavMeshParams navMeshParams = new DtNavMeshParams();
navMeshParams.orig = geom.GetMeshBoundsMin(); navMeshParams.orig = geom.GetMeshBoundsMin();
@ -120,19 +141,19 @@ namespace DotRecast.Recast.Toolset.Builder
} }
public int GetMaxTiles(DemoInputGeomProvider geom, float cellSize, int tileSize) public int GetMaxTiles(IInputGeomProvider geom, float cellSize, int tileSize)
{ {
int tileBits = GetTileBits(geom, cellSize, tileSize); int tileBits = GetTileBits(geom, cellSize, tileSize);
return 1 << tileBits; return 1 << tileBits;
} }
public int GetMaxPolysPerTile(DemoInputGeomProvider geom, float cellSize, int tileSize) public int GetMaxPolysPerTile(IInputGeomProvider geom, float cellSize, int tileSize)
{ {
int polyBits = 22 - GetTileBits(geom, cellSize, tileSize); int polyBits = 22 - GetTileBits(geom, cellSize, tileSize);
return 1 << polyBits; return 1 << polyBits;
} }
private int GetTileBits(DemoInputGeomProvider geom, float cellSize, int tileSize) private int GetTileBits(IInputGeomProvider geom, float cellSize, int tileSize)
{ {
RcUtils.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh); RcUtils.CalcGridSize(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), cellSize, out var gw, out var gh);
int tw = (gw + tileSize - 1) / tileSize; int tw = (gw + tileSize - 1) / tileSize;

View File

@ -6,6 +6,7 @@ namespace DotRecast.Recast
{ {
public readonly int tileX; public readonly int tileX;
public readonly int tileZ; public readonly int tileZ;
private readonly RcCompactHeightfield chf; private readonly RcCompactHeightfield chf;
private readonly RcContourSet cs; private readonly RcContourSet cs;
private readonly RcPolyMesh pmesh; private readonly RcPolyMesh pmesh;