From 2842c65bb752d771915b82e346b63797b04f68e2 Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 28 Jul 2023 20:43:50 +0900 Subject: [PATCH] for unity3d --- .../DynamicNavMeshConfig.cs | 2 +- src/DotRecast.Detour.Dynamic/DynamicTile.cs | 5 +-- src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs | 8 ++--- .../Tools/DynamicUpdateTool.cs | 11 +++--- .../UI/RcSettingsView.cs | 4 +-- .../Builder/SoloNavMeshBuilder.cs | 8 ++--- .../Builder/TileNavMeshBuilder.cs | 8 ++--- ...leSettings.cs => RcNavMeshBuildSetting.cs} | 5 ++- src/DotRecast.Recast.DemoTool/Sample.cs | 6 ++-- .../Tools/TileToolImpl.cs | 2 +- src/DotRecast.Recast/PartitionType.cs | 32 ----------------- src/DotRecast.Recast/RcConfig.cs | 10 +++--- src/DotRecast.Recast/RcPartition.cs | 9 +++++ src/DotRecast.Recast/RcPartitionType.cs | 34 +++++++++++++++++++ src/DotRecast.Recast/RecastBuilder.cs | 4 +-- .../RecastTestMeshBuilder.cs | 4 +-- .../Io/MeshSetReaderWriterTest.cs | 2 +- .../RecastTestMeshBuilder.cs | 4 +-- .../TestTiledNavMeshBuilder.cs | 4 +-- .../TestTileLayerBuilder.cs | 2 +- .../DotRecast.Recast.Test/RecastLayersTest.cs | 4 +-- .../RecastSoloMeshTest.cs | 26 +++++++------- .../RecastTileMeshTest.cs | 2 +- 23 files changed, 103 insertions(+), 93 deletions(-) rename src/DotRecast.Recast.DemoTool/{SampleSettings.cs => RcNavMeshBuildSetting.cs} (86%) delete mode 100644 src/DotRecast.Recast/PartitionType.cs create mode 100644 src/DotRecast.Recast/RcPartition.cs create mode 100644 src/DotRecast.Recast/RcPartitionType.cs diff --git a/src/DotRecast.Detour.Dynamic/DynamicNavMeshConfig.cs b/src/DotRecast.Detour.Dynamic/DynamicNavMeshConfig.cs index 18cb2d3..ca355f9 100644 --- a/src/DotRecast.Detour.Dynamic/DynamicNavMeshConfig.cs +++ b/src/DotRecast.Detour.Dynamic/DynamicNavMeshConfig.cs @@ -26,7 +26,7 @@ namespace DotRecast.Detour.Dynamic public readonly int tileSizeX; public readonly int tileSizeZ; public readonly float cellSize; - public PartitionType partitionType = PartitionType.WATERSHED; + public int partition = RcPartitionType.WATERSHED.Value; public RcAreaModification walkableAreaModification = new RcAreaModification(1); public float walkableHeight; public float walkableSlopeAngle; diff --git a/src/DotRecast.Detour.Dynamic/DynamicTile.cs b/src/DotRecast.Detour.Dynamic/DynamicTile.cs index d8e4f71..26c9b7c 100644 --- a/src/DotRecast.Detour.Dynamic/DynamicTile.cs +++ b/src/DotRecast.Detour.Dynamic/DynamicTile.cs @@ -82,8 +82,9 @@ namespace DotRecast.Detour.Dynamic private RecastBuilderResult BuildRecast(RecastBuilder builder, DynamicNavMeshConfig config, VoxelTile vt, RcHeightfield heightfield, RcTelemetry telemetry) { - RcConfig rcConfig = new RcConfig(config.useTiles, config.tileSizeX, config.tileSizeZ, vt.borderSize, - config.partitionType, vt.cellSize, vt.cellHeight, config.walkableSlopeAngle, true, true, true, + RcConfig rcConfig = new RcConfig( + config.useTiles, config.tileSizeX, config.tileSizeZ, vt.borderSize, + RcPartitionType.OfValue(config.partition), vt.cellSize, vt.cellHeight, config.walkableSlopeAngle, true, true, true, config.walkableHeight, config.walkableRadius, config.walkableClimb, config.minRegionArea, config.regionMergeArea, config.maxEdgeLen, config.maxSimplificationError, Math.Min(DynamicNavMesh.MAX_VERTS_PER_POLY, config.vertsPerPoly), true, config.detailSampleDistance, diff --git a/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs b/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs index bdaa3ea..067ec90 100644 --- a/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs +++ b/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs @@ -32,7 +32,7 @@ namespace DotRecast.Detour.Dynamic.Io public const int VERSION_EXPORTER_RECAST4J = 0x1000; public const int VERSION_COMPRESSION_LZ4 = 0x0100; public int version; - public PartitionType partitionType = PartitionType.WATERSHED; + public int partition = RcPartitionType.WATERSHED.Value; public bool filterLowHangingObstacles = true; public bool filterLedgeSpans = true; public bool filterWalkableLowHeightSpans = true; @@ -61,7 +61,7 @@ namespace DotRecast.Detour.Dynamic.Io tiles.Add(tile); } - public RcConfig GetConfig(VoxelTile tile, PartitionType partitionType, int maxPolyVerts, int regionMergeSize, + public RcConfig GetConfig(VoxelTile tile, RcPartition partitionType, int maxPolyVerts, int regionMergeSize, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, RcAreaModification walkbableAreaMod, bool buildMeshDetail, float detailSampleDist, float detailSampleMaxError) { @@ -75,7 +75,7 @@ namespace DotRecast.Detour.Dynamic.Io { VoxelFile f = new VoxelFile(); f.version = 1; - f.partitionType = config.partitionType; + f.partition = config.partition; f.filterLowHangingObstacles = config.filterLowHangingObstacles; f.filterLedgeSpans = config.filterLedgeSpans; f.filterWalkableLowHeightSpans = config.filterWalkableLowHeightSpans; @@ -119,7 +119,7 @@ namespace DotRecast.Detour.Dynamic.Io VoxelFile f = new VoxelFile(); f.version = 1; DynamicNavMeshConfig config = mesh.config; - f.partitionType = config.partitionType; + f.partition = config.partition; f.filterLowHangingObstacles = config.filterLowHangingObstacles; f.filterLedgeSpans = config.filterLedgeSpans; f.filterWalkableLowHeightSpans = config.filterWalkableLowHeightSpans; diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs index e54fd48..08078c9 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs @@ -45,8 +45,7 @@ public class DynamicUpdateTool : IRcTool private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD; private float cellSize = 0.3f; - private int partitioningIdx = PartitionType.WATERSHED.Idx; - private PartitionType partitioning = PartitionType.WATERSHED; + private int partitioning = RcPartitionType.WATERSHED.Value; private bool filterLowHangingObstacles = true; private bool filterLedgeSpans = true; private bool filterWalkableLowHeightSpans = true; @@ -575,11 +574,11 @@ public class DynamicUpdateTool : IRcTool ImGui.Text("Partitioning"); ImGui.Separator(); - PartitionType.Values.ForEach(partition => + RcPartitionType.Values.ForEach(partition => { var label = partition.Name.Substring(0, 1).ToUpper() + partition.Name.Substring(1).ToLower(); - ImGui.RadioButton(label, ref partitioningIdx, partition.Idx); + ImGui.RadioButton(label, ref partitioning, partition.Value); }); ImGui.NewLine(); @@ -721,7 +720,7 @@ public class DynamicUpdateTool : IRcTool private void ConfigDynaMesh() { - dynaMesh.config.partitionType = partitioning; + dynaMesh.config.partition = partitioning; dynaMesh.config.walkableHeight = walkableHeight; dynaMesh.config.walkableSlopeAngle = walkableSlopeAngle; dynaMesh.config.walkableRadius = walkableRadius; @@ -742,7 +741,7 @@ public class DynamicUpdateTool : IRcTool private void UpdateUI() { cellSize = dynaMesh.config.cellSize; - partitioning = dynaMesh.config.partitionType; + partitioning = (int)dynaMesh.config.partition; walkableHeight = dynaMesh.config.walkableHeight; walkableSlopeAngle = dynaMesh.config.walkableSlopeAngle; walkableRadius = dynaMesh.config.walkableRadius; diff --git a/src/DotRecast.Recast.Demo/UI/RcSettingsView.cs b/src/DotRecast.Recast.Demo/UI/RcSettingsView.cs index 0431c21..c875ca4 100644 --- a/src/DotRecast.Recast.Demo/UI/RcSettingsView.cs +++ b/src/DotRecast.Recast.Demo/UI/RcSettingsView.cs @@ -142,10 +142,10 @@ public class RcSettingsView : IRcView ImGui.Text("Partitioning"); ImGui.Separator(); - PartitionType.Values.ForEach(partition => + RcPartitionType.Values.ForEach(partition => { var label = partition.Name.Substring(0, 1).ToUpper() + partition.Name.Substring(1).ToLower(); - ImGui.RadioButton(label, ref settings.partitioningIdx, partition.Idx); + ImGui.RadioButton(label, ref settings.partitioning, partition.Value); }); ImGui.NewLine(); diff --git a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs index f08edbc..466f83a 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/SoloNavMeshBuilder.cs @@ -26,10 +26,10 @@ namespace DotRecast.Recast.DemoTool.Builder { public class SoloNavMeshBuilder { - public NavMeshBuildResult Build(DemoInputGeomProvider geom, SampleSettings settings) + public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcNavMeshBuildSetting settings) { return Build(geom, - settings.partitioning, settings.cellSize, settings.cellHeight, settings.agentHeight, + RcPartitionType.OfValue(settings.partitioning), settings.cellSize, settings.cellHeight, settings.agentHeight, settings.agentRadius, settings.agentMaxClimb, settings.agentMaxSlope, settings.minRegionSize, settings.mergedRegionSize, settings.edgeMaxLen, settings.edgeMaxError, @@ -37,7 +37,7 @@ namespace DotRecast.Recast.DemoTool.Builder settings.filterLowHangingObstacles, settings.filterLedgeSpans, settings.filterWalkableLowHeightSpans); } - public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType, + public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcPartition 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, @@ -58,7 +58,7 @@ namespace DotRecast.Recast.DemoTool.Builder return new DtNavMesh(meshData, vertsPerPoly, 0); } - private RecastBuilderResult BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize, + private RecastBuilderResult BuildRecastResult(DemoInputGeomProvider geom, RcPartition 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, diff --git a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs index f07d2b8..e9fb3a9 100644 --- a/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs +++ b/src/DotRecast.Recast.DemoTool/Builder/TileNavMeshBuilder.cs @@ -30,10 +30,10 @@ namespace DotRecast.Recast.DemoTool.Builder { } - public NavMeshBuildResult Build(DemoInputGeomProvider geom, SampleSettings settings) + public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcNavMeshBuildSetting settings) { return Build(geom, - settings.partitioning, settings.cellSize, settings.cellHeight, settings.agentHeight, + RcPartitionType.OfValue(settings.partitioning), settings.cellSize, settings.cellHeight, settings.agentHeight, settings.agentRadius, settings.agentMaxClimb, settings.agentMaxSlope, settings.minRegionSize, settings.mergedRegionSize, settings.edgeMaxLen, settings.edgeMaxError, @@ -42,7 +42,7 @@ namespace DotRecast.Recast.DemoTool.Builder settings.tileSize); } - public NavMeshBuildResult Build(DemoInputGeomProvider geom, PartitionType partitionType, + public NavMeshBuildResult Build(DemoInputGeomProvider geom, RcPartition 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, @@ -57,7 +57,7 @@ namespace DotRecast.Recast.DemoTool.Builder return new NavMeshBuildResult(results, tileNavMesh); } - public List BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, + public List BuildRecastResult(DemoInputGeomProvider geom, RcPartition 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, diff --git a/src/DotRecast.Recast.DemoTool/SampleSettings.cs b/src/DotRecast.Recast.DemoTool/RcNavMeshBuildSetting.cs similarity index 86% rename from src/DotRecast.Recast.DemoTool/SampleSettings.cs rename to src/DotRecast.Recast.DemoTool/RcNavMeshBuildSetting.cs index bda647a..4d3cb4d 100644 --- a/src/DotRecast.Recast.DemoTool/SampleSettings.cs +++ b/src/DotRecast.Recast.DemoTool/RcNavMeshBuildSetting.cs @@ -1,6 +1,6 @@ namespace DotRecast.Recast.DemoTool { - public class SampleSettings + public class RcNavMeshBuildSetting { public float cellSize = 0.3f; public float cellHeight = 0.2f; @@ -16,8 +16,7 @@ public int minRegionSize = 8; public int mergedRegionSize = 20; - public int partitioningIdx = 0; - public PartitionType partitioning = PartitionType.WATERSHED; + public int partitioning = RcPartitionType.WATERSHED.Value; public bool filterLowHangingObstacles = true; public bool filterLedgeSpans = true; diff --git a/src/DotRecast.Recast.DemoTool/Sample.cs b/src/DotRecast.Recast.DemoTool/Sample.cs index 8908a83..93b5518 100644 --- a/src/DotRecast.Recast.DemoTool/Sample.cs +++ b/src/DotRecast.Recast.DemoTool/Sample.cs @@ -30,7 +30,7 @@ namespace DotRecast.Recast.DemoTool private DemoInputGeomProvider _inputGeom; private DtNavMesh _navMesh; private DtNavMeshQuery _navMeshQuery; - private readonly SampleSettings _settings; + private readonly RcNavMeshBuildSetting _settings; private IList _recastResults; private bool _changed; @@ -39,7 +39,7 @@ namespace DotRecast.Recast.DemoTool _inputGeom = inputGeom; _recastResults = recastResults; _navMesh = navMesh; - _settings = new SampleSettings(); + _settings = new RcNavMeshBuildSetting(); SetQuery(navMesh); _changed = true; @@ -65,7 +65,7 @@ namespace DotRecast.Recast.DemoTool return _navMesh; } - public SampleSettings GetSettings() + public RcNavMeshBuildSetting GetSettings() { return _settings; } diff --git a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs index f3e105d..b5ac83d 100644 --- a/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs +++ b/src/DotRecast.Recast.DemoTool/Tools/TileToolImpl.cs @@ -97,7 +97,7 @@ namespace DotRecast.Recast.DemoTool.Tools settings.tileSize, settings.tileSize, RcConfig.CalcBorder(settings.agentRadius, settings.cellSize), - settings.partitioning, + RcPartitionType.OfValue(settings.partitioning), settings.cellSize, settings.cellHeight, settings.agentMaxSlope, diff --git a/src/DotRecast.Recast/PartitionType.cs b/src/DotRecast.Recast/PartitionType.cs deleted file mode 100644 index 1ebabb6..0000000 --- a/src/DotRecast.Recast/PartitionType.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Immutable; -using System.Linq; - -namespace DotRecast.Recast -{ - /// < Tessellate edges between areas during contour - /// simplification. - public class PartitionType - { - public static readonly PartitionType WATERSHED = new PartitionType(0, nameof(WATERSHED)); - public static readonly PartitionType MONOTONE = new PartitionType(1, nameof(MONOTONE)); - public static readonly PartitionType LAYERS = new PartitionType(2, nameof(LAYERS)); - - public static readonly ImmutableArray Values = ImmutableArray.Create(WATERSHED, MONOTONE, LAYERS); - - public int Idx { get; } - public string Name { get; } - - private PartitionType(int idx, string name) - { - Idx = idx; - Name = name; - } - - public static PartitionType OfIdx(int idx) - { - return Values.FirstOrDefault(x => x.Idx == idx) ?? WATERSHED; - } - - public override string ToString() => Name; - } -} \ No newline at end of file diff --git a/src/DotRecast.Recast/RcConfig.cs b/src/DotRecast.Recast/RcConfig.cs index 5942d08..8f22e89 100644 --- a/src/DotRecast.Recast/RcConfig.cs +++ b/src/DotRecast.Recast/RcConfig.cs @@ -24,7 +24,7 @@ namespace DotRecast.Recast { public class RcConfig { - public readonly PartitionType partitionType; + public readonly int partition; public readonly bool useTiles; @@ -116,7 +116,7 @@ namespace DotRecast.Recast /** * Non-tiled build configuration */ - public RcConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, + public RcConfig(RcPartition 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, RcAreaModification walkableAreaMod) : this(partitionType, cellSize, cellHeight, agentMaxSlope, true, true, true, agentHeight, agentRadius, agentMaxClimb, @@ -128,7 +128,7 @@ namespace DotRecast.Recast /** * Non-tiled build configuration */ - public RcConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentMaxSlope, + public RcConfig(RcPartition partitionType, float cellSize, float cellHeight, float agentMaxSlope, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, float agentHeight, float agentRadius, float agentMaxClimb, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, RcAreaModification walkableAreaMod, @@ -140,7 +140,7 @@ namespace DotRecast.Recast // Note: area = size*size in [Units: wu] } - public RcConfig(bool useTiles, int tileSizeX, int tileSizeZ, int borderSize, PartitionType partitionType, + public RcConfig(bool useTiles, int tileSizeX, int tileSizeZ, int borderSize, RcPartition partition, float cellSize, float cellHeight, float agentMaxSlope, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, float agentHeight, float agentRadius, float agentMaxClimb, float minRegionArea, float mergeRegionArea, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, bool buildMeshDetail, @@ -150,7 +150,7 @@ namespace DotRecast.Recast this.tileSizeX = tileSizeX; this.tileSizeZ = tileSizeZ; this.borderSize = borderSize; - this.partitionType = partitionType; + this.partition = RcPartitionType.Of(partition).Value; cs = cellSize; ch = cellHeight; walkableSlopeAngle = agentMaxSlope; diff --git a/src/DotRecast.Recast/RcPartition.cs b/src/DotRecast.Recast/RcPartition.cs new file mode 100644 index 0000000..266bfd8 --- /dev/null +++ b/src/DotRecast.Recast/RcPartition.cs @@ -0,0 +1,9 @@ +namespace DotRecast.Recast +{ + public enum RcPartition + { + WATERSHED = 0, + MONOTONE = 1, + LAYERS = 2, + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RcPartitionType.cs b/src/DotRecast.Recast/RcPartitionType.cs new file mode 100644 index 0000000..cb85ac7 --- /dev/null +++ b/src/DotRecast.Recast/RcPartitionType.cs @@ -0,0 +1,34 @@ +using System.Linq; + +namespace DotRecast.Recast +{ + public class RcPartitionType + { + public static readonly RcPartitionType WATERSHED = new RcPartitionType(RcPartition.WATERSHED); + public static readonly RcPartitionType MONOTONE = new RcPartitionType(RcPartition.MONOTONE); + public static readonly RcPartitionType LAYERS = new RcPartitionType(RcPartition.LAYERS); + + public static readonly RcPartitionType[] Values = { WATERSHED, MONOTONE, LAYERS }; + + public readonly RcPartition EnumType; + public readonly int Value; + public readonly string Name; + + private RcPartitionType(RcPartition et) + { + EnumType = et; + Value = (int)et; + Name = et.ToString(); + } + + public static RcPartition OfValue(int value) + { + return Values.FirstOrDefault(x => x.Value == value)?.EnumType ?? RcPartition.WATERSHED; + } + + public static RcPartitionType Of(RcPartition partition) + { + return Values.FirstOrDefault(x => x.EnumType == partition) ?? WATERSHED; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index d4ca210..4071a52 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -210,7 +210,7 @@ namespace DotRecast.Recast // * good choice to use for tiled navmesh with medium and small sized // tiles - if (cfg.partitionType == PartitionType.WATERSHED) + if (cfg.partition == RcPartitionType.WATERSHED.Value) { // Prepare for region partitioning, by calculating distance field // along the walkable surface. @@ -218,7 +218,7 @@ namespace DotRecast.Recast // Partition the walkable surface into simple regions without holes. RecastRegion.BuildRegions(ctx, chf, cfg.minRegionArea, cfg.mergeRegionArea); } - else if (cfg.partitionType == PartitionType.MONOTONE) + else if (cfg.partition == RcPartitionType.MONOTONE.Value) { // Partition the walkable surface into simple regions without holes. // Monotone partitioning does not need distancefield. diff --git a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs index d0c142a..a28fda8 100644 --- a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs @@ -40,13 +40,13 @@ public class RecastTestMeshBuilder public const float m_detailSampleMaxError = 1.0f; public RecastTestMeshBuilder() : this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), - PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, + RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError) { } - public RecastTestMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize, + public RecastTestMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize, float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope, int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, float m_detailSampleDist, float m_detailSampleMaxError) diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs index fae54eb..6f843d1 100644 --- a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs +++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs @@ -75,7 +75,7 @@ public class MeshSetReaderWriterTest for (int x = 0; x < tw; ++x) { RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, - RcConfig.CalcBorder(m_agentRadius, m_cellSize), PartitionType.WATERSHED, m_cellSize, m_cellHeight, + RcConfig.CalcBorder(m_agentRadius, m_cellSize), RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); diff --git a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs index 0e6388f..726b306 100644 --- a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs @@ -41,13 +41,13 @@ public class RecastTestMeshBuilder public RecastTestMeshBuilder() : this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), - PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, + RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError) { } - public RecastTestMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize, + public RecastTestMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize, float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope, int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, float m_detailSampleDist, float m_detailSampleMaxError) diff --git a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs index ade9b1a..4c97930 100644 --- a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs @@ -46,13 +46,13 @@ public class TestTiledNavMeshBuilder public TestTiledNavMeshBuilder() : this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), - PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, + RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, m_tileSize) { } - public TestTiledNavMeshBuilder(IInputGeomProvider m_geom, PartitionType m_partitionType, float m_cellSize, float m_cellHeight, + public TestTiledNavMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize, float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope, int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, float m_detailSampleDist, float m_detailSampleMaxError, int m_tileSize) diff --git a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs index a5508ac..c1ca2d5 100644 --- a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs +++ b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs @@ -52,7 +52,7 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder { this.geom = geom; rcConfig = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize), - PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, + RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); RcVec3f bmin = geom.GetMeshBoundsMin(); diff --git a/test/DotRecast.Recast.Test/RecastLayersTest.cs b/test/DotRecast.Recast.Test/RecastLayersTest.cs index ba423eb..981bc67 100644 --- a/test/DotRecast.Recast.Test/RecastLayersTest.cs +++ b/test/DotRecast.Recast.Test/RecastLayersTest.cs @@ -44,7 +44,7 @@ public class RecastLayersTest private const int m_vertsPerPoly = 6; private const float m_detailSampleDist = 6.0f; private const float m_detailSampleMaxError = 1.0f; - private readonly PartitionType m_partitionType = PartitionType.WATERSHED; + private readonly int m_partitionType = RcPartitionType.WATERSHED.Value; private const int m_tileSize = 48; [Test] @@ -148,7 +148,7 @@ public class RecastLayersTest IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename)); RecastBuilder builder = new RecastBuilder(); RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize), - m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, + RcPartitionType.OfValue(m_partitionType), m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), x, y); diff --git a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs index 4242b4b..06d3d59 100644 --- a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs @@ -43,56 +43,56 @@ public class RecastSoloMeshTest private const int m_vertsPerPoly = 6; private const float m_detailSampleDist = 6.0f; private const float m_detailSampleMaxError = 1.0f; - private PartitionType m_partitionType = PartitionType.WATERSHED; + private RcPartition m_partitionType = RcPartition.WATERSHED; [Test] public void TestPerformance() { for (int i = 0; i < 10; i++) { - TestBuild("dungeon.obj", PartitionType.WATERSHED, 52, 16, 15, 223, 118, 118, 513, 291); - TestBuild("dungeon.obj", PartitionType.MONOTONE, 0, 17, 16, 210, 100, 100, 453, 264); - TestBuild("dungeon.obj", PartitionType.LAYERS, 0, 5, 5, 203, 97, 97, 446, 266); + TestBuild("dungeon.obj", RcPartition.WATERSHED, 52, 16, 15, 223, 118, 118, 513, 291); + TestBuild("dungeon.obj", RcPartition.MONOTONE, 0, 17, 16, 210, 100, 100, 453, 264); + TestBuild("dungeon.obj", RcPartition.LAYERS, 0, 5, 5, 203, 97, 97, 446, 266); } } [Test] public void TestDungeonWatershed() { - TestBuild("dungeon.obj", PartitionType.WATERSHED, 52, 16, 15, 223, 118, 118, 513, 291); + TestBuild("dungeon.obj", RcPartition.WATERSHED, 52, 16, 15, 223, 118, 118, 513, 291); } [Test] public void TestDungeonMonotone() { - TestBuild("dungeon.obj", PartitionType.MONOTONE, 0, 17, 16, 210, 100, 100, 453, 264); + TestBuild("dungeon.obj", RcPartition.MONOTONE, 0, 17, 16, 210, 100, 100, 453, 264); } [Test] public void TestDungeonLayers() { - TestBuild("dungeon.obj", PartitionType.LAYERS, 0, 5, 5, 203, 97, 97, 446, 266); + TestBuild("dungeon.obj", RcPartition.LAYERS, 0, 5, 5, 203, 97, 97, 446, 266); } [Test] public void TestWatershed() { - TestBuild("nav_test.obj", PartitionType.WATERSHED, 60, 48, 47, 349, 155, 155, 812, 561); + TestBuild("nav_test.obj", RcPartition.WATERSHED, 60, 48, 47, 349, 155, 155, 812, 561); } [Test] public void TestMonotone() { - TestBuild("nav_test.obj", PartitionType.MONOTONE, 0, 50, 49, 341, 186, 186, 878, 567); + TestBuild("nav_test.obj", RcPartition.MONOTONE, 0, 50, 49, 341, 186, 186, 878, 567); } [Test] public void TestLayers() { - TestBuild("nav_test.obj", PartitionType.LAYERS, 0, 19, 32, 310, 150, 150, 773, 526); + TestBuild("nav_test.obj", RcPartition.LAYERS, 0, 19, 32, 310, 150, 150, 773, 526); } - public void TestBuild(string filename, PartitionType partitionType, int expDistance, int expRegions, + public void TestBuild(string filename, RcPartition partitionType, int expDistance, int expRegions, int expContours, int expVerts, int expPolys, int expDetMeshes, int expDetVerts, int expDetTris) { m_partitionType = partitionType; @@ -206,7 +206,7 @@ public class RecastSoloMeshTest // tiles long time3 = RcFrequency.Ticks; - if (m_partitionType == PartitionType.WATERSHED) + if (m_partitionType == RcPartition.WATERSHED) { // Prepare for region partitioning, by calculating distance field // along the walkable surface. @@ -214,7 +214,7 @@ public class RecastSoloMeshTest // Partition the walkable surface into simple regions without holes. RecastRegion.BuildRegions(m_ctx, m_chf, cfg.minRegionArea, cfg.mergeRegionArea); } - else if (m_partitionType == PartitionType.MONOTONE) + else if (m_partitionType == RcPartition.MONOTONE) { // Partition the walkable surface into simple regions without holes. // Monotone partitioning does not need distancefield. diff --git a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs index b7cb635..9039b90 100644 --- a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs @@ -49,7 +49,7 @@ public class RecastTileMeshTest private const int m_vertsPerPoly = 6; private const float m_detailSampleDist = 6.0f; private const float m_detailSampleMaxError = 1.0f; - private PartitionType m_partitionType = PartitionType.WATERSHED; + private RcPartition m_partitionType = RcPartition.WATERSHED; private const int m_tileSize = 32; [Test]