Compound collision shape. More...

Data Structures | |
| struct | b3CompoundCapsuleDef |
| Definition for a capsule in a compound shape. More... | |
| struct | b3CompoundHullDef |
| Definition for a convex hull in a compound shape. More... | |
| struct | b3CompoundMeshDef |
| Definition for a triangle mesh in a compound shape. More... | |
| struct | b3CompoundSphereDef |
| Definition for a sphere in a compound shape. More... | |
| struct | b3CompoundDef |
| Definition for creating a compound shape. More... | |
| struct | b3CompoundData |
| The runtime data for a compound shape. More... | |
| struct | b3CompoundCapsule |
| A capsule that lives in a compound. More... | |
| struct | b3CompoundHull |
| A hull that lives in a compound. More... | |
| struct | b3CompoundMesh |
| A mesh with non-uniform scale that lives in a compound. More... | |
| struct | b3CompoundSphere |
| A sphere that lives in a compound. More... | |
| struct | b3ChildShape |
| Child shape of a compound. More... | |
| union | b3ChildShape.__unnamed0__ |
| Tagged union. More... | |
Macros | |
| #define | B3_COMPOUND_VERSION ( 0x830778DB07086EB4ull ^ B3_DYNAMIC_TREE_VERSION ^ B3_MESH_VERSION ^ B3_HULL_VERSION ) |
| The compound version depends on the tree, mesh, and hull versions. | |
| #define | B3_MAX_COMPOUND_MESH_MATERIALS 4 |
| Meshes used in compounds have limited space for materials. | |
Typedefs | |
| typedef bool | b3CompoundQueryFcn(const b3CompoundData *compound, int childIndex, void *context) |
| Callback for compound overlap queries. | |
Functions | |
| b3ChildShape | b3GetCompoundChild (const b3CompoundData *compound, int childIndex) |
| Get a child shape of a compound. | |
| void | b3QueryCompound (const b3CompoundData *compound, b3AABB aabb, b3CompoundQueryFcn *fcn, void *context) |
| Query a compound shape for children that overlap an AABB. | |
| b3CompoundCapsule | b3GetCompoundCapsule (const b3CompoundData *compound, int index) |
| Access a child capsule by index. | |
| b3CompoundHull | b3GetCompoundHull (const b3CompoundData *compound, int index) |
| Access a child hull by index. | |
| b3CompoundMesh | b3GetCompoundMesh (const b3CompoundData *compound, int index) |
| Access a child mesh by index. | |
| b3CompoundSphere | b3GetCompoundSphere (const b3CompoundData *compound, int index) |
| Access a child sphere by index. | |
| const b3SurfaceMaterial * | b3GetCompoundMaterials (const b3CompoundData *compound) |
| Access the compound material array. | |
| b3CompoundData * | b3CreateCompound (const b3CompoundDef *def) |
| Create a compound shape. All input data in the definition is cloned into the resulting compound. | |
| void | b3DestroyCompound (b3CompoundData *compound) |
| Destroy a compound shape. | |
| uint8_t * | b3ConvertCompoundToBytes (b3CompoundData *compound) |
| If bytes is null then this returns the number of required bytes. | |
| b3CompoundData * | b3ConvertBytesToCompound (uint8_t *bytes, int byteCount) |
| Convert bytes to compound. | |
Compound collision shape.
| struct b3CompoundCapsuleDef |
Definition for a capsule in a compound shape.

| Data Fields | ||
|---|---|---|
| b3Capsule | capsule | Local capsule. |
| b3SurfaceMaterial | material | Material properties. |
| struct b3CompoundHullDef |
Definition for a convex hull in a compound shape.

| Data Fields | ||
|---|---|---|
| const b3HullData * | hull | Shared hull. |
| b3SurfaceMaterial | material | Material properties. |
| b3Transform | transform | Transform of the shared hull into compound local space. |
| struct b3CompoundMeshDef |
Definition for a triangle mesh in a compound shape.

| Data Fields | ||
|---|---|---|
| int | materialCount | Number of materials. |
| const b3SurfaceMaterial * | materials |
Material properties. This array must line up with the material indices on the triangles. |
| const b3MeshData * | meshData | Shared mesh. |
| b3Vec3 | scale | Local space non-uniform mesh scale. May have negative components. |
| b3Transform | transform | Transform of the shared mesh into compound local space. |
| struct b3CompoundSphereDef |
Definition for a sphere in a compound shape.

| Data Fields | ||
|---|---|---|
| b3SurfaceMaterial | material | Material properties. |
| b3Sphere | sphere | Local sphere. |
| struct b3CompoundDef |
Definition for creating a compound shape.
All this data is fully cloned into the run-time compound shape.

| Data Fields | ||
|---|---|---|
| int | capsuleCount | Number of capsules. |
| b3CompoundCapsuleDef * | capsules | Capsule instances. |
| int | hullCount | Number of hull instances. |
| b3CompoundHullDef * | hulls | Hulls instances. |
| int | meshCount | Number of mesh instances. |
| b3CompoundMeshDef * | meshes | Mesh instances. |
| int | sphereCount | Number of spheres. |
| b3CompoundSphereDef * | spheres | Sphere instances. |
| struct b3CompoundData |
The runtime data for a compound shape.
This is a potentially large yet highly optimized data structure. It can contain thousands of child shapes, yet at runtime it populates into the world as a single shape in the runtime broad-phase. This data structure has data living off the end and must be accessed using offsets. Accessors are provided for user relevant data.

| Data Fields | ||
|---|---|---|
| int | byteCount | The total number of bytes for this compound. |
| int | capsuleCount | The number of capsules. |
| int | capsuleOffset | Offset of the capsule array in bytes from the struct address. |
| int | hullCount | The number of hull instances. |
| int | hullOffset | Offset of the hull instance array in bytes from the struct address. |
| int | materialCount | The number of materials. |
| int | materialOffset | Offset of the material array in bytes from the struct address. |
| int | meshCount | The number of mesh instances. |
| int | meshOffset | Offset of the mesh instance array in bytes from the struct address. |
| int | nodeOffset | Offset of the tree node array in bytes from the struct address. |
| int | sharedHullCount | The number of unique hulls. Diagnostic. |
| int | sharedMeshCount | The number of unique meshes. Diagnostic. |
| int | sphereCount | The number of spheres. |
| int | sphereOffset | Offset of the sphere array in bytes from the struct address. |
| b3DynamicTree | tree | Immutable dynamic tree. The tree node pointer must be fixed up using the node offset. |
| uint64_t | version | The compound version is always first. |
| struct b3CompoundCapsule |
| struct b3CompoundHull |
A hull that lives in a compound.

| Data Fields | ||
|---|---|---|
| const b3HullData * | hull | Pointer to the unique shared hull. |
| int | materialIndex | Index to a shared material. |
| b3Transform | transform | The transform of this hull instance. |
| struct b3CompoundMesh |
A mesh with non-uniform scale that lives in a compound.

| Data Fields | ||
|---|---|---|
| int | materialIndices[B3_MAX_COMPOUND_MESH_MATERIALS] |
This is used to access the surface material from b3GetCompoundMaterials. Requires an extra level of indirection. The triangle material index is clamped to B3_MAX_COMPOUND_MESH_MATERIALS. materialIndex = materialIndices[triangle->materialIndex] |
| const b3MeshData * | meshData | Pointer to the unique shared mesh. |
| b3Vec3 | scale | Non-uniform scale of this mesh instance. |
| b3Transform | transform | The transform of this mesh instance. |
| struct b3CompoundSphere |
| union b3ChildShape.__unnamed0__ |
Tagged union.
| Data Fields | ||
|---|---|---|
| b3Capsule | capsule | Capsule. |
| const b3HullData * | hull | Hull. |
| b3Mesh | mesh | Mesh. |
| b3Sphere | sphere | Sphere. |
| #define B3_MAX_COMPOUND_MESH_MATERIALS 4 |
Meshes used in compounds have limited space for materials.
If you have a mesh with many materials, you can use it outside of the compound.
| b3CompoundData * b3ConvertBytesToCompound | ( | uint8_t * | bytes, |
| int | byteCount ) |
Convert bytes to compound.
This does not clone. The bytes must remain in scope while the compound is used. This is done to improve run-time performance and allow for instancing. The bytes are mutated to fixup pointers.
| uint8_t * b3ConvertCompoundToBytes | ( | b3CompoundData * | compound | ) |
If bytes is null then this returns the number of required bytes.
This clones all the data into the bytes buffer. This is expected to run offline or asynchronously. This mutates the compound to nullify pointers, leaving the compound in an unusable state.