UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RecastRegion.cpp File Reference
#include "CoreMinimal.h"
#include "Stats/Stats.h"
#include "Recast/Recast.h"
#include "Recast/RecastAlloc.h"
#include "Recast/RecastAssert.h"

Classes

struct  rcRegion
 
struct  rcSweepSpan
 

Namespaces

namespace  RecastRegionFunc
 
namespace  UE
 
namespace  UE::Recast
 
namespace  UE::Recast::Private
 

Macros

#define _USE_MATH_DEFINES
 

Functions

bool rcBuildDistanceField (rcContext *ctx, rcCompactHeightfield &chf)
 
void UE::Recast::Private::rcMarkBorderRegions (const rcBorderSize borderSize, const int w, const int h, rcCompactHeightfield &chf, unsigned short *srcReg, unsigned short &id)
 
bool rcBuildRegionsMonotone (rcContext *ctx, rcCompactHeightfield &chf, const rcBorderSize borderSize, const int minRegionArea, const int mergeRegionArea)
 
bool rcBuildRegionsChunky (rcContext *ctx, rcCompactHeightfield &chf, const rcBorderSize borderSize, const int minRegionArea, const int mergeRegionArea, const int regionChunkSize)
 
bool rcGatherRegionsNoFilter (rcContext *ctx, rcCompactHeightfield &chf, const rcBorderSize borderSize, unsigned short *spanBuf4)
 helper function from RecastRegion.cpp, requires distance data in compact height field
 
bool rcBuildRegions (rcContext *ctx, rcCompactHeightfield &chf, const rcBorderSize borderSize, const int minRegionArea, const int mergeRegionArea)
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Function Documentation

◆ rcBuildDistanceField()

bool rcBuildDistanceField ( rcContext ctx,
rcCompactHeightfield chf 
)

This is usually the second to the last step in creating a fully built compact heightfield. This step is required before regions are built using rcBuildRegions or rcBuildRegionsMonotone.

After this step, the distance data is available via the rcCompactHeightfield::maxDistance and rcCompactHeightfield::dist fields.

See also
rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone

◆ rcBuildRegions()

bool rcBuildRegions ( rcContext ctx,
rcCompactHeightfield chf,
const rcBorderSize  borderSize,
const int  minRegionArea,
const int  mergeRegionArea 
)

Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour. Contours will form simple polygons.

If multiple regions form an area that is smaller than minRegionArea, then all spans will be re-assigned to the zero (null) region.

Watershed partitioning can result in smaller than necessary regions, especially in diagonal corridors. mergeRegionArea helps reduce unecessarily small regions.

See the rcConfig documentation for more information on the configuration parameters.

The region data will be available via the rcCompactHeightfield::maxRegions and rcCompactSpan::reg fields.

Warning
The distance field must be created using rcBuildDistanceField before attempting to build regions.
See also
rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig

◆ rcBuildRegionsChunky()

bool rcBuildRegionsChunky ( rcContext ctx,
rcCompactHeightfield chf,
const rcBorderSize  borderSize,
const int  minRegionArea,
const int  mergeRegionArea,
const int  chunkSize 
)

Builds region data for the heightfield using simple monotone partitioning.

Parameters
[in,out]ctxThe build context to use during the operation.
[in,out]chfA populated compact heightfield.
[in]borderSizeThe size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]
[in]minRegionAreaThe minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx].
[in]mergeRegionAreaAny regions with a span count smaller than this value will, if possible, be merged with larger regions. [Limit: >=0] [Units: vx]
[in]chunkSizeSize of subregion [Units: vx]
Returns
True if the operation completed successfully.

◆ rcBuildRegionsMonotone()

bool rcBuildRegionsMonotone ( rcContext ctx,
rcCompactHeightfield chf,
const rcBorderSize  borderSize,
const int  minRegionArea,
const int  mergeRegionArea 
)

Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour. Contours will form simple polygons.

If multiple regions form an area that is smaller than minRegionArea, then all spans will be re-assigned to the zero (null) region.

Partitioning can result in smaller than necessary regions. mergeRegionArea helps reduce unecessarily small regions.

See the rcConfig documentation for more information on the configuration parameters.

The region data will be available via the rcCompactHeightfield::maxRegions and rcCompactSpan::reg fields.

Warning
The distance field must be created using rcBuildDistanceField before attempting to build regions.
See also
rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig

◆ rcGatherRegionsNoFilter()

bool rcGatherRegionsNoFilter ( rcContext ctx,
rcCompactHeightfield chf,
const rcBorderSize  borderSize,
unsigned short spanBuf4 
)

helper function from RecastRegion.cpp, requires distance data in compact height field

@UE: rcBuildRegions is now split into two functions: gathering regions and merging them it allows reusing existing code for building layer set (flood fill based partitioning)

spanBuf4 is temporary buffer, allocated and freed by caller (size = chf.spanCount * 4)