Recast Navigation
Navigation-mesh Toolset for Games
rcHeightfield Struct Reference

A dynamic heightfield representing obstructed space. More...

#include <Recast.h>

Public Member Functions

 rcHeightfield ()
 
 ~rcHeightfield ()
 

Public Attributes

int width
 The width of the heightfield. (Along the x-axis in cell units.) More...
 
int height
 The height of the heightfield. (Along the z-axis in cell units.) More...
 
float bmin [3]
 The minimum bounds in world space. [(x, y, z)]. More...
 
float bmax [3]
 The maximum bounds in world space. [(x, y, z)]. More...
 
float cs
 The size of each cell. (On the xz-plane.) More...
 
float ch
 The height of each cell. (The minimum increment along the y-axis.) More...
 
rcSpan ** spans
 Heightfield of spans (width*height). More...
 
rcSpanPoolpools
 Linked list of span pools. More...
 
rcSpanfreelist
 The next free span. More...
 

Description

A dynamic heightfield representing obstructed space.

The grid of a heightfield is layed out on the xz-plane based on the value of cs. Spans exist within the grid columns with the span min/max values at increments of ch from the base of the grid. The smallest possible span size is (cs width) * (cs depth) * (ch height). (Which is a single voxel.)

The standard process for buidling a heightfield is to allocate it using rcAllocHeightfield, initialize it using rcCreateHeightfield, then add spans using the various helper functions such as rcRasterizeTriangle.

Building a heightfield is one of the first steps in creating a polygon mesh from source geometry. After it is populated, it is used to build a rcCompactHeightfield.

Example of iterating the spans in a heightfield:

// Where hf is a reference to an heightfield object.
const float* orig = hf.bmin;
const float cs = hf.cs;
const float ch = hf.ch;
const int w = hf.width;
const int h = hf.height;
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
// Deriving the minimum corner of the grid location.
float fx = orig[0] + x*cs;
float fz = orig[2] + y*cs;
// The base span in the column. (May be null.)
const rcSpan* s = hf.spans[x + y*w];
while (s)
{
// Detriving the minium and maximum world position of the span.
float fymin = orig[1]+s->smin*ch;
float fymax = orig[1] + s->smax*ch;
// Do other things with the span before moving up the column.
s = s->next;
}
}
}
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:322
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:321
Represents a span in a heightfield.
Definition: Recast.h:295
rcSpan * next
The next span higher up in column.
Definition: Recast.h:299
unsigned int smax
The upper limit of the span. [Limit: <= RC_SPAN_MAX_HEIGHT].
Definition: Recast.h:297
unsigned int smin
The lower limit of the span. [Limit: < smax].
Definition: Recast.h:296
See also
rcAllocHeightfield, rcFreeHeightField, rcCreateHeightfield

Constructor & Destructor Documentation

◆ rcHeightfield()

rcHeightfield::rcHeightfield ( )

◆ ~rcHeightfield()

rcHeightfield::~rcHeightfield ( )

Member Data Documentation

◆ bmax

float rcHeightfield::bmax[3]

The maximum bounds in world space. [(x, y, z)].

◆ bmin

float rcHeightfield::bmin[3]

The minimum bounds in world space. [(x, y, z)].

◆ ch

float rcHeightfield::ch

The height of each cell. (The minimum increment along the y-axis.)

◆ cs

float rcHeightfield::cs

The size of each cell. (On the xz-plane.)

◆ freelist

rcSpan* rcHeightfield::freelist

The next free span.

◆ height

int rcHeightfield::height

The height of the heightfield. (Along the z-axis in cell units.)

◆ pools

rcSpanPool* rcHeightfield::pools

Linked list of span pools.

◆ spans

rcSpan** rcHeightfield::spans

Heightfield of spans (width*height).

◆ width

int rcHeightfield::width

The width of the heightfield. (Along the x-axis in cell units.)


The documentation for this struct was generated from the following files: