This commit is contained in:
ikpil 2023-09-12 23:57:00 +09:00
parent db6b222e25
commit 6e4d7e95a6
3 changed files with 45 additions and 48 deletions

View File

@ -119,7 +119,7 @@ namespace DotRecast.Recast.Demo
// int b = 3; // int b = 3;
// } // }
// //
// Console.WriteLine($"tileIdx({ti}) polyIdx({pi}) polyType({polyType} polyArea({polyArea})"); // Logger.Error($"tileIdx({ti}) polyIdx({pi}) polyType({polyType} polyArea({polyArea})");
// } // }
// //
// } // }

View File

@ -24,15 +24,12 @@ using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Dynamic; using DotRecast.Detour.Dynamic;
using DotRecast.Detour.Dynamic.Colliders;
using DotRecast.Detour.Dynamic.Io; using DotRecast.Detour.Dynamic.Io;
using DotRecast.Recast.Toolset.Builder;
using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Toolset.Geom;
using DotRecast.Recast.Toolset.Gizmos;
using DotRecast.Recast.Demo.UI;
using DotRecast.Recast.Toolset; using DotRecast.Recast.Toolset;
using DotRecast.Recast.Toolset.Gizmos;
using DotRecast.Recast.Toolset.Tools; using DotRecast.Recast.Toolset.Tools;
using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.UI;
using ImGuiNET; using ImGuiNET;
using Serilog; using Serilog;
using static DotRecast.Recast.Demo.Draw.DebugDraw; using static DotRecast.Recast.Demo.Draw.DebugDraw;
@ -509,7 +506,7 @@ public class DynamicUpdateSampleTool : ISampleTool
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Logger.Error(e, "");
} }
} }
@ -522,14 +519,14 @@ public class DynamicUpdateSampleTool : ISampleTool
dynaMesh = new DynamicNavMesh(voxelFile); dynaMesh = new DynamicNavMesh(voxelFile);
dynaMesh.config.keepIntermediateResults = true; dynaMesh.config.keepIntermediateResults = true;
UpdateUI(); UpdateFrom(dynaMesh.config);
BuildDynaMesh(); BuildDynaMesh();
colliderGizmos.Clear(); colliderGizmos.Clear();
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Logger.Error(e, "");
dynaMesh = null; dynaMesh = null;
} }
} }
@ -543,7 +540,7 @@ public class DynamicUpdateSampleTool : ISampleTool
private void BuildDynaMesh() private void BuildDynaMesh()
{ {
ConfigDynaMesh(); UpdateTo(dynaMesh.config);
long t = RcFrequency.Ticks; long t = RcFrequency.Ticks;
try try
{ {
@ -551,51 +548,51 @@ public class DynamicUpdateSampleTool : ISampleTool
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Logger.Error(e, "");
} }
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond; buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
_sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); _sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
} }
private void ConfigDynaMesh() private void UpdateTo(DynamicNavMeshConfig config)
{ {
dynaMesh.config.partition = partitioning; config.partition = partitioning;
dynaMesh.config.walkableHeight = walkableHeight; config.walkableHeight = walkableHeight;
dynaMesh.config.walkableSlopeAngle = walkableSlopeAngle; config.walkableSlopeAngle = walkableSlopeAngle;
dynaMesh.config.walkableRadius = walkableRadius; config.walkableRadius = walkableRadius;
dynaMesh.config.walkableClimb = walkableClimb; config.walkableClimb = walkableClimb;
dynaMesh.config.filterLowHangingObstacles = filterLowHangingObstacles; config.filterLowHangingObstacles = filterLowHangingObstacles;
dynaMesh.config.filterLedgeSpans = filterLedgeSpans; config.filterLedgeSpans = filterLedgeSpans;
dynaMesh.config.filterWalkableLowHeightSpans = filterWalkableLowHeightSpans; config.filterWalkableLowHeightSpans = filterWalkableLowHeightSpans;
dynaMesh.config.minRegionArea = minRegionArea; config.minRegionArea = minRegionArea;
dynaMesh.config.regionMergeArea = regionMergeSize; config.regionMergeArea = regionMergeSize;
dynaMesh.config.maxEdgeLen = maxEdgeLen; config.maxEdgeLen = maxEdgeLen;
dynaMesh.config.maxSimplificationError = maxSimplificationError; config.maxSimplificationError = maxSimplificationError;
dynaMesh.config.vertsPerPoly = vertsPerPoly; config.vertsPerPoly = vertsPerPoly;
dynaMesh.config.buildDetailMesh = buildDetailMesh; config.buildDetailMesh = buildDetailMesh;
dynaMesh.config.detailSampleDistance = detailSampleDist; config.detailSampleDistance = detailSampleDist;
dynaMesh.config.detailSampleMaxError = detailSampleMaxError; config.detailSampleMaxError = detailSampleMaxError;
} }
private void UpdateUI() private void UpdateFrom(DynamicNavMeshConfig config)
{ {
cellSize = dynaMesh.config.cellSize; cellSize = config.cellSize;
partitioning = (int)dynaMesh.config.partition; partitioning = config.partition;
walkableHeight = dynaMesh.config.walkableHeight; walkableHeight = config.walkableHeight;
walkableSlopeAngle = dynaMesh.config.walkableSlopeAngle; walkableSlopeAngle = config.walkableSlopeAngle;
walkableRadius = dynaMesh.config.walkableRadius; walkableRadius = config.walkableRadius;
walkableClimb = dynaMesh.config.walkableClimb; walkableClimb = config.walkableClimb;
minRegionArea = dynaMesh.config.minRegionArea; minRegionArea = config.minRegionArea;
regionMergeSize = dynaMesh.config.regionMergeArea; regionMergeSize = config.regionMergeArea;
maxEdgeLen = dynaMesh.config.maxEdgeLen; maxEdgeLen = config.maxEdgeLen;
maxSimplificationError = dynaMesh.config.maxSimplificationError; maxSimplificationError = config.maxSimplificationError;
vertsPerPoly = dynaMesh.config.vertsPerPoly; vertsPerPoly = config.vertsPerPoly;
buildDetailMesh = dynaMesh.config.buildDetailMesh; buildDetailMesh = config.buildDetailMesh;
detailSampleDist = dynaMesh.config.detailSampleDistance; detailSampleDist = config.detailSampleDistance;
detailSampleMaxError = dynaMesh.config.detailSampleMaxError; detailSampleMaxError = config.detailSampleMaxError;
filterLowHangingObstacles = dynaMesh.config.filterLowHangingObstacles; filterLowHangingObstacles = config.filterLowHangingObstacles;
filterLedgeSpans = dynaMesh.config.filterLedgeSpans; filterLedgeSpans = config.filterLedgeSpans;
filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans; filterWalkableLowHeightSpans = config.filterWalkableLowHeightSpans;
} }
} }