From afc515c498788602be9c244d2731c2c965610d97 Mon Sep 17 00:00:00 2001 From: ikpil Date: Thu, 27 Jul 2023 14:29:34 +0900 Subject: [PATCH] build by sample settings --- src/DotRecast.Recast.Demo/RecastDemo.cs | 66 ++----------------- .../Builder/SoloNavMeshBuilder.cs | 11 ++++ .../Builder/TileNavMeshBuilder.cs | 12 ++++ .../Tools/TileToolImpl.cs | 8 ++- 4 files changed, 34 insertions(+), 63 deletions(-) diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index ace6c8b..c5dade8 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -502,7 +502,7 @@ public class RecastDemo : IRecastDemoChannel if (processHitTest) { processHitTest = false; - + RcVec3f rayStart = new RcVec3f(); RcVec3f rayEnd = new RcVec3f(); @@ -669,77 +669,21 @@ public class RecastDemo : IRecastDemoChannel return; } - var settings = _sample.GetSettings(); - var partitioning = settings.partitioning; - var cellSize = settings.cellSize; - var cellHeight = settings.cellHeight; - var agentHeight = settings.agentHeight; - var agentRadius = settings.agentRadius; - var agentMaxClimb = settings.agentMaxClimb; - var agentMaxSlope = settings.agentMaxSlope; - var regionMinSize = settings.minRegionSize; - var regionMergeSize = settings.mergedRegionSize; - var edgeMaxLen = settings.edgeMaxLen; - var edgeMaxError = settings.edgeMaxError; - var vertsPerPoly = settings.vertsPerPoly; - var detailSampleDist = settings.detailSampleDist; - var detailSampleMaxError = settings.detailSampleMaxError; - var filterLowHangingObstacles = settings.filterLowHangingObstacles; - var filterLedgeSpans = settings.filterLedgeSpans; - var filterWalkableLowHeightSpans = settings.filterWalkableLowHeightSpans; - var tileSize = settings.tileSize; long t = RcFrequency.Ticks; Logger.Information($"build"); NavMeshBuildResult buildResult; + + var settings = _sample.GetSettings(); if (settings.tiled) { - buildResult = tileNavMeshBuilder.Build( - _sample.GetInputGeom(), - partitioning, - cellSize, - cellHeight, - agentHeight, - agentRadius, - agentMaxClimb, - agentMaxSlope, - regionMinSize, - regionMergeSize, - edgeMaxLen, - edgeMaxError, - vertsPerPoly, - detailSampleDist, - detailSampleMaxError, - filterLowHangingObstacles, - filterLedgeSpans, - filterWalkableLowHeightSpans, - tileSize - ); + buildResult = tileNavMeshBuilder.Build(_sample.GetInputGeom(), settings); } else { - buildResult = soloNavMeshBuilder.Build( - _sample.GetInputGeom(), - partitioning, - cellSize, - cellHeight, - agentHeight, - agentRadius, - agentMaxClimb, - agentMaxSlope, - regionMinSize, - regionMergeSize, - edgeMaxLen, - edgeMaxError, - vertsPerPoly, - detailSampleDist, - detailSampleMaxError, - filterLowHangingObstacles, - filterLedgeSpans, - filterWalkableLowHeightSpans - ); + buildResult = soloNavMeshBuilder.Build(_sample.GetInputGeom(), settings); } _sample.Update(_sample.GetInputGeom(), buildResult.RecastBuilderResults, buildResult.NavMesh); diff --git a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs index 807cd93..f08edbc 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs @@ -26,6 +26,17 @@ namespace DotRecast.Recast.DemoTool.Builder { public class SoloNavMeshBuilder { + public NavMeshBuildResult Build(DemoInputGeomProvider geom, SampleSettings settings) + { + return Build(geom, + settings.partitioning, settings.cellSize, settings.cellHeight, settings.agentHeight, + settings.agentRadius, settings.agentMaxClimb, settings.agentMaxSlope, + settings.minRegionSize, settings.mergedRegionSize, + settings.edgeMaxLen, settings.edgeMaxError, + settings.vertsPerPoly, settings.detailSampleDist, settings.detailSampleMaxError, + settings.filterLowHangingObstacles, settings.filterLedgeSpans, settings.filterWalkableLowHeightSpans); + } + 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, diff --git a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs index 43cb29f..246113a 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs @@ -30,6 +30,18 @@ namespace DotRecast.Recast.DemoTool.Builder { } + public NavMeshBuildResult Build(DemoInputGeomProvider geom, SampleSettings settings) + { + return Build(geom, + settings.partitioning, settings.cellSize, settings.cellHeight, settings.agentHeight, + settings.agentRadius, settings.agentMaxClimb, settings.agentMaxSlope, + settings.minRegionSize, settings.mergedRegionSize, + settings.edgeMaxLen, settings.edgeMaxError, + settings.vertsPerPoly, settings.detailSampleDist, settings.detailSampleMaxError, + settings.filterLowHangingObstacles, settings.filterLedgeSpans, settings.filterWalkableLowHeightSpans, + settings.tileSize); + } + 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, diff --git a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs index b02024a..0fcc072 100644 --- a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs +++ b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs @@ -1,5 +1,6 @@ using DotRecast.Core; using DotRecast.Detour.TileCache; +using DotRecast.Recast.DemoTool.Builder; namespace DotRecast.Recast.DemoTool.Tools { @@ -37,8 +38,11 @@ namespace DotRecast.Recast.DemoTool.Tools int tx = (int)((pos.x - bmin[0]) / ts); int ty = (int)((pos.z - bmin[2]) / ts); - - var tileRef = navMesh.GetTileRefAt(tx, ty, 0); + + // var tnmb = new TileNavMeshBuilder(); + // tnmb.BuildRecastResult(geom, settings.partitioning, ) + + //var tileRef = navMesh.GetTileRefAt(tx, ty, 0); // navMesh.RemoveTile(tileRef); }