Box3D 0.1.0
A 3D physics engine for games
Loading...
Searching...
No Matches

Height field collision shape. More...

Collaboration diagram for Height Field:

Data Structures

struct  b3HeightFieldDef
 Data used to create a height field. More...
struct  b3HeightFieldData
 A height field with compressed storage. More...

Macros

#define B3_HEIGHT_FIELD_HOLE   0xFF
 This material index is used to designate holes in a height field.
#define B3_HEIGHT_FIELD_VERSION   0x8B18CBD138A6BC84ull
 64-bit height-field version. Useful for validating serialized data.

Functions

const uint16_t * b3GetHeightFieldCompressedHeights (const b3HeightFieldData *hf)
 Get read only compressed heights. One uint16_t per grid point.
const uint8_t * b3GetHeightFieldMaterialIndices (const b3HeightFieldData *hf)
 Get read only material indices. One uint8_t per cell.
const uint8_t * b3GetHeightFieldFlags (const b3HeightFieldData *hf)
 Get read only triangle flags. One uint8_t per triangle.
b3HeightFieldDatab3CreateHeightField (const b3HeightFieldDef *data)
 Create a generic height field.
b3HeightFieldDatab3CreateGrid (int rowCount, int columnCount, b3Vec3 scale, bool makeHoles)
 Create a grid as a height field.
b3HeightFieldDatab3CreateWave (int rowCount, int columnCount, b3Vec3 scale, float rowFrequency, float columnFrequency, bool makeHoles)
 Create a wave grid as a height field.
void b3DestroyHeightField (b3HeightFieldData *heightField)
 Destroy a height field.
void b3DumpHeightData (const b3HeightFieldDef *data, const char *fileName)
 Save input height data to a file.
b3HeightFieldDatab3LoadHeightField (const char *fileName)
 Create a height field by loading a previously saved height data.

Detailed Description

Height field collision shape.


Data Structure Documentation

◆ b3HeightFieldDef

struct b3HeightFieldDef

Data used to create a height field.

Collaboration diagram for b3HeightFieldDef:
Data Fields
bool clockwiseWinding Use clock-wise winding. This effectively inverts the height-field along the y-axis.
int countX The number of grid lines along the x-axis.
int countZ The number of grid lines along the z-axis.
float globalMaximumHeight The maximum.
float globalMinimumHeight Global minimum and maximum heights used for quantization.

This is important if you want height fields to be placed next to each other and line up exactly. In that case, both height fields should use the same minimum and maximum heights. All height values are clamped to this range. These values are in unscaled space.

float * heights Grid point heights count = countX * countZ.
uint8_t * materialIndices Grid cell material A value of 0xFF is reserved for holes count = (countX - 1) * (countZ - 1).
b3Vec3 scale The height field scale. All components must be positive values.

◆ b3HeightFieldData

struct b3HeightFieldData

A height field with compressed storage.

Note
This data structure has data hanging off the end and cannot be directly copied.
Collaboration diagram for b3HeightFieldData:
Data Fields
b3AABB aabb The local axis-aligned bounding box.
int byteCount The total number of bytes for this height field.
bool clockwise Triangle winding.
int columnCount The number of grid columns along the local x-axis.
int flagsOffset Offset of the flag array in bytes from the struct address.

uint8_t, one per triangle.

uint32_t hash Hash of this height field (this field is zero when the hash is computed).
float heightScale The quantization scale.
int heightsOffset Offset of the compressed height array in bytes from the struct address.

uint16_t, one per grid point.

int materialOffset Offset of the material index array in bytes from the struct address.

uint8_t, one per cell.

float maxHeight The maximum y value.
float minHeight The minimum y value.
uint8_t padding[3] Explicit padding.

Identity is a content hash over raw bytes, so there must be no unnamed padding for struct copies to scramble.

int rowCount The number of grid rows along the local z-axis.
b3Vec3 scale The overall scale.
uint64_t version Version must be first and match B3_HEIGHT_FIELD_VERSION.