A* Pathfinding Project
3.6.1
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) |
void | CollectMeshes () |
Vector3 | CompactSpanToVector (int x, int z, int i) |
Vector3 | ConvertPos (int x, int y, int z) |
Vector3 | ConvertPosCorrZ (int x, int y, int z) |
Vector3 | ConvertPosition (int x, int z, int i) |
Vector3 | ConvertPosWithoutOffset (int x, int y, int z) |
void | DebugDrawCompactSpans () |
void | DebugDrawSpans () |
void | DrawLine (int a, int b, int[] indices, int[] verts, Color col) |
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 | OnGUI () |
void | RemoveDegenerateSegments (List< int > simplified) |
void | SimplifyContour (List< int > verts, List< int > simplified, float maxError, int maxEdgeLenght, int buildFlags) |
int | Triangulate (int n, int[] verts, ref int[] indices, ref int[] tris) |
void | VectorToIndex (Vector3 p, out int x, out int z) |
void | VoxelizeInput () |
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 void | CollectMeshes (List< ExtraMesh > extraMeshes, Bounds bounds, out Vector3[] verts, out int[] tris) |
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 Vector3 | cellScale |
readonly Vector3 | cellScaleDivision |
readonly float | cellSize = 0.2F |
The xz-plane cell size to use for fields. | |
VoxelContourSet | countourSet |
string | debugString = "" |
int | depth |
Depth in voxels. | |
Bounds | forcedBounds |
The world AABB to rasterize. | |
List< ExtraMesh > | inputExtraMeshes |
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 |
Vector3 | voxelOffset |
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. | |
Constants @{ | |
const uint | NotConnected = 0x3f |
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 | RC_CONTOUR_TESS_WALL_EDGES = 0x01 |
const int | RC_CONTOUR_TESS_AREA_EDGES = 0x02 |
const int | ContourRegMask = 0xffff |
Mask used with contours to extract region id. | |
Protected Attributes | |
int[] | inputTriangles |
Vector3[] | inputVertices |
Private Member Functions | |
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) |
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) |
static void | union_find_union (int[] arr, int a, int b) |
static bool | Vequal (int a, int b, int[] verts) |
Static Private Attributes | |
static readonly int[] | emptyArr = new int[0] |
static List< int[]> | intArrCache = new List<int[]>() |
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.
nvp | Maximum allowed vertices per polygon. |
void BuildRegions | ( | ) |
void BuildVoxelConnections | ( | ) |
int CalcAreaOfPolygon2D | ( | int[] | verts, |
int | nverts | ||
) |
ushort CalculateDistanceField | ( | ushort[] | src | ) |
|
staticprivate |
void CollectMeshes | ( | ) |
|
static |
|
static |
Vector3 CompactSpanToVector | ( | int | x, |
int | z, | ||
int | i | ||
) |
Vector3 ConvertPos | ( | int | x, |
int | y, | ||
int | z | ||
) |
Vector3 ConvertPosCorrZ | ( | int | x, |
int | y, | ||
int | z | ||
) |
Vector3 ConvertPosition | ( | int | x, |
int | z, | ||
int | i | ||
) |
Vector3 ConvertPosWithoutOffset | ( | int | x, |
int | y, | ||
int | z | ||
) |
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*.
void DrawLine | ( | int | a, |
int | b, | ||
int[] | indices, | ||
int[] | verts, | ||
Color | col | ||
) |
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
void OnGUI | ( | ) |
|
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 | ||
) |
int Triangulate | ( | int | n, |
int[] | verts, | ||
ref int[] | indices, | ||
ref int[] | tris | ||
) |
|
staticprivate |
|
staticprivate |
void VectorToIndex | ( | Vector3 | p, |
out int | x, | ||
out int | z | ||
) |
|
staticprivate |
void VoxelizeInput | ( | ) |
void WalkContour | ( | int | x, |
int | z, | ||
int | i, | ||
ushort[] | flags, | ||
List< int > | verts | ||
) |
|
static |
const ushort BorderReg = 0x8000 |
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]
readonly Vector3 cellScale |
readonly Vector3 cellScaleDivision |
readonly float cellSize = 0.2F |
The xz-plane cell size to use for fields.
[Limit: > 0] [Units: wu]
const int ContourRegMask = 0xffff |
Mask used with contours to extract region id.
VoxelContourSet countourSet |
string debugString = "" |
int depth |
Depth in voxels.
Must match the forcedBounds
|
staticprivate |
Bounds forcedBounds |
The world AABB to rasterize.
List<ExtraMesh> inputExtraMeshes |
|
protected |
|
protected |
|
staticprivate |
float maxEdgeLength = 20 |
The maximum allowed length for contour edges along the border of the mesh.
[Limit: >= 0] [Units: vx]
const int MaxLayers = 65535 |
Unmotivated variable, but let's clamp the layers at 65535.
const int MaxRegions = 500 |
float maxSlope = 30 |
The maximum slope that is considered walkable.
[Limits: 0 <= value < 90] [Units: Degrees]
int minRegionSize = 100 |
const uint NotConnected = 0x3f |
const int RC_AREA_BORDER = 0x20000 |
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_CONTOUR_TESS_AREA_EDGES = 0x02 |
const int RC_CONTOUR_TESS_WALL_EDGES = 0x01 |
RecastGraph.RelevantGraphSurfaceMode relevantGraphSurfaceMode |
const int UnwalkableArea = 0 |
const int VERTEX_BUCKET_COUNT = 1<<12 |
VoxelArea voxelArea |
Vector3 voxelOffset |
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