Recast Navigation
Navigation-mesh Toolset for Games
|
Go to the source code of this file.
Classes | |
class | rcContext |
Provides an interface for optional logging and performance tracking of the Recast build process. More... | |
class | rcScopedTimer |
A helper to first start a timer and then stop it when this helper goes out of scope. More... | |
struct | rcConfig |
Specifies a configuration to use when performing Recast builds. More... | |
struct | rcSpan |
Represents a span in a heightfield. More... | |
struct | rcSpanPool |
A memory pool used for quick allocation of spans within a heightfield. More... | |
struct | rcHeightfield |
A dynamic heightfield representing obstructed space. More... | |
struct | rcCompactCell |
Provides information on the content of a cell column in a compact heightfield. More... | |
struct | rcCompactSpan |
Represents a span of unobstructed space within a compact heightfield. More... | |
struct | rcCompactHeightfield |
A compact, static heightfield representing unobstructed space. More... | |
struct | rcHeightfieldLayer |
Represents a heightfield layer within a layer set. More... | |
struct | rcHeightfieldLayerSet |
Represents a set of heightfield layers. More... | |
struct | rcContour |
Represents a simple, non-overlapping contour in field space. More... | |
struct | rcContourSet |
Represents a group of related contours. More... | |
struct | rcPolyMesh |
Represents a polygon mesh suitable for use in building a navigation mesh. More... | |
struct | rcPolyMeshDetail |
Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon mesh object. More... | |
Functions | |
template<class T > | |
void | rcIgnoreUnused (const T &) |
Used to ignore unused function parameters and silence any compiler warnings. More... | |
Allocation Functions | |
Functions used to allocate and de-allocate Recast objects.
| |
rcHeightfield * | rcAllocHeightfield () |
Allocates a heightfield object using the Recast allocator. More... | |
void | rcFreeHeightField (rcHeightfield *heightfield) |
Frees the specified heightfield object using the Recast allocator. More... | |
rcCompactHeightfield * | rcAllocCompactHeightfield () |
Allocates a compact heightfield object using the Recast allocator. More... | |
void | rcFreeCompactHeightfield (rcCompactHeightfield *compactHeightfield) |
Frees the specified compact heightfield object using the Recast allocator. More... | |
rcHeightfieldLayerSet * | rcAllocHeightfieldLayerSet () |
Allocates a heightfield layer set using the Recast allocator. More... | |
void | rcFreeHeightfieldLayerSet (rcHeightfieldLayerSet *layerSet) |
Frees the specified heightfield layer set using the Recast allocator. More... | |
rcContourSet * | rcAllocContourSet () |
Allocates a contour set object using the Recast allocator. More... | |
void | rcFreeContourSet (rcContourSet *contourSet) |
Frees the specified contour set using the Recast allocator. More... | |
rcPolyMesh * | rcAllocPolyMesh () |
Allocates a polygon mesh object using the Recast allocator. More... | |
void | rcFreePolyMesh (rcPolyMesh *polyMesh) |
Frees the specified polygon mesh using the Recast allocator. More... | |
rcPolyMeshDetail * | rcAllocPolyMeshDetail () |
Allocates a detail mesh object using the Recast allocator. More... | |
void | rcFreePolyMeshDetail (rcPolyMeshDetail *detailMesh) |
Frees the specified detail mesh using the Recast allocator. More... | |
General helper functions | |
template<class T > | |
void | rcSwap (T &a, T &b) |
Swaps the values of the two parameters. More... | |
template<class T > | |
T | rcMin (T a, T b) |
Returns the minimum of two values. More... | |
template<class T > | |
T | rcMax (T a, T b) |
Returns the maximum of two values. More... | |
template<class T > | |
T | rcAbs (T a) |
Returns the absolute value. More... | |
template<class T > | |
T | rcSqr (T a) |
Returns the square of the value. More... | |
template<class T > | |
T | rcClamp (T value, T minInclusive, T maxInclusive) |
Clamps the value to the specified range. More... | |
float | rcSqrt (float x) |
Returns the square root of the value. More... | |
Vector helper functions. | |
void | rcVcross (float *dest, const float *v1, const float *v2) |
Derives the cross product of two vectors. More... | |
float | rcVdot (const float *v1, const float *v2) |
Derives the dot product of two vectors. More... | |
void | rcVmad (float *dest, const float *v1, const float *v2, const float s) |
Performs a scaled vector addition. More... | |
void | rcVadd (float *dest, const float *v1, const float *v2) |
Performs a vector addition. More... | |
void | rcVsub (float *dest, const float *v1, const float *v2) |
Performs a vector subtraction. More... | |
void | rcVmin (float *mn, const float *v) |
Selects the minimum value of each element from the specified vectors. More... | |
void | rcVmax (float *mx, const float *v) |
Selects the maximum value of each element from the specified vectors. More... | |
void | rcVcopy (float *dest, const float *v) |
Performs a vector copy. More... | |
float | rcVdist (const float *v1, const float *v2) |
Returns the distance between two points. More... | |
float | rcVdistSqr (const float *v1, const float *v2) |
Returns the square of the distance between two points. More... | |
void | rcVnormalize (float *v) |
Normalizes the vector. More... | |
Heightfield Functions | |
| |
void | rcCalcBounds (const float *verts, int numVerts, float *minBounds, float *maxBounds) |
Calculates the bounding box of an array of vertices. More... | |
void | rcCalcGridSize (const float *minBounds, const float *maxBounds, float cellSize, int *sizeX, int *sizeZ) |
Calculates the grid size based on the bounding box and grid cell size. More... | |
bool | rcCreateHeightfield (rcContext *context, rcHeightfield &heightfield, int sizeX, int sizeZ, const float *minBounds, const float *maxBounds, float cellSize, float cellHeight) |
Initializes a new heightfield. More... | |
void | rcMarkWalkableTriangles (rcContext *context, float walkableSlopeAngle, const float *verts, int numVerts, const int *tris, int numTris, unsigned char *triAreaIDs) |
Sets the area id of all triangles with a slope below the specified value to RC_WALKABLE_AREA. More... | |
void | rcClearUnwalkableTriangles (rcContext *context, float walkableSlopeAngle, const float *verts, int numVerts, const int *tris, int numTris, unsigned char *triAreaIDs) |
Sets the area id of all triangles with a slope greater than or equal to the specified value to RC_NULL_AREA. More... | |
bool | rcAddSpan (rcContext *context, rcHeightfield &heightfield, int x, int z, unsigned short spanMin, unsigned short spanMax, unsigned char areaID, int flagMergeThreshold) |
Adds a span to the specified heightfield. More... | |
bool | rcRasterizeTriangle (rcContext *context, const float *v0, const float *v1, const float *v2, unsigned char areaID, rcHeightfield &heightfield, int flagMergeThreshold=1) |
Rasterizes a single triangle into the specified heightfield. More... | |
bool | rcRasterizeTriangles (rcContext *context, const float *verts, int numVerts, const int *tris, const unsigned char *triAreaIDs, int numTris, rcHeightfield &heightfield, int flagMergeThreshold=1) |
Rasterizes an indexed triangle mesh into the specified heightfield. More... | |
bool | rcRasterizeTriangles (rcContext *context, const float *verts, int numVerts, const unsigned short *tris, const unsigned char *triAreaIDs, int numTris, rcHeightfield &heightfield, int flagMergeThreshold=1) |
Rasterizes an indexed triangle mesh into the specified heightfield. More... | |
bool | rcRasterizeTriangles (rcContext *context, const float *verts, const unsigned char *triAreaIDs, int numTris, rcHeightfield &heightfield, int flagMergeThreshold=1) |
Rasterizes a triangle list into the specified heightfield. More... | |
void | rcFilterLowHangingWalkableObstacles (rcContext *context, int walkableClimb, rcHeightfield &heightfield) |
Marks non-walkable spans as walkable if their maximum is within walkableClimb of the span below them. More... | |
void | rcFilterLedgeSpans (rcContext *context, int walkableHeight, int walkableClimb, rcHeightfield &heightfield) |
Marks spans that are ledges as not-walkable. More... | |
void | rcFilterWalkableLowHeightSpans (rcContext *context, int walkableHeight, rcHeightfield &heightfield) |
Marks walkable spans as not walkable if the clearance above the span is less than the specified walkableHeight. More... | |
int | rcGetHeightFieldSpanCount (rcContext *context, const rcHeightfield &heightfield) |
Returns the number of spans contained in the specified heightfield. More... | |
Compact Heightfield Functions | |
| |
bool | rcBuildCompactHeightfield (rcContext *context, int walkableHeight, int walkableClimb, const rcHeightfield &heightfield, rcCompactHeightfield &compactHeightfield) |
Builds a compact heightfield representing open space, from a heightfield representing solid space. More... | |
bool | rcErodeWalkableArea (rcContext *context, int erosionRadius, rcCompactHeightfield &compactHeightfield) |
Erodes the walkable area within the heightfield by the specified radius. More... | |
bool | rcMedianFilterWalkableArea (rcContext *context, rcCompactHeightfield &compactHeightfield) |
Applies a median filter to walkable area types (based on area id), removing noise. More... | |
void | rcMarkBoxArea (rcContext *context, const float *boxMinBounds, const float *boxMaxBounds, unsigned char areaId, rcCompactHeightfield &compactHeightfield) |
Applies an area id to all spans within the specified bounding box. More... | |
void | rcMarkConvexPolyArea (rcContext *context, const float *verts, int numVerts, float minY, float maxY, unsigned char areaId, rcCompactHeightfield &compactHeightfield) |
Applies the area id to the all spans within the specified convex polygon. More... | |
int | rcOffsetPoly (const float *verts, int numVerts, float offset, float *outVerts, int maxOutVerts) |
Expands a convex polygon along its vertex normals by the given offset amount. More... | |
void | rcMarkCylinderArea (rcContext *context, const float *position, float radius, float height, unsigned char areaId, rcCompactHeightfield &compactHeightfield) |
Applies the area id to all spans within the specified y-axis-aligned cylinder. More... | |
bool | rcBuildDistanceField (rcContext *ctx, rcCompactHeightfield &chf) |
Builds the distance field for the specified compact heightfield. More... | |
bool | rcBuildRegions (rcContext *ctx, rcCompactHeightfield &chf, int borderSize, int minRegionArea, int mergeRegionArea) |
Builds region data for the heightfield using watershed partitioning. More... | |
bool | rcBuildLayerRegions (rcContext *ctx, rcCompactHeightfield &chf, int borderSize, int minRegionArea) |
Builds region data for the heightfield by partitioning the heightfield in non-overlapping layers. More... | |
bool | rcBuildRegionsMonotone (rcContext *ctx, rcCompactHeightfield &chf, int borderSize, int minRegionArea, int mergeRegionArea) |
Builds region data for the heightfield using simple monotone partitioning. More... | |
void | rcSetCon (rcCompactSpan &span, int direction, int neighborIndex) |
Sets the neighbor connection data for the specified direction. More... | |
int | rcGetCon (const rcCompactSpan &span, int direction) |
Gets neighbor connection data for the specified direction. More... | |
int | rcGetDirOffsetX (int direction) |
Gets the standard width (x-axis) offset for the specified direction. More... | |
int | rcGetDirOffsetY (int direction) |
Gets the standard height (z-axis) offset for the specified direction. More... | |
int | rcGetDirForOffset (int offsetX, int offsetZ) |
Gets the direction for the specified offset. More... | |
Layer, Contour, Polymesh, and Detail Mesh Functions | |
| |
bool | rcBuildHeightfieldLayers (rcContext *ctx, const rcCompactHeightfield &chf, int borderSize, int walkableHeight, rcHeightfieldLayerSet &lset) |
Builds a layer set from the specified compact heightfield. More... | |
bool | rcBuildContours (rcContext *ctx, const rcCompactHeightfield &chf, float maxError, int maxEdgeLen, rcContourSet &cset, int buildFlags=RC_CONTOUR_TESS_WALL_EDGES) |
Builds a contour set from the region outlines in the provided compact heightfield. More... | |
bool | rcBuildPolyMesh (rcContext *ctx, const rcContourSet &cset, const int nvp, rcPolyMesh &mesh) |
Builds a polygon mesh from the provided contours. More... | |
bool | rcMergePolyMeshes (rcContext *ctx, rcPolyMesh **meshes, const int nmeshes, rcPolyMesh &mesh) |
Merges multiple polygon meshes into a single mesh. More... | |
bool | rcBuildPolyMeshDetail (rcContext *ctx, const rcPolyMesh &mesh, const rcCompactHeightfield &chf, float sampleDist, float sampleMaxError, rcPolyMeshDetail &dmesh) |
Builds a detail mesh from the provided polygon mesh. More... | |
bool | rcCopyPolyMesh (rcContext *ctx, const rcPolyMesh &src, rcPolyMesh &dst) |
Copies the poly mesh data from src to dst. More... | |
bool | rcMergePolyMeshDetails (rcContext *ctx, rcPolyMeshDetail **meshes, const int nmeshes, rcPolyMeshDetail &mesh) |
Merges multiple detail meshes into a single detail mesh. More... | |
Variables | |
static const float | RC_PI = 3.14159265f |
The value of PI used by Recast. More... | |
static const int | RC_SPAN_HEIGHT_BITS = 13 |
Defines the number of bits allocated to rcSpan::smin and rcSpan::smax. More... | |
static const int | RC_SPAN_MAX_HEIGHT = (1 << RC_SPAN_HEIGHT_BITS) - 1 |
Defines the maximum value for rcSpan::smin and rcSpan::smax. More... | |
static const int | RC_SPANS_PER_POOL = 2048 |
The number of spans allocated per span spool. More... | |
static const unsigned short | RC_BORDER_REG = 0x8000 |
Heightfield border flag. More... | |
static const unsigned short | RC_MULTIPLE_REGS = 0 |
Polygon touches multiple regions. More... | |
static const int | RC_BORDER_VERTEX = 0x10000 |
Border vertex flag. More... | |
static const int | RC_AREA_BORDER = 0x20000 |
Area border flag. More... | |
static const int | RC_CONTOUR_REG_MASK = 0xffff |
Applied to the region id field of contour vertices in order to extract the region id. More... | |
static const unsigned short | RC_MESH_NULL_IDX = 0xffff |
An value which indicates an invalid index within a mesh. More... | |
static const unsigned char | RC_NULL_AREA = 0 |
Represents the null area. More... | |
static const unsigned char | RC_WALKABLE_AREA = 63 |
The default area id used to indicate a walkable polygon. More... | |
static const int | RC_NOT_CONNECTED = 0x3f |
The value returned by rcGetCon if the specified direction is not connected to another span. More... | |
enum rcBuildContoursFlags |
Contour build flags.
Enumerator | |
---|---|
RC_CONTOUR_TESS_WALL_EDGES | Tessellate solid (impassable) edges during contour simplification. |
RC_CONTOUR_TESS_AREA_EDGES | Tessellate edges between areas during contour simplification. |
enum rcLogCategory |
Recast log categories.
Enumerator | |
---|---|
RC_LOG_PROGRESS | A progress log entry. |
RC_LOG_WARNING | A warning log entry. |
RC_LOG_ERROR | An error log entry. |
enum rcTimerLabel |
Recast performance timer categories.
Enumerator | |
---|---|
RC_TIMER_TOTAL | The user defined total time of the build. |
RC_TIMER_TEMP | A user defined build time. |
RC_TIMER_RASTERIZE_TRIANGLES | The time to rasterize the triangles. (See: rcRasterizeTriangle) |
RC_TIMER_BUILD_COMPACTHEIGHTFIELD | The time to build the compact heightfield. (See: rcBuildCompactHeightfield) |
RC_TIMER_BUILD_CONTOURS | The total time to build the contours. (See: rcBuildContours) |
RC_TIMER_BUILD_CONTOURS_TRACE | The time to trace the boundaries of the contours. (See: rcBuildContours) |
RC_TIMER_BUILD_CONTOURS_SIMPLIFY | The time to simplify the contours. (See: rcBuildContours) |
RC_TIMER_FILTER_BORDER | The time to filter ledge spans. (See: rcFilterLedgeSpans) |
RC_TIMER_FILTER_WALKABLE | The time to filter low height spans. (See: rcFilterWalkableLowHeightSpans) |
RC_TIMER_MEDIAN_AREA | The time to apply the median filter. (See: rcMedianFilterWalkableArea) |
RC_TIMER_FILTER_LOW_OBSTACLES | The time to filter low obstacles. (See: rcFilterLowHangingWalkableObstacles) |
RC_TIMER_BUILD_POLYMESH | The time to build the polygon mesh. (See: rcBuildPolyMesh) |
RC_TIMER_MERGE_POLYMESH | The time to merge polygon meshes. (See: rcMergePolyMeshes) |
RC_TIMER_ERODE_AREA | The time to erode the walkable area. (See: rcErodeWalkableArea) |
RC_TIMER_MARK_BOX_AREA | The time to mark a box area. (See: rcMarkBoxArea) |
RC_TIMER_MARK_CYLINDER_AREA | The time to mark a cylinder area. (See: rcMarkCylinderArea) |
RC_TIMER_MARK_CONVEXPOLY_AREA | The time to mark a convex polygon area. (See: rcMarkConvexPolyArea) |
RC_TIMER_BUILD_DISTANCEFIELD | The total time to build the distance field. (See: rcBuildDistanceField) |
RC_TIMER_BUILD_DISTANCEFIELD_DIST | The time to build the distances of the distance field. (See: rcBuildDistanceField) |
RC_TIMER_BUILD_DISTANCEFIELD_BLUR | The time to blur the distance field. (See: rcBuildDistanceField) |
RC_TIMER_BUILD_REGIONS | The total time to build the regions. (See: rcBuildRegions, rcBuildRegionsMonotone) |
RC_TIMER_BUILD_REGIONS_WATERSHED | The total time to apply the watershed algorithm. (See: rcBuildRegions) |
RC_TIMER_BUILD_REGIONS_EXPAND | The time to expand regions while applying the watershed algorithm. (See: rcBuildRegions) |
RC_TIMER_BUILD_REGIONS_FLOOD | The time to flood regions while applying the watershed algorithm. (See: rcBuildRegions) |
RC_TIMER_BUILD_REGIONS_FILTER | The time to filter out small regions. (See: rcBuildRegions, rcBuildRegionsMonotone) |
RC_TIMER_BUILD_LAYERS | The time to build heightfield layers. (See: rcBuildHeightfieldLayers) |
RC_TIMER_BUILD_POLYMESHDETAIL | The time to build the polygon mesh detail. (See: rcBuildPolyMeshDetail) |
RC_TIMER_MERGE_POLYMESHDETAIL | The time to merge polygon mesh details. (See: rcMergePolyMeshDetails) |
RC_MAX_TIMERS | The maximum number of timers. (Used for iterating timers.) |
|
inline |
Returns the absolute value.
[in] | a | The value. |
|
inline |
Clamps the value to the specified range.
[in] | value | The value to clamp. |
[in] | minInclusive | The minimum permitted return value. |
[in] | maxInclusive | The maximum permitted return value. |
void rcIgnoreUnused | ( | const T & | ) |
Used to ignore unused function parameters and silence any compiler warnings.
|
inline |
Returns the maximum of two values.
[in] | a | Value A |
[in] | b | Value B |
|
inline |
Returns the minimum of two values.
[in] | a | Value A |
[in] | b | Value B |
|
inline |
Returns the square of the value.
[in] | a | The value. |
float rcSqrt | ( | float | x | ) |
Returns the square root of the value.
[in] | x | The value. |
|
inline |
Swaps the values of the two parameters.
[in,out] | a | Value A |
[in,out] | b | Value B |
|
inline |
Performs a vector addition.
(v1
+ v2
)
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to add to v1 . [(x, y, z)] |
|
inline |
Performs a vector copy.
[out] | dest | The result. [(x, y, z)] |
[in] | v | The vector to copy. [(x, y, z)] |
|
inline |
Derives the cross product of two vectors.
(v1
x v2
)
[out] | dest | The cross product. [(x, y, z)] |
[in] | v1 | A Vector [(x, y, z)] |
[in] | v2 | A vector [(x, y, z)] |
|
inline |
Returns the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
|
inline |
Returns the square of the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
|
inline |
Derives the dot product of two vectors.
(v1
. v2
)
[in] | v1 | A Vector [(x, y, z)] |
[in] | v2 | A vector [(x, y, z)] |
|
inline |
Performs a scaled vector addition.
(v1
+ (v2
* s
))
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to scale and add to v1 . [(x, y, z)] |
[in] | s | The amount to scale v2 by before adding to v1 . |
|
inline |
Selects the maximum value of each element from the specified vectors.
[in,out] | mx | A vector. (Will be updated with the result.) [(x, y, z)] |
[in] | v | A vector. [(x, y, z)] |
|
inline |
Selects the minimum value of each element from the specified vectors.
[in,out] | mn | A vector. (Will be updated with the result.) [(x, y, z)] |
[in] | v | A vector. [(x, y, z)] |
|
inline |
Normalizes the vector.
[in,out] | v | The vector to normalize. [(x, y, z)] |
|
inline |
Performs a vector subtraction.
(v1
- v2
)
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to subtract from v1 . [(x, y, z)] |
|
static |
Area border flag.
If a region ID has this bit set, then the associated element lies on the border of an area. (Used during the region and contour build process.)
|
static |
Heightfield border flag.
If a heightfield region ID has this bit set, then the region is a border region and its spans are considered un-walkable. (Used during the region and contour build process.)
|
static |
Border vertex flag.
If a region ID has this bit set, then the associated element lies on a tile border. If a contour vertex's region ID has this bit set, the vertex will later be removed in order to match the segments and vertices at tile boundaries. (Used during the build process.)
|
static |
Applied to the region id field of contour vertices in order to extract the region id.
The region id field of a vertex may have several flags applied to it. So the fields value can't be used directly.
|
static |
An value which indicates an invalid index within a mesh.
|
static |
Polygon touches multiple regions.
If a polygon has this region ID it was merged with or created from polygons of different regions during the polymesh build step that removes redundant border vertices. (Used during the polymesh and detail polymesh build processes)
|
static |
The value returned by rcGetCon if the specified direction is not connected to another span.
(Has no neighbor.)
|
static |
Represents the null area.
When a data element is given this value it is considered to no longer be assigned to a usable area. (E.g. It is un-walkable.)
|
static |
The value of PI used by Recast.
|
static |
Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
|
static |
Defines the maximum value for rcSpan::smin and rcSpan::smax.
|
static |
The number of spans allocated per span spool.
|
static |
The default area id used to indicate a walkable polygon.
This is also the maximum allowed area id, and the only non-null area id recognized by some steps in the build process.