Recast Navigation  1.0.35
Recast.h File Reference
#include "SharedConfig.h"
#include "Util.h"
#include "Vector.h"
#include "Heightfield.h"
#include "CompactHeightfield.h"

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...
 
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...
 
struct  rcHeightThreshold
 

Enumerations

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...
 
enum  rcBuildContoursFlags { RC_CONTOUR_TESS_WALL_EDGES = 0x01, RC_CONTOUR_TESS_AREA_EDGES = 0x02 }
 Contour build flags. More...
 

Functions

void rcFilterHeightThresholds (rcContext *ctx, const rcHeightThreshold *heights, int numHeights, rcHeightfield &solid)
 
bool rcErodeWalkableArea (rcContext *ctx, int radius, rcCompactHeightfield &chf)
 Erodes the walkable area within the heightfield by the specified radius. More...
 
bool rcMedianFilterWalkableArea (rcContext *ctx, rcCompactHeightfield &chf)
 Applies a median filter to walkable area types (based on area id), removing noise. More...
 
void rcMarkBoxArea (rcContext *ctx, const float *bmin, const float *bmax, navAreaMask areaId, rcCompactHeightfield &chf)
 Applies an area id to all spans within the specified bounding box. More...
 
void rcMarkConvexPolyArea (rcContext *ctx, const float *verts, const int nverts, const float hmin, const float hmax, navAreaMask areaId, rcCompactHeightfield &chf)
 Applies the area id to the all spans within the specified convex polygon. More...
 
int rcOffsetPoly (const float *verts, const int nverts, const float offset, float *outVerts, const int maxOutVerts)
 Helper function to offset voncex polygons for rcMarkConvexPolyArea. More...
 
void rcMarkCylinderArea (rcContext *ctx, const float *pos, const float r, const float h, navAreaMask areaMask, rcCompactHeightfield &chf)
 Applies the area id to all spans within the specified cylinder. More...
 
bool rcBuildHeightfieldLayers (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int walkableHeight, rcHeightfieldLayerSet &lset)
 Builds a layer set from the specified compact heightfield. More...
 
bool rcBuildContours (rcContext *ctx, rcCompactHeightfield &chf, const float maxError, const int maxEdgeLen, rcContourSet &cset, const 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, 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, const float sampleDist, const 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...
 
int rcConvexhull (const float *pts, int npts, int *out)
 
Allocation Functions

Functions used to allocate and de-allocate Recast objects.

See also
rcAllocSetCustom
rcHeightfieldrcAllocHeightfield ()
 Allocates a heightfield object using the Recast allocator. More...
 
void rcFreeHeightField (rcHeightfield *hf)
 Frees the specified heightfield object using the Recast allocator. More...
 
rcCompactHeightfieldrcAllocCompactHeightfield ()
 Allocates a compact heightfield object using the Recast allocator. More...
 
void rcFreeCompactHeightfield (rcCompactHeightfield *chf)
 Frees the specified compact heightfield object using the Recast allocator. More...
 
rcHeightfieldLayerSetrcAllocHeightfieldLayerSet ()
 Allocates a heightfield layer set using the Recast allocator. More...
 
void rcFreeHeightfieldLayerSet (rcHeightfieldLayerSet *lset)
 Frees the specified heightfield layer set using the Recast allocator. More...
 
rcContourSetrcAllocContourSet ()
 Allocates a contour set object using the Recast allocator. More...
 
void rcFreeContourSet (rcContourSet *cset)
 Frees the specified contour set using the Recast allocator. More...
 
rcPolyMeshrcAllocPolyMesh ()
 Allocates a polygon mesh object using the Recast allocator. More...
 
void rcFreePolyMesh (rcPolyMesh *pmesh)
 Frees the specified polygon mesh using the Recast allocator. More...
 
rcPolyMeshDetailrcAllocPolyMeshDetail ()
 Allocates a detail mesh object using the Recast allocator. More...
 
void rcFreePolyMeshDetail (rcPolyMeshDetail *dmesh)
 Frees the specified detail mesh using the Recast allocator. More...
 
Compact Heightfield Functions
bool rcBuildRegions (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea)
 Builds region data for the heightfield using watershed partitioning. More...
 
bool rcBuildLayerRegions (rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea)
 Builds region data for the heightfield by partitioning the heightfield in non-overlapping layers. More...
 
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. More...
 

Variables

static const float RC_PI = 3.14159265f
 The value of PI used by Recast. More...
 
static const unsigned short RC_BORDER_REG = 0x8000
 Heighfield border flag. 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 navAreaMask RC_NULL_AREA = 0
 Represents the null area. More...
 
static const navAreaMask RC_WALKABLE_AREA = 0x1
 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...
 

Enumeration Type Documentation

Contour build flags.

See also
rcBuildContours
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.

Recast log categories.

See also
rcContext
Enumerator
RC_LOG_PROGRESS 

A progress log entry.

RC_LOG_WARNING 

A warning log entry.

RC_LOG_ERROR 

An error log entry.

Recast performance timer categories.

See also
rcContext
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.)

Function Documentation

int rcConvexhull ( const float *  pts,
int  npts,
int *  out 
)
void rcFilterHeightThresholds ( rcContext ctx,
const rcHeightThreshold heights,
int  numHeights,
rcHeightfield solid 
)

Variable Documentation

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.)

See also
rcCompactSpan::reg, rcContour::verts, rcContour::rverts
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.)

See also
rcCompactSpan::reg
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.)

See also
rcCompactSpan::reg, rcContour::verts, rcContour::rverts
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.

See also
rcContour::verts, rcContour::rverts
const unsigned short RC_MESH_NULL_IDX = 0xffff
static

An value which indicates an invalid index within a mesh.

Note
This does not necessarily indicate an error.
See also
rcPolyMesh::polys
const int RC_NOT_CONNECTED = 0x3f
static

The value returned by rcGetCon if the specified direction is not connected to another span.

(Has no neighbor.)

const navAreaMask RC_NULL_AREA = 0
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 unwalkable.)

const float RC_PI = 3.14159265f
static

The value of PI used by Recast.

const navAreaMask RC_WALKABLE_AREA = 0x1
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.