forked from mirror/DotRecast
for unity3d
This commit is contained in:
parent
2553e40ad3
commit
2842c65bb7
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<RecastBuilderResult> BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType,
|
||||
public List<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,
|
||||
|
|
|
@ -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;
|
|
@ -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<RecastBuilderResult> _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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<PartitionType> 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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace DotRecast.Recast
|
||||
{
|
||||
public enum RcPartition
|
||||
{
|
||||
WATERSHED = 0,
|
||||
MONOTONE = 1,
|
||||
LAYERS = 2,
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue