forked from bit/DotRecastNetSim
for unity3d
This commit is contained in:
parent
2842c65bb7
commit
12dfb27538
|
@ -75,26 +75,26 @@ namespace DotRecast.Detour.Dynamic.Io
|
||||||
{
|
{
|
||||||
VoxelFile f = new VoxelFile();
|
VoxelFile f = new VoxelFile();
|
||||||
f.version = 1;
|
f.version = 1;
|
||||||
f.partition = config.partition;
|
f.partition = config.Partition;
|
||||||
f.filterLowHangingObstacles = config.filterLowHangingObstacles;
|
f.filterLowHangingObstacles = config.FilterLowHangingObstacles;
|
||||||
f.filterLedgeSpans = config.filterLedgeSpans;
|
f.filterLedgeSpans = config.FilterLedgeSpans;
|
||||||
f.filterWalkableLowHeightSpans = config.filterWalkableLowHeightSpans;
|
f.filterWalkableLowHeightSpans = config.FilterWalkableLowHeightSpans;
|
||||||
f.walkableRadius = config.walkableRadiusWorld;
|
f.walkableRadius = config.WalkableRadiusWorld;
|
||||||
f.walkableHeight = config.walkableHeightWorld;
|
f.walkableHeight = config.WalkableHeightWorld;
|
||||||
f.walkableClimb = config.walkableClimbWorld;
|
f.walkableClimb = config.WalkableClimbWorld;
|
||||||
f.walkableSlopeAngle = config.walkableSlopeAngle;
|
f.walkableSlopeAngle = config.WalkableSlopeAngle;
|
||||||
f.cellSize = config.cs;
|
f.cellSize = config.Cs;
|
||||||
f.maxSimplificationError = config.maxSimplificationError;
|
f.maxSimplificationError = config.MaxSimplificationError;
|
||||||
f.maxEdgeLen = config.maxEdgeLenWorld;
|
f.maxEdgeLen = config.MaxEdgeLenWorld;
|
||||||
f.minRegionArea = config.minRegionAreaWorld;
|
f.minRegionArea = config.MinRegionAreaWorld;
|
||||||
f.regionMergeArea = config.mergeRegionAreaWorld;
|
f.regionMergeArea = config.MergeRegionAreaWorld;
|
||||||
f.vertsPerPoly = config.maxVertsPerPoly;
|
f.vertsPerPoly = config.MaxVertsPerPoly;
|
||||||
f.buildMeshDetail = config.buildMeshDetail;
|
f.buildMeshDetail = config.BuildMeshDetail;
|
||||||
f.detailSampleDistance = config.detailSampleDist;
|
f.detailSampleDistance = config.DetailSampleDist;
|
||||||
f.detailSampleMaxError = config.detailSampleMaxError;
|
f.detailSampleMaxError = config.DetailSampleMaxError;
|
||||||
f.useTiles = config.useTiles;
|
f.useTiles = config.UseTiles;
|
||||||
f.tileSizeX = config.tileSizeX;
|
f.tileSizeX = config.TileSizeX;
|
||||||
f.tileSizeZ = config.tileSizeZ;
|
f.tileSizeZ = config.TileSizeZ;
|
||||||
f.bounds = new float[]
|
f.bounds = new float[]
|
||||||
{
|
{
|
||||||
float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity,
|
float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity,
|
||||||
|
|
|
@ -22,96 +22,98 @@ using System;
|
||||||
|
|
||||||
namespace DotRecast.Recast
|
namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
|
/// Specifies a configuration to use when performing Recast builds.
|
||||||
|
/// @ingroup recast
|
||||||
public class RcConfig
|
public class RcConfig
|
||||||
{
|
{
|
||||||
public readonly int partition;
|
public readonly int Partition;
|
||||||
|
|
||||||
public readonly bool useTiles;
|
public readonly bool UseTiles;
|
||||||
|
|
||||||
/** The width/depth size of tile's on the xz-plane. [Limit: >= 0] [Units: vx] **/
|
/** The width/depth size of tile's on the xz-plane. [Limit: >= 0] [Units: vx] **/
|
||||||
public readonly int tileSizeX;
|
public readonly int TileSizeX;
|
||||||
|
|
||||||
public readonly int tileSizeZ;
|
public readonly int TileSizeZ;
|
||||||
|
|
||||||
/** The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu] **/
|
/** The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu] **/
|
||||||
public readonly float cs;
|
public readonly float Cs;
|
||||||
|
|
||||||
/** The y-axis cell size to use for fields. [Limit: > 0] [Units: wu] **/
|
/** The y-axis cell size to use for fields. [Limit: > 0] [Units: wu] **/
|
||||||
public readonly float ch;
|
public readonly float Ch;
|
||||||
|
|
||||||
/** The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees] **/
|
/** The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees] **/
|
||||||
public readonly float walkableSlopeAngle;
|
public readonly float WalkableSlopeAngle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3]
|
* Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3]
|
||||||
* [Units: vx]
|
* [Units: vx]
|
||||||
**/
|
**/
|
||||||
public readonly int walkableHeight;
|
public readonly int WalkableHeight;
|
||||||
|
|
||||||
/** Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] **/
|
/** Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] **/
|
||||||
public readonly int walkableClimb;
|
public readonly int WalkableClimb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The distance to erode/shrink the walkable area of the heightfield away from obstructions. [Limit: >=0] [Units:
|
* The distance to erode/shrink the walkable area of the heightfield away from obstructions. [Limit: >=0] [Units:
|
||||||
* vx]
|
* vx]
|
||||||
**/
|
**/
|
||||||
public readonly int walkableRadius;
|
public readonly int WalkableRadius;
|
||||||
|
|
||||||
/** The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx] **/
|
/** The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx] **/
|
||||||
public readonly int maxEdgeLen;
|
public readonly int MaxEdgeLen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum distance a simplfied contour's border edges should deviate the original raw contour. [Limit: >=0]
|
* The maximum distance a simplfied contour's border edges should deviate the original raw contour. [Limit: >=0]
|
||||||
* [Units: vx]
|
* [Units: vx]
|
||||||
**/
|
**/
|
||||||
public readonly float maxSimplificationError;
|
public readonly float MaxSimplificationError;
|
||||||
|
|
||||||
/** The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx] **/
|
/** The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx] **/
|
||||||
public readonly int minRegionArea;
|
public readonly int MinRegionArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any regions with a span count smaller than this value will, if possible, be merged with larger regions. [Limit:
|
* Any regions with a span count smaller than this value will, if possible, be merged with larger regions. [Limit:
|
||||||
* >=0] [Units: vx]
|
* >=0] [Units: vx]
|
||||||
**/
|
**/
|
||||||
public readonly int mergeRegionArea;
|
public readonly int MergeRegionArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
|
* The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
|
||||||
* [Limit: >= 3]
|
* [Limit: >= 3]
|
||||||
**/
|
**/
|
||||||
public readonly int maxVertsPerPoly;
|
public readonly int MaxVertsPerPoly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the sampling distance to use when generating the detail mesh. (For height detail only.) [Limits: 0 or >=
|
* Sets the sampling distance to use when generating the detail mesh. (For height detail only.) [Limits: 0 or >=
|
||||||
* 0.9] [Units: wu]
|
* 0.9] [Units: wu]
|
||||||
**/
|
**/
|
||||||
public readonly float detailSampleDist;
|
public readonly float DetailSampleDist;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum distance the detail mesh surface should deviate from heightfield data. (For height detail only.)
|
* The maximum distance the detail mesh surface should deviate from heightfield data. (For height detail only.)
|
||||||
* [Limit: >=0] [Units: wu]
|
* [Limit: >=0] [Units: wu]
|
||||||
**/
|
**/
|
||||||
public readonly float detailSampleMaxError;
|
public readonly float DetailSampleMaxError;
|
||||||
|
|
||||||
public readonly RcAreaModification walkableAreaMod;
|
public readonly RcAreaModification WalkableAreaMod;
|
||||||
public readonly bool filterLowHangingObstacles;
|
public readonly bool FilterLowHangingObstacles;
|
||||||
public readonly bool filterLedgeSpans;
|
public readonly bool FilterLedgeSpans;
|
||||||
public readonly bool filterWalkableLowHeightSpans;
|
public readonly bool FilterWalkableLowHeightSpans;
|
||||||
|
|
||||||
/** Set to false to disable building detailed mesh **/
|
/** Set to false to disable building detailed mesh **/
|
||||||
public readonly bool buildMeshDetail;
|
public readonly bool BuildMeshDetail;
|
||||||
|
|
||||||
/** The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx] **/
|
/** The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx] **/
|
||||||
public readonly int borderSize;
|
public readonly int BorderSize;
|
||||||
|
|
||||||
/** Set of original settings passed in world units */
|
/** Set of original settings passed in world units */
|
||||||
public readonly float minRegionAreaWorld;
|
public readonly float MinRegionAreaWorld;
|
||||||
|
|
||||||
public readonly float mergeRegionAreaWorld;
|
public readonly float MergeRegionAreaWorld;
|
||||||
public readonly float walkableHeightWorld;
|
public readonly float WalkableHeightWorld;
|
||||||
public readonly float walkableClimbWorld;
|
public readonly float WalkableClimbWorld;
|
||||||
public readonly float walkableRadiusWorld;
|
public readonly float WalkableRadiusWorld;
|
||||||
public readonly float maxEdgeLenWorld;
|
public readonly float MaxEdgeLenWorld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-tiled build configuration
|
* Non-tiled build configuration
|
||||||
|
@ -146,35 +148,35 @@ namespace DotRecast.Recast
|
||||||
float mergeRegionArea, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, bool buildMeshDetail,
|
float mergeRegionArea, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, bool buildMeshDetail,
|
||||||
float detailSampleDist, float detailSampleMaxError, RcAreaModification walkableAreaMod)
|
float detailSampleDist, float detailSampleMaxError, RcAreaModification walkableAreaMod)
|
||||||
{
|
{
|
||||||
this.useTiles = useTiles;
|
UseTiles = useTiles;
|
||||||
this.tileSizeX = tileSizeX;
|
TileSizeX = tileSizeX;
|
||||||
this.tileSizeZ = tileSizeZ;
|
TileSizeZ = tileSizeZ;
|
||||||
this.borderSize = borderSize;
|
BorderSize = borderSize;
|
||||||
this.partition = RcPartitionType.Of(partition).Value;
|
Partition = RcPartitionType.Of(partition).Value;
|
||||||
cs = cellSize;
|
Cs = cellSize;
|
||||||
ch = cellHeight;
|
Ch = cellHeight;
|
||||||
walkableSlopeAngle = agentMaxSlope;
|
WalkableSlopeAngle = agentMaxSlope;
|
||||||
walkableHeight = (int)Math.Ceiling(agentHeight / ch);
|
WalkableHeight = (int)Math.Ceiling(agentHeight / Ch);
|
||||||
walkableHeightWorld = agentHeight;
|
WalkableHeightWorld = agentHeight;
|
||||||
walkableClimb = (int)Math.Floor(agentMaxClimb / ch);
|
WalkableClimb = (int)Math.Floor(agentMaxClimb / Ch);
|
||||||
walkableClimbWorld = agentMaxClimb;
|
WalkableClimbWorld = agentMaxClimb;
|
||||||
walkableRadius = (int)Math.Ceiling(agentRadius / cs);
|
WalkableRadius = (int)Math.Ceiling(agentRadius / Cs);
|
||||||
walkableRadiusWorld = agentRadius;
|
WalkableRadiusWorld = agentRadius;
|
||||||
this.minRegionArea = (int)Math.Round(minRegionArea / (cs * cs));
|
MinRegionArea = (int)Math.Round(minRegionArea / (Cs * Cs));
|
||||||
minRegionAreaWorld = minRegionArea;
|
MinRegionAreaWorld = minRegionArea;
|
||||||
this.mergeRegionArea = (int)Math.Round(mergeRegionArea / (cs * cs));
|
MergeRegionArea = (int)Math.Round(mergeRegionArea / (Cs * Cs));
|
||||||
mergeRegionAreaWorld = mergeRegionArea;
|
MergeRegionAreaWorld = mergeRegionArea;
|
||||||
maxEdgeLen = (int)(edgeMaxLen / cellSize);
|
MaxEdgeLen = (int)(edgeMaxLen / cellSize);
|
||||||
maxEdgeLenWorld = edgeMaxLen;
|
MaxEdgeLenWorld = edgeMaxLen;
|
||||||
maxSimplificationError = edgeMaxError;
|
MaxSimplificationError = edgeMaxError;
|
||||||
maxVertsPerPoly = vertsPerPoly;
|
MaxVertsPerPoly = vertsPerPoly;
|
||||||
this.detailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist;
|
DetailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist;
|
||||||
this.detailSampleMaxError = cellHeight * detailSampleMaxError;
|
DetailSampleMaxError = cellHeight * detailSampleMaxError;
|
||||||
this.walkableAreaMod = walkableAreaMod;
|
WalkableAreaMod = walkableAreaMod;
|
||||||
this.filterLowHangingObstacles = filterLowHangingObstacles;
|
FilterLowHangingObstacles = filterLowHangingObstacles;
|
||||||
this.filterLedgeSpans = filterLedgeSpans;
|
FilterLedgeSpans = filterLedgeSpans;
|
||||||
this.filterWalkableLowHeightSpans = filterWalkableLowHeightSpans;
|
FilterWalkableLowHeightSpans = filterWalkableLowHeightSpans;
|
||||||
this.buildMeshDetail = buildMeshDetail;
|
BuildMeshDetail = buildMeshDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CalcBorder(float agentRadius, float cs)
|
public static int CalcBorder(float agentRadius, float cs)
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
RcVec3f bmin = geom.GetMeshBoundsMin();
|
RcVec3f bmin = geom.GetMeshBoundsMin();
|
||||||
RcVec3f bmax = geom.GetMeshBoundsMax();
|
RcVec3f bmax = geom.GetMeshBoundsMax();
|
||||||
Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th);
|
Recast.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
|
||||||
List<RecastBuilderResult> results = new List<RecastBuilderResult>();
|
List<RecastBuilderResult> results = new List<RecastBuilderResult>();
|
||||||
if (null != taskFactory)
|
if (null != taskFactory)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
RcVec3f bmin = geom.GetMeshBoundsMin();
|
RcVec3f bmin = geom.GetMeshBoundsMin();
|
||||||
RcVec3f bmax = geom.GetMeshBoundsMax();
|
RcVec3f bmax = geom.GetMeshBoundsMax();
|
||||||
Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th);
|
Recast.CalcTileCount(bmin, bmax, cfg.Cs, cfg.TileSizeX, cfg.TileSizeZ, out var tw, out var th);
|
||||||
Task task;
|
Task task;
|
||||||
if (1 < threads)
|
if (1 < threads)
|
||||||
{
|
{
|
||||||
|
@ -210,24 +210,24 @@ namespace DotRecast.Recast
|
||||||
// * good choice to use for tiled navmesh with medium and small sized
|
// * good choice to use for tiled navmesh with medium and small sized
|
||||||
// tiles
|
// tiles
|
||||||
|
|
||||||
if (cfg.partition == RcPartitionType.WATERSHED.Value)
|
if (cfg.Partition == RcPartitionType.WATERSHED.Value)
|
||||||
{
|
{
|
||||||
// Prepare for region partitioning, by calculating distance field
|
// Prepare for region partitioning, by calculating distance field
|
||||||
// along the walkable surface.
|
// along the walkable surface.
|
||||||
RecastRegion.BuildDistanceField(ctx, chf);
|
RecastRegion.BuildDistanceField(ctx, chf);
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
RecastRegion.BuildRegions(ctx, chf, cfg.minRegionArea, cfg.mergeRegionArea);
|
RecastRegion.BuildRegions(ctx, chf, cfg.MinRegionArea, cfg.MergeRegionArea);
|
||||||
}
|
}
|
||||||
else if (cfg.partition == RcPartitionType.MONOTONE.Value)
|
else if (cfg.Partition == RcPartitionType.MONOTONE.Value)
|
||||||
{
|
{
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
// Monotone partitioning does not need distancefield.
|
// Monotone partitioning does not need distancefield.
|
||||||
RecastRegion.BuildRegionsMonotone(ctx, chf, cfg.minRegionArea, cfg.mergeRegionArea);
|
RecastRegion.BuildRegionsMonotone(ctx, chf, cfg.MinRegionArea, cfg.MergeRegionArea);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
RecastRegion.BuildLayerRegions(ctx, chf, cfg.minRegionArea);
|
RecastRegion.BuildLayerRegions(ctx, chf, cfg.MinRegionArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -235,21 +235,21 @@ namespace DotRecast.Recast
|
||||||
//
|
//
|
||||||
|
|
||||||
// Create contours.
|
// Create contours.
|
||||||
RcContourSet cset = RecastContour.BuildContours(ctx, chf, cfg.maxSimplificationError, cfg.maxEdgeLen,
|
RcContourSet cset = RecastContour.BuildContours(ctx, chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen,
|
||||||
RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Step 6. Build polygons mesh from contours.
|
// Step 6. Build polygons mesh from contours.
|
||||||
//
|
//
|
||||||
|
|
||||||
RcPolyMesh pmesh = RecastMesh.BuildPolyMesh(ctx, cset, cfg.maxVertsPerPoly);
|
RcPolyMesh pmesh = RecastMesh.BuildPolyMesh(ctx, cset, cfg.MaxVertsPerPoly);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Step 7. Create detail mesh which allows to access approximate height
|
// Step 7. Create detail mesh which allows to access approximate height
|
||||||
// on each polygon.
|
// on each polygon.
|
||||||
//
|
//
|
||||||
RcPolyMeshDetail dmesh = cfg.buildMeshDetail
|
RcPolyMeshDetail dmesh = cfg.BuildMeshDetail
|
||||||
? RecastMeshDetail.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.detailSampleDist, cfg.detailSampleMaxError)
|
? RecastMeshDetail.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.DetailSampleDist, cfg.DetailSampleMaxError)
|
||||||
: null;
|
: null;
|
||||||
return new RecastBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx);
|
return new RecastBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx);
|
||||||
}
|
}
|
||||||
|
@ -262,19 +262,19 @@ namespace DotRecast.Recast
|
||||||
// Once all geometry is rasterized, we do initial pass of filtering to
|
// Once all geometry is rasterized, we do initial pass of filtering to
|
||||||
// remove unwanted overhangs caused by the conservative rasterization
|
// remove unwanted overhangs caused by the conservative rasterization
|
||||||
// as well as filter spans where the character cannot possibly stand.
|
// as well as filter spans where the character cannot possibly stand.
|
||||||
if (cfg.filterLowHangingObstacles)
|
if (cfg.FilterLowHangingObstacles)
|
||||||
{
|
{
|
||||||
RecastFilter.FilterLowHangingWalkableObstacles(ctx, cfg.walkableClimb, solid);
|
RecastFilter.FilterLowHangingWalkableObstacles(ctx, cfg.WalkableClimb, solid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.filterLedgeSpans)
|
if (cfg.FilterLedgeSpans)
|
||||||
{
|
{
|
||||||
RecastFilter.FilterLedgeSpans(ctx, cfg.walkableHeight, cfg.walkableClimb, solid);
|
RecastFilter.FilterLedgeSpans(ctx, cfg.WalkableHeight, cfg.WalkableClimb, solid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.filterWalkableLowHeightSpans)
|
if (cfg.FilterWalkableLowHeightSpans)
|
||||||
{
|
{
|
||||||
RecastFilter.FilterWalkableLowHeightSpans(ctx, cfg.walkableHeight, solid);
|
RecastFilter.FilterWalkableLowHeightSpans(ctx, cfg.WalkableHeight, solid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,10 +287,10 @@ namespace DotRecast.Recast
|
||||||
// Compact the heightfield so that it is faster to handle from now on.
|
// Compact the heightfield so that it is faster to handle from now on.
|
||||||
// This will result more cache coherent data as well as the neighbours
|
// This will result more cache coherent data as well as the neighbours
|
||||||
// between walkable cells will be calculated.
|
// between walkable cells will be calculated.
|
||||||
RcCompactHeightfield chf = RecastCompact.BuildCompactHeightfield(ctx, cfg.walkableHeight, cfg.walkableClimb, solid);
|
RcCompactHeightfield chf = RecastCompact.BuildCompactHeightfield(ctx, cfg.WalkableHeight, cfg.WalkableClimb, solid);
|
||||||
|
|
||||||
// Erode the walkable area by agent radius.
|
// Erode the walkable area by agent radius.
|
||||||
RecastArea.ErodeWalkableArea(ctx, cfg.walkableRadius, chf);
|
RecastArea.ErodeWalkableArea(ctx, cfg.WalkableRadius, chf);
|
||||||
// (Optional) Mark areas.
|
// (Optional) Mark areas.
|
||||||
if (volumeProvider != null)
|
if (volumeProvider != null)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +309,7 @@ namespace DotRecast.Recast
|
||||||
RcHeightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx);
|
RcHeightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx);
|
||||||
FilterHeightfield(solid, builderCfg.cfg, ctx);
|
FilterHeightfield(solid, builderCfg.cfg, ctx);
|
||||||
RcCompactHeightfield chf = BuildCompactHeightfield(geom, builderCfg.cfg, ctx, solid);
|
RcCompactHeightfield chf = BuildCompactHeightfield(geom, builderCfg.cfg, ctx, solid);
|
||||||
return RecastLayers.BuildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight);
|
return RecastLayers.BuildHeightfieldLayers(ctx, chf, builderCfg.cfg.WalkableHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,10 +52,10 @@ namespace DotRecast.Recast
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.bmin = bmin;
|
this.bmin = bmin;
|
||||||
this.bmax = bmax;
|
this.bmax = bmax;
|
||||||
if (cfg.useTiles)
|
if (cfg.UseTiles)
|
||||||
{
|
{
|
||||||
float tsx = cfg.tileSizeX * cfg.cs;
|
float tsx = cfg.TileSizeX * cfg.Cs;
|
||||||
float tsz = cfg.tileSizeZ * cfg.cs;
|
float tsz = cfg.TileSizeZ * cfg.Cs;
|
||||||
this.bmin.x += tileX * tsx;
|
this.bmin.x += tileX * tsx;
|
||||||
this.bmin.z += tileZ * tsz;
|
this.bmin.z += tileZ * tsz;
|
||||||
this.bmax.x = this.bmin.x + tsx;
|
this.bmax.x = this.bmin.x + tsx;
|
||||||
|
@ -83,16 +83,16 @@ namespace DotRecast.Recast
|
||||||
// you will need to pass in data from neighbour terrain tiles too! In a simple case, just pass in all the 8
|
// you will need to pass in data from neighbour terrain tiles too! In a simple case, just pass in all the 8
|
||||||
// neighbours,
|
// neighbours,
|
||||||
// or use the bounding box below to only pass in a sliver of each of the 8 neighbours.
|
// or use the bounding box below to only pass in a sliver of each of the 8 neighbours.
|
||||||
this.bmin.x -= cfg.borderSize * cfg.cs;
|
this.bmin.x -= cfg.BorderSize * cfg.Cs;
|
||||||
this.bmin.z -= cfg.borderSize * cfg.cs;
|
this.bmin.z -= cfg.BorderSize * cfg.Cs;
|
||||||
this.bmax.x += cfg.borderSize * cfg.cs;
|
this.bmax.x += cfg.BorderSize * cfg.Cs;
|
||||||
this.bmax.z += cfg.borderSize * cfg.cs;
|
this.bmax.z += cfg.BorderSize * cfg.Cs;
|
||||||
width = cfg.tileSizeX + cfg.borderSize * 2;
|
width = cfg.TileSizeX + cfg.BorderSize * 2;
|
||||||
height = cfg.tileSizeZ + cfg.borderSize * 2;
|
height = cfg.TileSizeZ + cfg.BorderSize * 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Recast.CalcGridSize(this.bmin, this.bmax, cfg.cs, out width, out height);
|
Recast.CalcGridSize(this.bmin, this.bmax, cfg.Cs, out width, out height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace DotRecast.Recast
|
||||||
RcConfig cfg = builderCfg.cfg;
|
RcConfig cfg = builderCfg.cfg;
|
||||||
|
|
||||||
// Allocate voxel heightfield where we rasterize our input data to.
|
// Allocate voxel heightfield where we rasterize our input data to.
|
||||||
RcHeightfield solid = new RcHeightfield(builderCfg.width, builderCfg.height, builderCfg.bmin, builderCfg.bmax, cfg.cs, cfg.ch, cfg.borderSize);
|
RcHeightfield solid = new RcHeightfield(builderCfg.width, builderCfg.height, builderCfg.bmin, builderCfg.bmax, cfg.Cs, cfg.Ch, cfg.BorderSize);
|
||||||
|
|
||||||
// Allocate array that can hold triangle area types.
|
// Allocate array that can hold triangle area types.
|
||||||
// If you have multiple meshes you need to process, allocate
|
// If you have multiple meshes you need to process, allocate
|
||||||
|
@ -44,7 +44,7 @@ namespace DotRecast.Recast
|
||||||
foreach (RcTriMesh geom in geomProvider.Meshes())
|
foreach (RcTriMesh geom in geomProvider.Meshes())
|
||||||
{
|
{
|
||||||
float[] verts = geom.GetVerts();
|
float[] verts = geom.GetVerts();
|
||||||
if (cfg.useTiles)
|
if (cfg.UseTiles)
|
||||||
{
|
{
|
||||||
float[] tbmin = new float[2];
|
float[] tbmin = new float[2];
|
||||||
float[] tbmax = new float[2];
|
float[] tbmax = new float[2];
|
||||||
|
@ -57,16 +57,16 @@ namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
int[] tris = node.tris;
|
int[] tris = node.tris;
|
||||||
int ntris = tris.Length / 3;
|
int ntris = tris.Length / 3;
|
||||||
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.walkableSlopeAngle, verts, tris, ntris, cfg.walkableAreaMod);
|
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
|
||||||
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.walkableClimb, ctx);
|
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int[] tris = geom.GetTris();
|
int[] tris = geom.GetTris();
|
||||||
int ntris = tris.Length / 3;
|
int ntris = tris.Length / 3;
|
||||||
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.walkableSlopeAngle, verts, tris, ntris, cfg.walkableAreaMod);
|
int[] m_triareas = Recast.MarkWalkableTriangles(ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
|
||||||
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.walkableClimb, ctx);
|
RecastRasterization.RasterizeTriangles(solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,17 @@ public class RecastTestMeshBuilder
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecastTestMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize,
|
public RecastTestMeshBuilder(IInputGeomProvider geom, RcPartition partitionType, float cellSize,
|
||||||
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope,
|
float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope,
|
||||||
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
|
int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly,
|
||||||
float m_detailSampleDist, float m_detailSampleMaxError)
|
float detailSampleDist, float detailSampleMaxError)
|
||||||
{
|
{
|
||||||
RcConfig cfg = new RcConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius,
|
RcConfig cfg = new RcConfig(partitionType, cellSize, cellHeight, agentHeight, agentRadius,
|
||||||
m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError,
|
agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError,
|
||||||
m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
vertsPerPoly, detailSampleDist, detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
||||||
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax());
|
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
|
||||||
RecastBuilder rcBuilder = new RecastBuilder();
|
RecastBuilder rcBuilder = new RecastBuilder();
|
||||||
RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg);
|
RecastBuilderResult rcResult = rcBuilder.Build(geom, bcfg);
|
||||||
RcPolyMesh m_pmesh = rcResult.GetMesh();
|
RcPolyMesh m_pmesh = rcResult.GetMesh();
|
||||||
for (int i = 0; i < m_pmesh.npolys; ++i)
|
for (int i = 0; i < m_pmesh.npolys; ++i)
|
||||||
{
|
{
|
||||||
|
@ -77,13 +77,13 @@ public class RecastTestMeshBuilder
|
||||||
option.detailVertsCount = m_dmesh.nverts;
|
option.detailVertsCount = m_dmesh.nverts;
|
||||||
option.detailTris = m_dmesh.tris;
|
option.detailTris = m_dmesh.tris;
|
||||||
option.detailTriCount = m_dmesh.ntris;
|
option.detailTriCount = m_dmesh.ntris;
|
||||||
option.walkableHeight = m_agentHeight;
|
option.walkableHeight = agentHeight;
|
||||||
option.walkableRadius = m_agentRadius;
|
option.walkableRadius = agentRadius;
|
||||||
option.walkableClimb = m_agentMaxClimb;
|
option.walkableClimb = agentMaxClimb;
|
||||||
option.bmin = m_pmesh.bmin;
|
option.bmin = m_pmesh.bmin;
|
||||||
option.bmax = m_pmesh.bmax;
|
option.bmax = m_pmesh.bmax;
|
||||||
option.cs = m_cellSize;
|
option.cs = cellSize;
|
||||||
option.ch = m_cellHeight;
|
option.ch = cellHeight;
|
||||||
option.buildBvTree = true;
|
option.buildBvTree = true;
|
||||||
|
|
||||||
option.offMeshConVerts = new float[6];
|
option.offMeshConVerts = new float[6];
|
||||||
|
|
|
@ -47,17 +47,17 @@ public class RecastTestMeshBuilder
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecastTestMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize,
|
public RecastTestMeshBuilder(IInputGeomProvider geom, RcPartition partition, float cellSize,
|
||||||
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope,
|
float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope,
|
||||||
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
|
int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly,
|
||||||
float m_detailSampleDist, float m_detailSampleMaxError)
|
float detailSampleDist, float detailSampleMaxError)
|
||||||
{
|
{
|
||||||
RcConfig cfg = new RcConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius,
|
RcConfig cfg = new RcConfig(partition, cellSize, cellHeight, agentHeight, agentRadius,
|
||||||
m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError,
|
agentMaxClimb, agentMaxSlope, regionMinSize, regionMergeSize, edgeMaxLen, edgeMaxError,
|
||||||
m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
vertsPerPoly, detailSampleDist, detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
||||||
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax());
|
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax());
|
||||||
RecastBuilder rcBuilder = new RecastBuilder();
|
RecastBuilder rcBuilder = new RecastBuilder();
|
||||||
RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg);
|
RecastBuilderResult rcResult = rcBuilder.Build(geom, bcfg);
|
||||||
RcPolyMesh m_pmesh = rcResult.GetMesh();
|
RcPolyMesh m_pmesh = rcResult.GetMesh();
|
||||||
for (int i = 0; i < m_pmesh.npolys; ++i)
|
for (int i = 0; i < m_pmesh.npolys; ++i)
|
||||||
{
|
{
|
||||||
|
@ -78,13 +78,13 @@ public class RecastTestMeshBuilder
|
||||||
option.detailVertsCount = m_dmesh.nverts;
|
option.detailVertsCount = m_dmesh.nverts;
|
||||||
option.detailTris = m_dmesh.tris;
|
option.detailTris = m_dmesh.tris;
|
||||||
option.detailTriCount = m_dmesh.ntris;
|
option.detailTriCount = m_dmesh.ntris;
|
||||||
option.walkableHeight = m_agentHeight;
|
option.walkableHeight = agentHeight;
|
||||||
option.walkableRadius = m_agentRadius;
|
option.walkableRadius = agentRadius;
|
||||||
option.walkableClimb = m_agentMaxClimb;
|
option.walkableClimb = agentMaxClimb;
|
||||||
option.bmin = m_pmesh.bmin;
|
option.bmin = m_pmesh.bmin;
|
||||||
option.bmax = m_pmesh.bmax;
|
option.bmax = m_pmesh.bmax;
|
||||||
option.cs = m_cellSize;
|
option.cs = cellSize;
|
||||||
option.ch = m_cellHeight;
|
option.ch = cellHeight;
|
||||||
option.buildBvTree = true;
|
option.buildBvTree = true;
|
||||||
|
|
||||||
option.offMeshConVerts = new float[6];
|
option.offMeshConVerts = new float[6];
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class TestDetourBuilder : DetourBuilder
|
||||||
option.walkableClimb = agentMaxClimb;
|
option.walkableClimb = agentMaxClimb;
|
||||||
option.bmin = pmesh.bmin;
|
option.bmin = pmesh.bmin;
|
||||||
option.bmax = pmesh.bmax;
|
option.bmax = pmesh.bmax;
|
||||||
option.cs = rcConfig.cs;
|
option.cs = rcConfig.Cs;
|
||||||
option.ch = rcConfig.ch;
|
option.ch = rcConfig.Ch;
|
||||||
option.buildBvTree = true;
|
option.buildBvTree = true;
|
||||||
/*
|
/*
|
||||||
* option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts();
|
* option.offMeshConVerts = m_geom->GetOffMeshConnectionVerts();
|
||||||
|
|
|
@ -52,27 +52,27 @@ public class TestTiledNavMeshBuilder
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestTiledNavMeshBuilder(IInputGeomProvider m_geom, RcPartition m_partitionType, float m_cellSize, float m_cellHeight,
|
public TestTiledNavMeshBuilder(IInputGeomProvider geom, RcPartition partitionType, float cellSize, float cellHeight,
|
||||||
float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_agentMaxSlope, int m_regionMinSize,
|
float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope, int regionMinSize,
|
||||||
int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, float m_detailSampleDist,
|
int regionMergeSize, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, float detailSampleDist,
|
||||||
float m_detailSampleMaxError, int m_tileSize)
|
float detailSampleMaxError, int tileSize)
|
||||||
{
|
{
|
||||||
// Create empty nav mesh
|
// Create empty nav mesh
|
||||||
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
||||||
navMeshParams.orig = m_geom.GetMeshBoundsMin();
|
navMeshParams.orig = geom.GetMeshBoundsMin();
|
||||||
navMeshParams.tileWidth = m_tileSize * m_cellSize;
|
navMeshParams.tileWidth = tileSize * cellSize;
|
||||||
navMeshParams.tileHeight = m_tileSize * m_cellSize;
|
navMeshParams.tileHeight = tileSize * cellSize;
|
||||||
navMeshParams.maxTiles = 128;
|
navMeshParams.maxTiles = 128;
|
||||||
navMeshParams.maxPolys = 32768;
|
navMeshParams.maxPolys = 32768;
|
||||||
navMesh = new DtNavMesh(navMeshParams, 6);
|
navMesh = new DtNavMesh(navMeshParams, 6);
|
||||||
|
|
||||||
// Build all tiles
|
// Build all tiles
|
||||||
RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
|
RcConfig cfg = new RcConfig(true, tileSize, tileSize, RcConfig.CalcBorder(agentRadius, cellSize),
|
||||||
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
|
partitionType, cellSize, cellHeight, agentMaxSlope, true, true, true, agentHeight, agentRadius,
|
||||||
m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true,
|
agentMaxClimb, m_regionMinArea, m_regionMergeArea, edgeMaxLen, edgeMaxError, vertsPerPoly, true,
|
||||||
m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
detailSampleDist, detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
|
||||||
RecastBuilder rcBuilder = new RecastBuilder();
|
RecastBuilder rcBuilder = new RecastBuilder();
|
||||||
List<RecastBuilderResult> rcResult = rcBuilder.BuildTiles(m_geom, cfg, null);
|
List<RecastBuilderResult> rcResult = rcBuilder.BuildTiles(geom, cfg, null);
|
||||||
|
|
||||||
// Add tiles to nav mesh
|
// Add tiles to nav mesh
|
||||||
|
|
||||||
|
@ -103,13 +103,13 @@ public class TestTiledNavMeshBuilder
|
||||||
option.detailVertsCount = dmesh.nverts;
|
option.detailVertsCount = dmesh.nverts;
|
||||||
option.detailTris = dmesh.tris;
|
option.detailTris = dmesh.tris;
|
||||||
option.detailTriCount = dmesh.ntris;
|
option.detailTriCount = dmesh.ntris;
|
||||||
option.walkableHeight = m_agentHeight;
|
option.walkableHeight = agentHeight;
|
||||||
option.walkableRadius = m_agentRadius;
|
option.walkableRadius = agentRadius;
|
||||||
option.walkableClimb = m_agentMaxClimb;
|
option.walkableClimb = agentMaxClimb;
|
||||||
option.bmin = pmesh.bmin;
|
option.bmin = pmesh.bmin;
|
||||||
option.bmax = pmesh.bmax;
|
option.bmax = pmesh.bmax;
|
||||||
option.cs = m_cellSize;
|
option.cs = cellSize;
|
||||||
option.ch = m_cellHeight;
|
option.ch = cellHeight;
|
||||||
option.tileX = result.tileX;
|
option.tileX = result.tileX;
|
||||||
option.tileZ = result.tileZ;
|
option.tileZ = result.tileZ;
|
||||||
option.buildBvTree = true;
|
option.buildBvTree = true;
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class RecastSoloMeshTest
|
||||||
//
|
//
|
||||||
|
|
||||||
// Allocate voxel heightfield where we rasterize our input data to.
|
// Allocate voxel heightfield where we rasterize our input data to.
|
||||||
RcHeightfield m_solid = new RcHeightfield(bcfg.width, bcfg.height, bcfg.bmin, bcfg.bmax, cfg.cs, cfg.ch, cfg.borderSize);
|
RcHeightfield m_solid = new RcHeightfield(bcfg.width, bcfg.height, bcfg.bmin, bcfg.bmax, cfg.Cs, cfg.Ch, cfg.BorderSize);
|
||||||
|
|
||||||
foreach (RcTriMesh geom in geomProvider.Meshes())
|
foreach (RcTriMesh geom in geomProvider.Meshes())
|
||||||
{
|
{
|
||||||
|
@ -131,8 +131,8 @@ public class RecastSoloMeshTest
|
||||||
// Find triangles which are walkable based on their slope and rasterize them.
|
// Find triangles which are walkable based on their slope and rasterize them.
|
||||||
// If your input data is multiple meshes, you can transform them here, calculate
|
// If your input data is multiple meshes, you can transform them here, calculate
|
||||||
// the are type for each of the meshes and rasterize them.
|
// the are type for each of the meshes and rasterize them.
|
||||||
int[] m_triareas = Recast.MarkWalkableTriangles(m_ctx, cfg.walkableSlopeAngle, verts, tris, ntris, cfg.walkableAreaMod);
|
int[] m_triareas = Recast.MarkWalkableTriangles(m_ctx, cfg.WalkableSlopeAngle, verts, tris, ntris, cfg.WalkableAreaMod);
|
||||||
RecastRasterization.RasterizeTriangles(m_solid, verts, tris, m_triareas, ntris, cfg.walkableClimb, m_ctx);
|
RecastRasterization.RasterizeTriangles(m_solid, verts, tris, m_triareas, ntris, cfg.WalkableClimb, m_ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,9 @@ public class RecastSoloMeshTest
|
||||||
// Once all geometry is rasterized, we do initial pass of filtering to
|
// Once all geometry is rasterized, we do initial pass of filtering to
|
||||||
// remove unwanted overhangs caused by the conservative rasterization
|
// remove unwanted overhangs caused by the conservative rasterization
|
||||||
// as well as filter spans where the character cannot possibly stand.
|
// as well as filter spans where the character cannot possibly stand.
|
||||||
RecastFilter.FilterLowHangingWalkableObstacles(m_ctx, cfg.walkableClimb, m_solid);
|
RecastFilter.FilterLowHangingWalkableObstacles(m_ctx, cfg.WalkableClimb, m_solid);
|
||||||
RecastFilter.FilterLedgeSpans(m_ctx, cfg.walkableHeight, cfg.walkableClimb, m_solid);
|
RecastFilter.FilterLedgeSpans(m_ctx, cfg.WalkableHeight, cfg.WalkableClimb, m_solid);
|
||||||
RecastFilter.FilterWalkableLowHeightSpans(m_ctx, cfg.walkableHeight, m_solid);
|
RecastFilter.FilterWalkableLowHeightSpans(m_ctx, cfg.WalkableHeight, m_solid);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Step 4. Partition walkable surface to simple regions.
|
// Step 4. Partition walkable surface to simple regions.
|
||||||
|
@ -154,11 +154,11 @@ public class RecastSoloMeshTest
|
||||||
// Compact the heightfield so that it is faster to handle from now on.
|
// Compact the heightfield so that it is faster to handle from now on.
|
||||||
// This will result more cache coherent data as well as the neighbours
|
// This will result more cache coherent data as well as the neighbours
|
||||||
// between walkable cells will be calculated.
|
// between walkable cells will be calculated.
|
||||||
RcCompactHeightfield m_chf = RecastCompact.BuildCompactHeightfield(m_ctx, cfg.walkableHeight, cfg.walkableClimb,
|
RcCompactHeightfield m_chf = RecastCompact.BuildCompactHeightfield(m_ctx, cfg.WalkableHeight, cfg.WalkableClimb,
|
||||||
m_solid);
|
m_solid);
|
||||||
|
|
||||||
// Erode the walkable area by agent radius.
|
// Erode the walkable area by agent radius.
|
||||||
RecastArea.ErodeWalkableArea(m_ctx, cfg.walkableRadius, m_chf);
|
RecastArea.ErodeWalkableArea(m_ctx, cfg.WalkableRadius, m_chf);
|
||||||
|
|
||||||
// (Optional) Mark areas.
|
// (Optional) Mark areas.
|
||||||
/*
|
/*
|
||||||
|
@ -212,18 +212,18 @@ public class RecastSoloMeshTest
|
||||||
// along the walkable surface.
|
// along the walkable surface.
|
||||||
RecastRegion.BuildDistanceField(m_ctx, m_chf);
|
RecastRegion.BuildDistanceField(m_ctx, m_chf);
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
RecastRegion.BuildRegions(m_ctx, m_chf, cfg.minRegionArea, cfg.mergeRegionArea);
|
RecastRegion.BuildRegions(m_ctx, m_chf, cfg.MinRegionArea, cfg.MergeRegionArea);
|
||||||
}
|
}
|
||||||
else if (m_partitionType == RcPartition.MONOTONE)
|
else if (m_partitionType == RcPartition.MONOTONE)
|
||||||
{
|
{
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
// Monotone partitioning does not need distancefield.
|
// Monotone partitioning does not need distancefield.
|
||||||
RecastRegion.BuildRegionsMonotone(m_ctx, m_chf, cfg.minRegionArea, cfg.mergeRegionArea);
|
RecastRegion.BuildRegionsMonotone(m_ctx, m_chf, cfg.MinRegionArea, cfg.MergeRegionArea);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Partition the walkable surface into simple regions without holes.
|
// Partition the walkable surface into simple regions without holes.
|
||||||
RecastRegion.BuildLayerRegions(m_ctx, m_chf, cfg.minRegionArea);
|
RecastRegion.BuildLayerRegions(m_ctx, m_chf, cfg.MinRegionArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.That(m_chf.maxDistance, Is.EqualTo(expDistance), "maxDistance");
|
Assert.That(m_chf.maxDistance, Is.EqualTo(expDistance), "maxDistance");
|
||||||
|
@ -233,7 +233,7 @@ public class RecastSoloMeshTest
|
||||||
//
|
//
|
||||||
|
|
||||||
// Create contours.
|
// Create contours.
|
||||||
RcContourSet m_cset = RecastContour.BuildContours(m_ctx, m_chf, cfg.maxSimplificationError, cfg.maxEdgeLen,
|
RcContourSet m_cset = RecastContour.BuildContours(m_ctx, m_chf, cfg.MaxSimplificationError, cfg.MaxEdgeLen,
|
||||||
RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
|
||||||
|
|
||||||
Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours");
|
Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours");
|
||||||
|
@ -242,7 +242,7 @@ public class RecastSoloMeshTest
|
||||||
//
|
//
|
||||||
|
|
||||||
// Build polygon navmesh from the contours.
|
// Build polygon navmesh from the contours.
|
||||||
RcPolyMesh m_pmesh = RecastMesh.BuildPolyMesh(m_ctx, m_cset, cfg.maxVertsPerPoly);
|
RcPolyMesh m_pmesh = RecastMesh.BuildPolyMesh(m_ctx, m_cset, cfg.MaxVertsPerPoly);
|
||||||
Assert.That(m_pmesh.nverts, Is.EqualTo(expVerts), "Mesh Verts");
|
Assert.That(m_pmesh.nverts, Is.EqualTo(expVerts), "Mesh Verts");
|
||||||
Assert.That(m_pmesh.npolys, Is.EqualTo(expPolys), "Mesh Polys");
|
Assert.That(m_pmesh.npolys, Is.EqualTo(expPolys), "Mesh Polys");
|
||||||
|
|
||||||
|
@ -251,8 +251,8 @@ public class RecastSoloMeshTest
|
||||||
// on each polygon.
|
// on each polygon.
|
||||||
//
|
//
|
||||||
|
|
||||||
RcPolyMeshDetail m_dmesh = RecastMeshDetail.BuildPolyMeshDetail(m_ctx, m_pmesh, m_chf, cfg.detailSampleDist,
|
RcPolyMeshDetail m_dmesh = RecastMeshDetail.BuildPolyMeshDetail(m_ctx, m_pmesh, m_chf, cfg.DetailSampleDist,
|
||||||
cfg.detailSampleMaxError);
|
cfg.DetailSampleMaxError);
|
||||||
Assert.That(m_dmesh.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes");
|
Assert.That(m_dmesh.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes");
|
||||||
Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts");
|
Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts");
|
||||||
Assert.That(m_dmesh.ntris, Is.EqualTo(expDetTris), "Mesh Detail Tris");
|
Assert.That(m_dmesh.ntris, Is.EqualTo(expDetTris), "Mesh Detail Tris");
|
||||||
|
|
|
@ -29,8 +29,6 @@ using NUnit.Framework;
|
||||||
|
|
||||||
namespace DotRecast.Recast.Test;
|
namespace DotRecast.Recast.Test;
|
||||||
|
|
||||||
using static RcConstants;
|
|
||||||
|
|
||||||
[Parallelizable]
|
[Parallelizable]
|
||||||
public class RecastTileMeshTest
|
public class RecastTileMeshTest
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue