This is just the beginning of the process of fully building a compact heightfield. Various filters may be applied, then the distance field and regions built. E.g: rcBuildDistanceField and rcBuildRegions
334 const int w = hf.
width;
347 chf.
bmax[1] += walkableHeight*hf.
ch;
353 ctx->
log(
RC_LOG_ERROR,
"rcBuildCompactHeightfield: Out of memory 'chf.cells' (%d)", w*h);
360 ctx->
log(
RC_LOG_ERROR,
"rcBuildCompactHeightfield: Out of memory 'chf.spans' (%d)", spanCount);
367 ctx->
log(
RC_LOG_ERROR,
"rcBuildCompactHeightfield: Out of memory 'chf.areas' (%d)", spanCount);
376 for (
int y = 0;
y < h; ++
y)
378 for (
int x = 0;
x < w; ++
x)
390 const int bot = (int)s->
smax;
393 chf.
spans[idx].
h = (
unsigned char)
rcClamp(top - bot, 0, 0xff);
405 int tooHighNeighbour = 0;
406 for (
int y = 0;
y < h; ++
y)
408 for (
int x = 0;
x < w; ++
x)
415 for (
int dir = 0; dir < 4; ++dir)
421 if (nx < 0 || ny < 0 || nx >= w || ny >= h)
427 for (
int k = (
int)nc.
index, nk = (
int)(nc.
index+nc.
count); k < nk; ++k)
430 const int bot =
rcMax(s.
y, ns.
y);
431 const int top =
rcMin(s.
y+s.
h, ns.
y+ns.
h);
435 if ((top - bot) >= walkableHeight &&
rcAbs((
int)ns.
y - (
int)s.
y) <= walkableClimb)
438 const int lidx = k - (int)nc.
index;
439 if (lidx < 0 || lidx > MAX_LAYERS)
441 tooHighNeighbour =
rcMax(tooHighNeighbour, lidx);
454 if (tooHighNeighbour > MAX_LAYERS)
456 ctx->
log(
RC_LOG_ERROR,
"rcBuildCompactHeightfield: Heightfield has too many layers %d (max: %d)",
457 tooHighNeighbour, MAX_LAYERS);
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:308
#define rcAssert
Definition: RecastAssert.h:30
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:276
T rcAbs(T a)
Definition: Recast.h:577
unsigned short maxRegions
The maximum region id of any span within the field.
Definition: Recast.h:314
Represents a span of unobstructed space within a compact heightfield.
Definition: Recast.h:295
static const int RC_NOT_CONNECTED
Definition: Recast.h:547
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:281
unsigned char area
The area id assigned to the span.
Definition: Recast.h:260
rcCompactCell * cells
Array of cells. [Size: width*height].
Definition: Recast.h:319
int rcGetDirOffsetY(int dir)
Definition: Recast.h:1048
unsigned short y
The lower extent of the span. (Measured from the heightfield's base.)
Definition: Recast.h:297
rcCompactSpan * spans
Array of spans. [Size: spanCount].
Definition: Recast.h:320
T rcMin(T a, T b)
Definition: Recast.h:566
unsigned int h
The height of the span. (Measured from y.)
Definition: Recast.h:300
unsigned int index
Index to the first span in the column.
Definition: Recast.h:290
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:279
Provides information on the content of a cell column in a compact heightfield.
Definition: Recast.h:288
void rcSetCon(rcCompactSpan &s, int dir, int i)
Definition: Recast.h:1016
unsigned int count
Number of spans in the column.
Definition: Recast.h:291
An error log entry.
Definition: Recast.h:31
void * rcAlloc(int size, rcAllocHint hint)
Definition: RecastAlloc.cpp:44
int rcGetDirOffsetX(int dir)
Definition: Recast.h:1038
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:280
unsigned char * areas
Array containing area id data. [Size: spanCount].
Definition: Recast.h:322
G3D::int16 y
Definition: Vector2int16.h:38
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:316
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:307
The time to build the compact heightfield. (See: rcBuildCompactHeightfield)
Definition: Recast.h:45
unsigned int smin
The lower limit of the span. [Limit: < smax].
Definition: Recast.h:258
void rcVcopy(float *dest, const float *v)
Definition: Recast.h:677
void startTimer(const rcTimerLabel label)
Definition: Recast.h:131
int spanCount
The number of spans in the heightfield.
Definition: Recast.h:309
int walkableHeight
The walkable height used during the build of the field. (See: rcConfig::walkableHeight) ...
Definition: Recast.h:310
Memory will persist after a function call.
Definition: RecastAlloc.h:26
T rcClamp(T v, T mn, T mx)
Definition: Recast.h:589
unsigned int smax
The upper limit of the span. [Limit: <= RC_SPAN_MAX_HEIGHT].
Definition: Recast.h:259
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:317
rcSpan * next
The next span higher up in column.
Definition: Recast.h:261
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:278
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:318
static const unsigned char RC_NULL_AREA
Definition: Recast.h:538
T rcMax(T a, T b)
Definition: Recast.h:572
void log(const rcLogCategory category, const char *format,...)
Definition: Recast.cpp:55
G3D::int16 x
Definition: Vector2int16.h:37
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:277
void stopTimer(const rcTimerLabel label)
Definition: Recast.h:135
int walkableClimb
The walkable climb used during the build of the field. (See: rcConfig::walkableClimb) ...
Definition: Recast.h:311
#define MAX_HEIGHT
Definition: Map.h:247
rcSpan ** spans
Heightfield of spans (width*height).
Definition: Recast.h:282
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:315
int rcGetHeightFieldSpanCount(rcContext *ctx, rcHeightfield &hf)
Definition: Recast.cpp:297