Planeshift
|
Go to the source code of this file.
Classes | |
struct | rcCompactCell |
Provides information on the content of a cell column in a compact heightfield. More... | |
struct | rcCompactHeightfield |
A compact, static heightfield representing unobstructed space. More... | |
struct | rcCompactSpan |
Represents a span of unobstructed space within a compact heightfield. More... | |
struct | rcConfig |
Specifies a configuration to use when performing Recast builds. More... | |
class | rcContext |
Provides an interface for optional logging and performance tracking of the Recast build process. More... | |
struct | rcContour |
Represents a simple, non-overlapping contour in field space. More... | |
struct | rcContourSet |
Represents a group of related contours. More... | |
struct | rcHeightfield |
A dynamic heightfield representing obstructed space. More... | |
struct | rcHeightfieldLayer |
Represents a heightfield layer within a layer set. More... | |
struct | rcHeightfieldLayerSet |
Represents a set of heightfield layers. 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... | |
struct | rcSpan |
Represents a span in a heightfield. More... | |
struct | rcSpanPool |
A memory pool used for quick allocation of spans within a heightfield. More... | |
Enumerations | |
enum | rcBuildContoursFlags { RC_CONTOUR_TESS_WALL_EDGES = 0x01, RC_CONTOUR_TESS_AREA_EDGES = 0x02 } |
Contour build flags. More... | |
enum | rcLogCategory { RC_LOG_PROGRESS = 1, RC_LOG_WARNING, RC_LOG_ERROR } |
Recast log categories. More... | |
enum | rcTimerLabel { RC_TIMER_TOTAL, RC_TIMER_TEMP, RC_TIMER_RASTERIZE_TRIANGLES, RC_TIMER_BUILD_COMPACTHEIGHTFIELD, RC_TIMER_BUILD_CONTOURS, RC_TIMER_BUILD_CONTOURS_TRACE, RC_TIMER_BUILD_CONTOURS_SIMPLIFY, RC_TIMER_FILTER_BORDER, RC_TIMER_FILTER_WALKABLE, RC_TIMER_MEDIAN_AREA, RC_TIMER_FILTER_LOW_OBSTACLES, RC_TIMER_BUILD_POLYMESH, RC_TIMER_MERGE_POLYMESH, RC_TIMER_ERODE_AREA, RC_TIMER_MARK_BOX_AREA, RC_TIMER_MARK_CYLINDER_AREA, RC_TIMER_MARK_CONVEXPOLY_AREA, RC_TIMER_BUILD_DISTANCEFIELD, RC_TIMER_BUILD_DISTANCEFIELD_DIST, RC_TIMER_BUILD_DISTANCEFIELD_BLUR, RC_TIMER_BUILD_REGIONS, RC_TIMER_BUILD_REGIONS_WATERSHED, RC_TIMER_BUILD_REGIONS_EXPAND, RC_TIMER_BUILD_REGIONS_FLOOD, RC_TIMER_BUILD_REGIONS_FILTER, RC_TIMER_BUILD_LAYERS, RC_TIMER_BUILD_POLYMESHDETAIL, RC_TIMER_MERGE_POLYMESHDETAIL, RC_MAX_TIMERS } |
Recast performance timer categories. More... | |
Functions | |
Allocation Functions | |
Functions used to allocate and de-allocate Recast objects.
| |
rcHeightfield * | rcAllocHeightfield () |
Allocates a heightfield object using the Recast allocator. | |
void | rcFreeHeightField (rcHeightfield *hf) |
Frees the specified heightfield object using the Recast allocator. | |
rcCompactHeightfield * | rcAllocCompactHeightfield () |
Allocates a compact heightfield object using the Recast allocator. | |
void | rcFreeCompactHeightfield (rcCompactHeightfield *chf) |
Frees the specified compact heightfield object using the Recast allocator. | |
rcHeightfieldLayerSet * | rcAllocHeightfieldLayerSet () |
Allocates a heightfield layer set using the Recast allocator. | |
void | rcFreeHeightfieldLayerSet (rcHeightfieldLayerSet *lset) |
Frees the specified heightfield layer set using the Recast allocator. | |
rcContourSet * | rcAllocContourSet () |
Allocates a contour set object using the Recast allocator. | |
void | rcFreeContourSet (rcContourSet *cset) |
Frees the specified contour set using the Recast allocator. | |
rcPolyMesh * | rcAllocPolyMesh () |
Allocates a polygon mesh object using the Recast allocator. | |
void | rcFreePolyMesh (rcPolyMesh *pmesh) |
Frees the specified polygon mesh using the Recast allocator. | |
rcPolyMeshDetail * | rcAllocPolyMeshDetail () |
Allocates a detail mesh object using the Recast allocator. | |
void | rcFreePolyMeshDetail (rcPolyMeshDetail *dmesh) |
Frees the specified detail mesh using the Recast allocator. | |
General helper functions | |
template<class T > | |
void | rcSwap (T &a, T &b) |
Swaps the values of the two parameters. | |
template<class T > | |
T | rcMin (T a, T b) |
Returns the minimum of two values. | |
template<class T > | |
T | rcMax (T a, T b) |
Returns the maximum of two values. | |
template<class T > | |
T | rcAbs (T a) |
Returns the absolute value. | |
template<class T > | |
T | rcSqr (T a) |
Returns the square of the value. | |
template<class T > | |
T | rcClamp (T v, T mn, T mx) |
Clamps the value to the specified range. | |
float | rcSqrt (float x) |
Returns the square root of the value. | |
Vector helper functions. | |
void | rcVcross (float *dest, const float *v1, const float *v2) |
Derives the cross product of two vectors. (v1 x v2 ) | |
float | rcVdot (const float *v1, const float *v2) |
Derives the dot product of two vectors. (v1 . v2 ) | |
void | rcVmad (float *dest, const float *v1, const float *v2, const float s) |
Performs a scaled vector addition. (v1 + (v2 * s )) | |
void | rcVadd (float *dest, const float *v1, const float *v2) |
Performs a vector addition. (v1 + v2 ) | |
void | rcVsub (float *dest, const float *v1, const float *v2) |
Performs a vector subtraction. (v1 - v2 ) | |
void | rcVmin (float *mn, const float *v) |
Selects the minimum value of each element from the specified vectors. | |
void | rcVmax (float *mx, const float *v) |
Selects the maximum value of each element from the specified vectors. | |
void | rcVcopy (float *dest, const float *v) |
Performs a vector copy. | |
float | rcVdist (const float *v1, const float *v2) |
Returns the distance between two points. | |
float | rcVdistSqr (const float *v1, const float *v2) |
Returns the square of the distance between two points. | |
void | rcVnormalize (float *v) |
Normalizes the vector. | |
Heightfield Functions | |
| |
void | rcCalcBounds (const float *verts, int nv, float *bmin, float *bmax) |
Calculates the bounding box of an array of vertices. | |
void | rcCalcGridSize (const float *bmin, const float *bmax, float cs, int *w, int *h) |
Calculates the grid size based on the bounding box and grid cell size. | |
bool | rcCreateHeightfield (rcContext *ctx, rcHeightfield &hf, int width, int height, const float *bmin, const float *bmax, float cs, float ch) |
Initializes a new heightfield. | |
void | rcMarkWalkableTriangles (rcContext *ctx, const float walkableSlopeAngle, const float *verts, int nv, const int *tris, int nt, unsigned char *areas) |
Sets the area id of all triangles with a slope below the specified value to RC_WALKABLE_AREA. | |
void | rcClearUnwalkableTriangles (rcContext *ctx, const float walkableSlopeAngle, const float *verts, int nv, const int *tris, int nt, unsigned char *areas) |
Sets the area id of all triangles with a slope greater than or equal to the specified value to RC_NULL_AREA. | |
void | rcAddSpan (rcContext *ctx, rcHeightfield &hf, const int x, const int y, const unsigned short smin, const unsigned short smax, const unsigned char area, const int flagMergeThr) |
Adds a span to the specified heightfield. | |
void | rcRasterizeTriangle (rcContext *ctx, const float *v0, const float *v1, const float *v2, const unsigned char area, rcHeightfield &solid, const int flagMergeThr=1) |
Rasterizes a triangle into the specified heightfield. | |
void | rcRasterizeTriangles (rcContext *ctx, const float *verts, const int nv, const int *tris, const unsigned char *areas, const int nt, rcHeightfield &solid, const int flagMergeThr=1) |
Rasterizes an indexed triangle mesh into the specified heightfield. | |
void | rcRasterizeTriangles (rcContext *ctx, const float *verts, const int nv, const unsigned short *tris, const unsigned char *areas, const int nt, rcHeightfield &solid, const int flagMergeThr=1) |
Rasterizes an indexed triangle mesh into the specified heightfield. | |
void | rcRasterizeTriangles (rcContext *ctx, const float *verts, const unsigned char *areas, const int nt, rcHeightfield &solid, const int flagMergeThr=1) |
Rasterizes triangles into the specified heightfield. | |
void | rcFilterLowHangingWalkableObstacles (rcContext *ctx, const int walkableClimb, rcHeightfield &solid) |
Marks non-walkable spans as walkable if their maximum is within walkableClimp of a walkable neihbor. | |
void | rcFilterLedgeSpans (rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &solid) |
Marks spans that are ledges as not-walkable. | |
void | rcFilterWalkableLowHeightSpans (rcContext *ctx, int walkableHeight, rcHeightfield &solid) |
Marks walkable spans as not walkable if the clearence above the span is less than the specified height. | |
int | rcGetHeightFieldSpanCount (rcContext *ctx, rcHeightfield &hf) |
Returns the number of spans contained in the specified heightfield. | |
Compact Heightfield Functions | |
| |
bool | rcBuildCompactHeightfield (rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &hf, rcCompactHeightfield &chf) |
Builds a compact heightfield representing open space, from a heightfield representing solid space. | |
bool | rcErodeWalkableArea (rcContext *ctx, int radius, rcCompactHeightfield &chf) |
Erodes the walkable area within the heightfield by the specified radius. | |
bool | rcMedianFilterWalkableArea (rcContext *ctx, rcCompactHeightfield &chf) |
Applies a median filter to walkable area types (based on area id), removing noise. | |
void | rcMarkBoxArea (rcContext *ctx, const float *bmin, const float *bmax, unsigned char areaId, rcCompactHeightfield &chf) |
Applies an area id to all spans within the specified bounding box. (AABB) | |
void | rcMarkConvexPolyArea (rcContext *ctx, const float *verts, const int nverts, const float hmin, const float hmax, unsigned char areaId, rcCompactHeightfield &chf) |
Applies the area id to the all spans within the specified convex polygon. | |
int | rcOffsetPoly (const float *verts, const int nverts, const float offset, float *outVerts, const int maxOutVerts) |
Helper function to offset voncex polygons for rcMarkConvexPolyArea. | |
void | rcMarkCylinderArea (rcContext *ctx, const float *pos, const float r, const float h, unsigned char areaId, rcCompactHeightfield &chf) |
Applies the area id to all spans within the specified cylinder. | |
bool | rcBuildDistanceField (rcContext *ctx, rcCompactHeightfield &chf) |
Builds the distance field for the specified compact heightfield. | |
bool | rcBuildRegions (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea) |
Builds region data for the heightfield using watershed partitioning. | |
bool | rcBuildRegionsMonotone (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea) |
Builds region data for the heightfield using simple monotone partitioning. | |
void | rcSetCon (rcCompactSpan &s, int dir, int i) |
Sets the neighbor connection data for the specified direction. | |
int | rcGetCon (const rcCompactSpan &s, int dir) |
Gets neighbor connection data for the specified direction. | |
int | rcGetDirOffsetX (int dir) |
Gets the standard width (x-axis) offset for the specified direction. | |
int | rcGetDirOffsetY (int dir) |
Gets the standard height (z-axis) offset for the specified direction. | |
Layer, Contour, Polymesh, and Detail Mesh Functions | |
| |
bool | rcBuildHeightfieldLayers (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int walkableHeight, rcHeightfieldLayerSet &lset) |
Builds a layer set from the specified compact heightfield. | |
bool | rcBuildContours (rcContext *ctx, rcCompactHeightfield &chf, const float maxError, const int maxEdgeLen, rcContourSet &cset, const int flags=RC_CONTOUR_TESS_WALL_EDGES) |
Builds a contour set from the region outlines in the provided compact heightfield. | |
bool | rcBuildPolyMesh (rcContext *ctx, rcContourSet &cset, const int nvp, rcPolyMesh &mesh) |
Builds a polygon mesh from the provided contours. | |
bool | rcMergePolyMeshes (rcContext *ctx, rcPolyMesh **meshes, const int nmeshes, rcPolyMesh &mesh) |
Merges multiple polygon meshes into a single mesh. | |
bool | rcBuildPolyMeshDetail (rcContext *ctx, const rcPolyMesh &mesh, const rcCompactHeightfield &chf, const float sampleDist, const float sampleMaxError, rcPolyMeshDetail &dmesh) |
Builds a detail mesh from the provided polygon mesh. | |
bool | rcCopyPolyMesh (rcContext *ctx, const rcPolyMesh &src, rcPolyMesh &dst) |
Copies the poly mesh data from src to dst. | |
bool | rcMergePolyMeshDetails (rcContext *ctx, rcPolyMeshDetail **meshes, const int nmeshes, rcPolyMeshDetail &mesh) |
Merges multiple detail meshes into a single detail mesh. | |
Variables | |
static const int | RC_AREA_BORDER = 0x20000 |
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 const unsigned short | RC_BORDER_REG = 0x8000 |
Heighfield border flag. If a heightfield region ID has this bit set, then the region is a border region and its spans are considered unwalkable. (Used during the region and contour build process.) | |
static const int | RC_BORDER_VERTEX = 0x10000 |
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 const int | RC_CONTOUR_REG_MASK = 0xffff |
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 const unsigned short | RC_MESH_NULL_IDX = 0xffff |
An value which indicates an invalid index within a mesh. | |
static const int | RC_NOT_CONNECTED = 0x3f |
The value returned by rcGetCon if the specified direction is not connected to another span. (Has no neighbor.) | |
static const unsigned char | RC_NULL_AREA = 0 |
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 unwalkable.) | |
static const float | RC_PI = 3.14159265f |
The value of PI used by Recast. | |
static const int | RC_SPAN_HEIGHT_BITS = 13 |
Defines the number of bits allocated to rcSpan::smin and rcSpan::smax. | |
static const int | RC_SPAN_MAX_HEIGHT = (1<<RC_SPAN_HEIGHT_BITS)-1 |
Defines the maximum value for rcSpan::smin and rcSpan::smax. | |
static const int | RC_SPANS_PER_POOL = 2048 |
The number of spans allocated per span spool. | |
static const unsigned char | RC_WALKABLE_AREA = 63 |
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. |
enum rcBuildContoursFlags |
Contour build flags.
enum rcLogCategory |
enum rcTimerLabel |
Recast performance timer categories.
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.) |
T rcAbs | ( | T | a | ) | [inline] |
void rcAddSpan | ( | rcContext * | ctx, |
rcHeightfield & | hf, | ||
const int | x, | ||
const int | y, | ||
const unsigned short | smin, | ||
const unsigned short | smax, | ||
const unsigned char | area, | ||
const int | flagMergeThr | ||
) |
Adds a span to the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | hf | An initialized heightfield. |
[in] | x | The width index where the span is to be added. [Limits: 0 <= value < rcHeightfield::width] |
[in] | y | The height index where the span is to be added. [Limits: 0 <= value < rcHeightfield::height] |
[in] | smin | The minimum height of the span. [Limit: < smax ] [Units: vx] |
[in] | smax | The maximum height of the span. [Limit: <= RC_SPAN_MAX_HEIGHT] [Units: vx] |
[in] | area | The area id of the span. [Limit: <= RC_WALKABLE_AREA) |
[in] | flagMergeThr | The merge theshold. [Limit: >= 0] [Units: vx] |
rcCompactHeightfield* rcAllocCompactHeightfield | ( | ) |
Allocates a compact heightfield object using the Recast allocator.
rcContourSet* rcAllocContourSet | ( | ) |
Allocates a contour set object using the Recast allocator.
rcHeightfield* rcAllocHeightfield | ( | ) |
Allocates a heightfield object using the Recast allocator.
rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet | ( | ) |
Allocates a heightfield layer set using the Recast allocator.
rcPolyMesh* rcAllocPolyMesh | ( | ) |
Allocates a polygon mesh object using the Recast allocator.
rcPolyMeshDetail* rcAllocPolyMeshDetail | ( | ) |
Allocates a detail mesh object using the Recast allocator.
bool rcBuildCompactHeightfield | ( | rcContext * | ctx, |
const int | walkableHeight, | ||
const int | walkableClimb, | ||
rcHeightfield & | hf, | ||
rcCompactHeightfield & | chf | ||
) |
Builds a compact heightfield representing open space, from a heightfield representing solid space.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableHeight | Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3] [Units: vx] |
[in] | walkableClimb | Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] |
[in] | hf | The heightfield to be compacted. |
[out] | chf | The resulting compact heightfield. (Must be pre-allocated.) |
bool rcBuildContours | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf, | ||
const float | maxError, | ||
const int | maxEdgeLen, | ||
rcContourSet & | cset, | ||
const int | flags = RC_CONTOUR_TESS_WALL_EDGES |
||
) |
Builds a contour set from the region outlines in the provided compact heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | chf | A fully built compact heightfield. |
[in] | maxError | The maximum distance a simplfied contour's border edges should deviate the original raw contour. [Limit: >=0] [Units: wu] |
[in] | maxEdgeLen | The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx] |
[out] | cset | The resulting contour set. (Must be pre-allocated.) |
[in] | buildFlags | The build flags. (See: rcBuildContoursFlags) |
bool rcBuildDistanceField | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf | ||
) |
Builds the distance field for the specified compact heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | chf | A populated compact heightfield. |
bool rcBuildHeightfieldLayers | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf, | ||
const int | borderSize, | ||
const int | walkableHeight, | ||
rcHeightfieldLayerSet & | lset | ||
) |
Builds a layer set from the specified compact heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | chf | A fully built compact heightfield. |
[in] | borderSize | The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx] |
[in] | walkableHeight | Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3] [Units: vx] |
[out] | lset | The resulting layer set. (Must be pre-allocated.) |
bool rcBuildPolyMesh | ( | rcContext * | ctx, |
rcContourSet & | cset, | ||
const int | nvp, | ||
rcPolyMesh & | mesh | ||
) |
Builds a polygon mesh from the provided contours.
[in,out] | ctx | The build context to use during the operation. |
[in] | cset | A fully built contour set. |
[in] | nvp | The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process. [Limit: >= 3] |
[out] | mesh | The resulting polygon mesh. (Must be re-allocated.) |
bool rcBuildPolyMeshDetail | ( | rcContext * | ctx, |
const rcPolyMesh & | mesh, | ||
const rcCompactHeightfield & | chf, | ||
const float | sampleDist, | ||
const float | sampleMaxError, | ||
rcPolyMeshDetail & | dmesh | ||
) |
Builds a detail mesh from the provided polygon mesh.
[in,out] | ctx | The build context to use during the operation. |
[in] | mesh | A fully built polygon mesh. |
[in] | chf | The compact heightfield used to build the polygon mesh. |
[in] | sampleDist | Sets the distance to use when samping the heightfield. [Limit: >=0] [Units: wu] |
[in] | sampleMaxError | The maximum distance the detail mesh surface should deviate from heightfield data. [Limit: >=0] [Units: wu] |
[out] | dmesh | The resulting detail mesh. (Must be pre-allocated.) |
bool rcBuildRegions | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf, | ||
const int | borderSize, | ||
const int | minRegionArea, | ||
const int | mergeRegionArea | ||
) |
Builds region data for the heightfield using watershed partitioning.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | chf | A populated compact heightfield. |
[in] | borderSize | The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx] |
[in] | minRegionArea | The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]. |
[in] | mergeRegionArea | Any regions with a span count smaller than this value will, if possible, be merged with larger regions. [Limit: >=0] [Units: vx] |
bool rcBuildRegionsMonotone | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf, | ||
const int | borderSize, | ||
const int | minRegionArea, | ||
const int | mergeRegionArea | ||
) |
Builds region data for the heightfield using simple monotone partitioning.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | chf | A populated compact heightfield. |
[in] | borderSize | The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx] |
[in] | minRegionArea | The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]. |
[in] | mergeRegionArea | Any regions with a span count smaller than this value will, if possible, be merged with larger regions. [Limit: >=0] [Units: vx] |
Calculates the bounding box of an array of vertices.
[in] | verts | An array of vertices. [(x, y, z) * nv ] |
[in] | nv | The number of vertices in the verts array. |
[out] | bmin | The minimum bounds of the AABB. [(x, y, z)] [Units: wu] |
[out] | bmax | The maximum bounds of the AABB. [(x, y, z)] [Units: wu] |
Calculates the grid size based on the bounding box and grid cell size.
[in] | bmin | The minimum bounds of the AABB. [(x, y, z)] [Units: wu] |
[in] | bmax | The maximum bounds of the AABB. [(x, y, z)] [Units: wu] |
[in] | cs | The xz-plane cell size. [Limit: > 0] [Units: wu] |
[out] | w | The width along the x-axis. [Limit: >= 0] [Units: vx] |
[out] | h | The height along the z-axis. [Limit: >= 0] [Units: vx] |
T rcClamp | ( | T | v, |
T | mn, | ||
T | mx | ||
) | [inline] |
void rcClearUnwalkableTriangles | ( | rcContext * | ctx, |
const float | walkableSlopeAngle, | ||
const float * | verts, | ||
int | nv, | ||
const int * | tris, | ||
int | nt, | ||
unsigned char * | areas | ||
) |
Sets the area id of all triangles with a slope greater than or equal to the specified value to RC_NULL_AREA.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableSlopeAngle | The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees] |
[in] | verts | The vertices. [(x, y, z) * nv ] |
[in] | nv | The number of vertices. |
[in] | tris | The triangle vertex indices. [(vertA, vertB, vertC) * nt ] |
[in] | nt | The number of triangles. |
[out] | areas | The triangle area ids. [Length: >= nt ] |
bool rcCopyPolyMesh | ( | rcContext * | ctx, |
const rcPolyMesh & | src, | ||
rcPolyMesh & | dst | ||
) |
Copies the poly mesh data from src to dst.
[in,out] | ctx | The build context to use during the operation. |
[in] | src | The source mesh to copy from. |
[out] | dst | The resulting detail mesh. (Must be pre-allocated, must be empty mesh.) |
bool rcCreateHeightfield | ( | rcContext * | ctx, |
rcHeightfield & | hf, | ||
int | width, | ||
int | height, | ||
const float * | bmin, | ||
const float * | bmax, | ||
float | cs, | ||
float | ch | ||
) |
Initializes a new heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | hf | The allocated heightfield to initialize. |
[in] | width | The width of the field along the x-axis. [Limit: >= 0] [Units: vx] |
[in] | height | The height of the field along the z-axis. [Limit: >= 0] [Units: vx] |
[in] | bmin | The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu] |
[in] | bmax | The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu] |
[in] | cs | The xz-plane cell size to use for the field. [Limit: > 0] [Units: wu] |
[in] | ch | The y-axis cell size to use for field. [Limit: > 0] [Units: wu] |
bool rcErodeWalkableArea | ( | rcContext * | ctx, |
int | radius, | ||
rcCompactHeightfield & | chf | ||
) |
Erodes the walkable area within the heightfield by the specified radius.
[in,out] | ctx | The build context to use during the operation. |
[in] | radius | The radius of erosion. [Limits: 0 < value < 255] [Units: vx] |
[in,out] | chf | The populated compact heightfield to erode. |
void rcFilterLedgeSpans | ( | rcContext * | ctx, |
const int | walkableHeight, | ||
const int | walkableClimb, | ||
rcHeightfield & | solid | ||
) |
Marks spans that are ledges as not-walkable.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableHeight | Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3] [Units: vx] |
[in] | walkableClimb | Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] |
[in,out] | solid | A fully built heightfield. (All spans have been added.) |
void rcFilterLowHangingWalkableObstacles | ( | rcContext * | ctx, |
const int | walkableClimb, | ||
rcHeightfield & | solid | ||
) |
Marks non-walkable spans as walkable if their maximum is within walkableClimp
of a walkable neihbor.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableClimb | Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] |
[in,out] | solid | A fully built heightfield. (All spans have been added.) |
void rcFilterWalkableLowHeightSpans | ( | rcContext * | ctx, |
int | walkableHeight, | ||
rcHeightfield & | solid | ||
) |
Marks walkable spans as not walkable if the clearence above the span is less than the specified height.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableHeight | Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable. [Limit: >= 3] [Units: vx] |
[in,out] | solid | A fully built heightfield. (All spans have been added.) |
void rcFreeCompactHeightfield | ( | rcCompactHeightfield * | chf | ) |
Frees the specified compact heightfield object using the Recast allocator.
[in] | chf | A compact heightfield allocated using rcAllocCompactHeightfield |
void rcFreeContourSet | ( | rcContourSet * | cset | ) |
Frees the specified contour set using the Recast allocator.
[in] | cset | A contour set allocated using rcAllocContourSet |
void rcFreeHeightField | ( | rcHeightfield * | hf | ) |
Frees the specified heightfield object using the Recast allocator.
[in] | hf | A heightfield allocated using rcAllocHeightfield |
void rcFreeHeightfieldLayerSet | ( | rcHeightfieldLayerSet * | lset | ) |
Frees the specified heightfield layer set using the Recast allocator.
[in] | lset | A heightfield layer set allocated using rcAllocHeightfieldLayerSet |
void rcFreePolyMesh | ( | rcPolyMesh * | pmesh | ) |
Frees the specified polygon mesh using the Recast allocator.
[in] | pmesh | A polygon mesh allocated using rcAllocPolyMesh |
void rcFreePolyMeshDetail | ( | rcPolyMeshDetail * | dmesh | ) |
Frees the specified detail mesh using the Recast allocator.
[in] | dmesh | A detail mesh allocated using rcAllocPolyMeshDetail |
int rcGetCon | ( | const rcCompactSpan & | s, |
int | dir | ||
) | [inline] |
Gets neighbor connection data for the specified direction.
[in] | s | The span to check. |
[in] | dir | The direction to check. [Limits: 0 <= value < 4] |
int rcGetHeightFieldSpanCount | ( | rcContext * | ctx, |
rcHeightfield & | hf | ||
) |
Returns the number of spans contained in the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | hf | An initialized heightfield. |
void rcMarkBoxArea | ( | rcContext * | ctx, |
const float * | bmin, | ||
const float * | bmax, | ||
unsigned char | areaId, | ||
rcCompactHeightfield & | chf | ||
) |
Applies an area id to all spans within the specified bounding box. (AABB)
[in,out] | ctx | The build context to use during the operation. |
[in] | bmin | The minimum of the bounding box. [(x, y, z)] |
[in] | bmax | The maximum of the bounding box. [(x, y, z)] |
[in] | areaId | The area id to apply. [Limit: <= RC_WALKABLE_AREA] |
[in,out] | chf | A populated compact heightfield. |
void rcMarkConvexPolyArea | ( | rcContext * | ctx, |
const float * | verts, | ||
const int | nverts, | ||
const float | hmin, | ||
const float | hmax, | ||
unsigned char | areaId, | ||
rcCompactHeightfield & | chf | ||
) |
Applies the area id to the all spans within the specified convex polygon.
[in,out] | ctx | The build context to use during the operation. |
[in] | verts | The vertices of the polygon [Fomr: (x, y, z) * nverts ] |
[in] | nverts | The number of vertices in the polygon. |
[in] | hmin | The height of the base of the polygon. |
[in] | hmax | The height of the top of the polygon. |
[in] | areaId | The area id to apply. [Limit: <= RC_WALKABLE_AREA] |
[in,out] | chf | A populated compact heightfield. |
void rcMarkCylinderArea | ( | rcContext * | ctx, |
const float * | pos, | ||
const float | r, | ||
const float | h, | ||
unsigned char | areaId, | ||
rcCompactHeightfield & | chf | ||
) |
Applies the area id to all spans within the specified cylinder.
[in,out] | ctx | The build context to use during the operation. |
[in] | pos | The center of the base of the cylinder. [Form: (x, y, z)] |
[in] | r | The radius of the cylinder. |
[in] | h | The height of the cylinder. |
[in] | areaId | The area id to apply. [Limit: <= RC_WALKABLE_AREA] |
[in,out] | chf | A populated compact heightfield. |
void rcMarkWalkableTriangles | ( | rcContext * | ctx, |
const float | walkableSlopeAngle, | ||
const float * | verts, | ||
int | nv, | ||
const int * | tris, | ||
int | nt, | ||
unsigned char * | areas | ||
) |
Sets the area id of all triangles with a slope below the specified value to RC_WALKABLE_AREA.
[in,out] | ctx | The build context to use during the operation. |
[in] | walkableSlopeAngle | The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees] |
[in] | verts | The vertices. [(x, y, z) * nv ] |
[in] | nv | The number of vertices. |
[in] | tris | The triangle vertex indices. [(vertA, vertB, vertC) * nt ] |
[in] | nt | The number of triangles. |
[out] | areas | The triangle area ids. [Length: >= nt ] |
T rcMax | ( | T | a, |
T | b | ||
) | [inline] |
bool rcMedianFilterWalkableArea | ( | rcContext * | ctx, |
rcCompactHeightfield & | chf | ||
) |
Applies a median filter to walkable area types (based on area id), removing noise.
[in,out] | ctx | The build context to use during the operation. |
[in,out] | chf | A populated compact heightfield. |
bool rcMergePolyMeshDetails | ( | rcContext * | ctx, |
rcPolyMeshDetail ** | meshes, | ||
const int | nmeshes, | ||
rcPolyMeshDetail & | mesh | ||
) |
Merges multiple detail meshes into a single detail mesh.
[in,out] | ctx | The build context to use during the operation. |
[in] | meshes | An array of detail meshes to merge. [Size: nmeshes ] |
[in] | nmeshes | The number of detail meshes in the meshes array. |
[out] | mesh | The resulting detail mesh. (Must be pre-allocated.) |
bool rcMergePolyMeshes | ( | rcContext * | ctx, |
rcPolyMesh ** | meshes, | ||
const int | nmeshes, | ||
rcPolyMesh & | mesh | ||
) |
Merges multiple polygon meshes into a single mesh.
[in,out] | ctx | The build context to use during the operation. |
[in] | meshes | An array of polygon meshes to merge. [Size: nmeshes ] |
[in] | nmeshes | The number of polygon meshes in the meshes array. |
[in] | mesh | The resulting polygon mesh. (Must be pre-allocated.) |
T rcMin | ( | T | a, |
T | b | ||
) | [inline] |
int rcOffsetPoly | ( | const float * | verts, |
const int | nverts, | ||
const float | offset, | ||
float * | outVerts, | ||
const int | maxOutVerts | ||
) |
Helper function to offset voncex polygons for rcMarkConvexPolyArea.
[in] | verts | The vertices of the polygon [Form: (x, y, z) * nverts ] |
[in] | nverts | The number of vertices in the polygon. |
[out] | outVerts | The offset vertices (should hold up to 2 * nverts ) [Form: (x, y, z) * return value] |
[in] | maxOutVerts | The max number of vertices that can be stored to outVerts . |
outVerts
. void rcRasterizeTriangle | ( | rcContext * | ctx, |
const float * | v0, | ||
const float * | v1, | ||
const float * | v2, | ||
const unsigned char | area, | ||
rcHeightfield & | solid, | ||
const int | flagMergeThr = 1 |
||
) |
Rasterizes a triangle into the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | v0 | Triangle vertex 0 [(x, y, z)] |
[in] | v1 | Triangle vertex 1 [(x, y, z)] |
[in] | v2 | Triangle vertex 2 [(x, y, z)] |
[in] | area | The area id of the triangle. [Limit: <= RC_WALKABLE_AREA] |
[in,out] | solid | An initialized heightfield. |
[in] | flagMergeThr | The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] |
void rcRasterizeTriangles | ( | rcContext * | ctx, |
const float * | verts, | ||
const int | nv, | ||
const unsigned short * | tris, | ||
const unsigned char * | areas, | ||
const int | nt, | ||
rcHeightfield & | solid, | ||
const int | flagMergeThr = 1 |
||
) |
Rasterizes an indexed triangle mesh into the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | verts | The vertices. [(x, y, z) * nv ] |
[in] | nv | The number of vertices. |
[in] | tris | The triangle indices. [(vertA, vertB, vertC) * nt ] |
[in] | areas | The area id's of the triangles. [Limit: <= RC_WALKABLE_AREA] [Size: nt ] |
[in] | nt | The number of triangles. |
[in,out] | solid | An initialized heightfield. |
[in] | flagMergeThr | The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] |
void rcRasterizeTriangles | ( | rcContext * | ctx, |
const float * | verts, | ||
const int | nv, | ||
const int * | tris, | ||
const unsigned char * | areas, | ||
const int | nt, | ||
rcHeightfield & | solid, | ||
const int | flagMergeThr = 1 |
||
) |
Rasterizes an indexed triangle mesh into the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | verts | The vertices. [(x, y, z) * nv ] |
[in] | nv | The number of vertices. |
[in] | tris | The triangle indices. [(vertA, vertB, vertC) * nt ] |
[in] | areas | The area id's of the triangles. [Limit: <= RC_WALKABLE_AREA] [Size: nt ] |
[in] | nt | The number of triangles. |
[in,out] | solid | An initialized heightfield. |
[in] | flagMergeThr | The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] |
void rcRasterizeTriangles | ( | rcContext * | ctx, |
const float * | verts, | ||
const unsigned char * | areas, | ||
const int | nt, | ||
rcHeightfield & | solid, | ||
const int | flagMergeThr = 1 |
||
) |
Rasterizes triangles into the specified heightfield.
[in,out] | ctx | The build context to use during the operation. |
[in] | verts | The triangle vertices. [(ax, ay, az, bx, by, bz, cx, by, cx) * nt ] |
[in] | areas | The area id's of the triangles. [Limit: <= RC_WALKABLE_AREA] [Size: nt ] |
[in] | nt | The number of triangles. |
[in,out] | solid | An initialized heightfield. |
[in] | flagMergeThr | The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] |
void rcSetCon | ( | rcCompactSpan & | s, |
int | dir, | ||
int | i | ||
) | [inline] |
T rcSqr | ( | T | a | ) | [inline] |
Returns the square root of the value.
[in] | x | The value. |
void rcSwap | ( | T & | a, |
T & | b | ||
) | [inline] |
void rcVnormalize | ( | float * | v | ) | [inline] |
const int RC_AREA_BORDER = 0x20000 [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.)
const unsigned short RC_BORDER_REG = 0x8000 [static] |
Heighfield border flag. If a heightfield region ID has this bit set, then the region is a border region and its spans are considered unwalkable. (Used during the region and contour build process.)
const int RC_BORDER_VERTEX = 0x10000 [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.)
const int RC_CONTOUR_REG_MASK = 0xffff [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.
const unsigned short RC_MESH_NULL_IDX = 0xffff [static] |
An value which indicates an invalid index within a mesh.
const int RC_NOT_CONNECTED = 0x3f [static] |
const unsigned char RC_NULL_AREA = 0 [static] |
const int RC_SPAN_HEIGHT_BITS = 13 [static] |
Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
const int RC_SPAN_MAX_HEIGHT = (1<<RC_SPAN_HEIGHT_BITS)-1 [static] |
Defines the maximum value for rcSpan::smin and rcSpan::smax.
const int RC_SPANS_PER_POOL = 2048 [static] |
The number of spans allocated per span spool.
const unsigned char RC_WALKABLE_AREA = 63 [static] |