A* Pathfinding Project
3.8.5
The A* Pathfinding Project for Unity 3D
|
Voxelizer for recast graphs. More...
Voxelizer for recast graphs.
In comments: units wu are World Units, vx are Voxels
Public Member Functions | |
Voxelize (float ch, float cs, float wc, float wh, float ms) | |
ushort[] | BoxBlur (ushort[] src, ushort[] dst) |
void | BuildCompactField () |
void | BuildContours (float maxError, int maxEdgeLength, VoxelContourSet cset, int buildFlags) |
void | BuildDistanceField () |
void | BuildPolyMesh (VoxelContourSet cset, int nvp, out VoxelMesh mesh) |
Builds a polygon mesh from a contour set. | |
void | BuildRegions () |
void | BuildVoxelConnections () |
int | CalcAreaOfPolygon2D (int[] verts, int nverts) |
ushort | CalculateDistanceField (ushort[] src) |
Vector3 | CompactSpanToVector (int x, int z, int i) |
void | DebugDrawCompactSpans () |
void | DebugDrawSpans () |
void | ErodeVoxels (int radius) |
void | ErodeWalkableArea (int radius) |
ushort[] | ExpandRegions (int maxIterations, uint level, ushort[] srcReg, ushort[] srcDist, ushort[] dstReg, ushort[] dstDist, List< int > stack) |
void | FilterLedges (uint voxelWalkableHeight, int voxelWalkableClimb, float cs, float ch, Vector3 min) |
void | FilterLowHeightSpans (uint voxelWalkableHeight, float cs, float ch, Vector3 min) |
void | FilterSmallRegions (ushort[] reg, int minRegionSize, int maxRegions) |
Filters out or merges small regions. | |
bool | FloodRegion (int x, int z, int i, uint level, ushort r, ushort[] srcReg, ushort[] srcDist, List< int > stack) |
int | GetCornerHeight (int x, int z, int i, int dir, ref bool isBorderVertex) |
void | Init () |
void | MarkRectWithRegion (int minx, int maxx, int minz, int maxz, ushort region, ushort[] srcReg) |
void | RemoveDegenerateSegments (List< int > simplified) |
void | SimplifyContour (List< int > verts, List< int > simplified, float maxError, int maxEdgeLenght, int buildFlags) |
void | VectorToIndex (Vector3 p, out int x, out int z) |
void | VoxelizeInput () |
Vector3 | VoxelToWorld (int x, int y, int z) |
Convert from voxel coordinates to world coordinates. | |
Int3 | VoxelToWorldInt3 (Int3 voxelPosition) |
Convert from voxel coordinates to world coordinates. | |
void | WalkContour (int x, int z, int i, ushort[] flags, List< int > verts) |
Static Public Member Functions | |
static int | Area2 (int a, int b, int c, int[] verts) |
static bool | Collinear (int a, int b, int c, int[] verts) |
static bool | Diagonal (int i, int j, int n, int[] verts, int[] indices) |
Returns T iff (v_i, v_j) is a proper internal diagonal of P. | |
static bool | Ileft (int a, int b, int c, int[] va, int[] vb, int[] vc) |
static bool | InCone (int i, int j, int n, int[] verts, int[] indices) |
static bool | IntersectProp (int a, int b, int c, int d, int[] verts) |
static bool | Left (int a, int b, int c, int[] verts) |
Returns true iff c is strictly to the left of the directed line through a to b. | |
static bool | LeftOn (int a, int b, int c, int[] verts) |
static bool | MergeContours (ref VoxelContour ca, ref VoxelContour cb, int ia, int ib) |
static int | Next (int i, int n) |
(i+1) % n assuming 0 <= i < n | |
static int | Prev (int i, int n) |
(i-1+n) % n assuming 0 <= i < n | |
static bool | Xorb (bool x, bool y) |
Public Attributes | |
int | borderSize = 0 |
The size of the non-navigable border around the heightfield. | |
readonly float | cellHeight = 0.1F |
The y-axis cell size to use for fields. | |
readonly float | cellSize = 0.2F |
The xz-plane cell size to use for fields. | |
VoxelContourSet | countourSet |
int | depth |
Depth in voxels. | |
Bounds | forcedBounds |
The world AABB to rasterize. | |
List< RasterizationMesh > | inputMeshes |
float | maxEdgeLength = 20 |
The maximum allowed length for contour edges along the border of the mesh. | |
float | maxSlope = 30 |
The maximum slope that is considered walkable. | |
int | minRegionSize = 100 |
RecastGraph.RelevantGraphSurfaceMode | relevantGraphSurfaceMode |
VoxelArea | voxelArea |
readonly int | voxelWalkableClimb |
Maximum ledge height that is considered to still be traversable. | |
readonly uint | voxelWalkableHeight |
Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. | |
int | width |
Width in voxels. | |
Private Member Functions | |
Vector3 | ConvertPosition (int x, int z, int i) |
Vector3 | ConvertPosWithoutOffset (int x, int y, int z) |
void | DrawLine (int a, int b, int[] indices, int[] verts, Color col) |
void | FloodOnes (List< Int3 > st1, ushort[] regs, uint level, ushort reg) |
void | GetClosestIndices (int[] vertsa, int nvertsa, int[] vertsb, int nvertsb, ref int ia, ref int ib) |
int | Triangulate (int n, int[] verts, ref int[] indices, ref int[] tris) |
Static Private Member Functions | |
static bool | Between (int a, int b, int c, int[] verts) |
static int[] | ClaimIntArr (int minCapacity, bool zero) |
static bool | Diagonalie (int i, int j, int n, int[] verts, int[] indices) |
Returns T iff (v_i, v_j) is a proper internal *or* external diagonal of P, *ignoring edges incident to v_i and v_j*. | |
static bool | Intersect (int a, int b, int c, int d, int[] verts) |
static void | ReleaseContours (VoxelContourSet cset) |
Releases contents of a contour set to caches. | |
static void | ReleaseIntArr (int[] arr) |
static int | union_find_find (int[] arr, int x) |
Find method in the UnionFind data structure. | |
static void | union_find_union (int[] arr, int a, int b) |
Join method in the UnionFind data structure. | |
static bool | Vequal (int a, int b, int[] verts) |
Private Attributes | |
readonly Vector3 | cellScale |
VoxelPolygonClipper | clipper |
Utility for clipping polygons to rectangles. | |
Vector3 | voxelOffset |
Static Private Attributes | |
static readonly int[] | emptyArr = new int[0] |
static List< int[]> | intArrCache = new List<int[]>() |
Constants @{ | |
const uint | NotConnected = 0x3f |
const int | RC_CONTOUR_TESS_WALL_EDGES = 0x01 |
const int | RC_CONTOUR_TESS_AREA_EDGES = 0x02 |
const int | MaxLayers = 65535 |
Unmotivated variable, but let's clamp the layers at 65535. | |
const int | MaxRegions = 500 |
const int | UnwalkableArea = 0 |
const ushort | BorderReg = 0x8000 |
If heightfield region ID has the following bit set, the region is on border area and excluded from many calculations. | |
const int | RC_BORDER_VERTEX = 0x10000 |
If contour region ID has the following bit set, the vertex will be later removed in order to match the segments and vertices at tile boundaries. | |
const int | RC_AREA_BORDER = 0x20000 |
const int | VERTEX_BUCKET_COUNT = 1<<12 |
const int | ContourRegMask = 0xffff |
Mask used with contours to extract region id. | |
Voxelize | ( | float | ch, |
float | cs, | ||
float | wc, | ||
float | wh, | ||
float | ms | ||
) |
|
static |
|
staticprivate |
ushort [] BoxBlur | ( | ushort[] | src, |
ushort[] | dst | ||
) |
void BuildCompactField | ( | ) |
void BuildContours | ( | float | maxError, |
int | maxEdgeLength, | ||
VoxelContourSet | cset, | ||
int | buildFlags | ||
) |
void BuildDistanceField | ( | ) |
void BuildPolyMesh | ( | VoxelContourSet | cset, |
int | nvp, | ||
out VoxelMesh | mesh | ||
) |
Builds a polygon mesh from a contour set.
cset | contour set to build a mesh from. |
nvp | Maximum allowed vertices per polygon. |
mesh | Results will be written to this mesh. |
void BuildRegions | ( | ) |
void BuildVoxelConnections | ( | ) |
int CalcAreaOfPolygon2D | ( | int[] | verts, |
int | nverts | ||
) |
ushort CalculateDistanceField | ( | ushort[] | src | ) |
|
staticprivate |
|
static |
Vector3 CompactSpanToVector | ( | int | x, |
int | z, | ||
int | i | ||
) |
|
private |
|
private |
void DebugDrawCompactSpans | ( | ) |
void DebugDrawSpans | ( | ) |
|
static |
Returns T iff (v_i, v_j) is a proper internal diagonal of P.
|
staticprivate |
Returns T iff (v_i, v_j) is a proper internal *or* external diagonal of P, *ignoring edges incident to v_i and v_j*.
|
private |
void ErodeVoxels | ( | int | radius | ) |
void ErodeWalkableArea | ( | int | radius | ) |
ushort [] ExpandRegions | ( | int | maxIterations, |
uint | level, | ||
ushort[] | srcReg, | ||
ushort[] | srcDist, | ||
ushort[] | dstReg, | ||
ushort[] | dstDist, | ||
List< int > | stack | ||
) |
void FilterLedges | ( | uint | voxelWalkableHeight, |
int | voxelWalkableClimb, | ||
float | cs, | ||
float | ch, | ||
Vector3 | min | ||
) |
void FilterLowHeightSpans | ( | uint | voxelWalkableHeight, |
float | cs, | ||
float | ch, | ||
Vector3 | min | ||
) |
void FilterSmallRegions | ( | ushort[] | reg, |
int | minRegionSize, | ||
int | maxRegions | ||
) |
Filters out or merges small regions.
|
private |
bool FloodRegion | ( | int | x, |
int | z, | ||
int | i, | ||
uint | level, | ||
ushort | r, | ||
ushort[] | srcReg, | ||
ushort[] | srcDist, | ||
List< int > | stack | ||
) |
|
private |
int GetCornerHeight | ( | int | x, |
int | z, | ||
int | i, | ||
int | dir, | ||
ref bool | isBorderVertex | ||
) |
|
static |
|
static |
void Init | ( | ) |
|
staticprivate |
|
static |
|
static |
Returns true iff c is strictly to the left of the directed line through a to b.
|
static |
void MarkRectWithRegion | ( | int | minx, |
int | maxx, | ||
int | minz, | ||
int | maxz, | ||
ushort | region, | ||
ushort[] | srcReg | ||
) |
|
static |
|
static |
(i+1) % n assuming 0 <= i < n
|
static |
(i-1+n) % n assuming 0 <= i < n
|
staticprivate |
Releases contents of a contour set to caches.
|
staticprivate |
void RemoveDegenerateSegments | ( | List< int > | simplified | ) |
void SimplifyContour | ( | List< int > | verts, |
List< int > | simplified, | ||
float | maxError, | ||
int | maxEdgeLenght, | ||
int | buildFlags | ||
) |
|
private |
|
staticprivate |
Find method in the UnionFind data structure.
|
staticprivate |
Join method in the UnionFind data structure.
void VectorToIndex | ( | Vector3 | p, |
out int | x, | ||
out int | z | ||
) |
|
staticprivate |
void VoxelizeInput | ( | ) |
Vector3 VoxelToWorld | ( | int | x, |
int | y, | ||
int | z | ||
) |
Convert from voxel coordinates to world coordinates.
(0,0,0) in voxel coordinates is a bottom corner of the bounding box. (1,0,0) is one voxel in the +X direction of that.
Convert from voxel coordinates to world coordinates.
(0,0,0) in voxel coordinates is a bottom corner of the bounding box. (1,0,0) is one voxel in the +X direction of that.
void WalkContour | ( | int | x, |
int | z, | ||
int | i, | ||
ushort[] | flags, | ||
List< int > | verts | ||
) |
|
static |
|
private |
If heightfield region ID has the following bit set, the region is on border area and excluded from many calculations.
int borderSize = 0 |
The size of the non-navigable border around the heightfield.
[Limit: >=0] [Units: vx]
readonly float cellHeight = 0.1F |
The y-axis cell size to use for fields.
[Limit: > 0] [Units: wu]
|
private |
readonly float cellSize = 0.2F |
The xz-plane cell size to use for fields.
[Limit: > 0] [Units: wu]
|
private |
Utility for clipping polygons to rectangles.
Implemented as a struct and not a bunch of static methods because it needs some buffer arrays that are best cached to avoid excessive allocations
|
private |
Mask used with contours to extract region id.
VoxelContourSet countourSet |
int depth |
Depth in voxels.
Must match the forcedBounds
|
staticprivate |
Bounds forcedBounds |
The world AABB to rasterize.
List<RasterizationMesh> inputMeshes |
|
staticprivate |
float maxEdgeLength = 20 |
The maximum allowed length for contour edges along the border of the mesh.
[Limit: >= 0] [Units: vx]
|
private |
Unmotivated variable, but let's clamp the layers at 65535.
|
private |
float maxSlope = 30 |
The maximum slope that is considered walkable.
[Limits: 0 <= value < 90] [Units: Degrees]
int minRegionSize = 100 |
const uint NotConnected = 0x3f |
|
private |
|
private |
If contour region ID has the following bit set, the vertex will be later removed in order to match the segments and vertices at tile boundaries.
const int RC_CONTOUR_TESS_AREA_EDGES = 0x02 |
const int RC_CONTOUR_TESS_WALL_EDGES = 0x01 |
RecastGraph.RelevantGraphSurfaceMode relevantGraphSurfaceMode |
|
private |
|
private |
VoxelArea voxelArea |
|
private |
readonly int voxelWalkableClimb |
Maximum ledge height that is considered to still be traversable.
[Limit: >=0] [Units: vx]
readonly uint voxelWalkableHeight |
Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable.
[Limit: >= 3] [Units: vx]
int width |
Width in voxels.
Must match the forcedBounds