Expand description
Triangle mesh collision shape.
Port of box3d-cpp-reference/src/mesh.c and the mesh group of
include/box3d/types.h / collision.h.
Layout:
types— MeshDef/Data/Node/Triangle, edge flags, blob serializationbvh— vertex welding, SAH/median BVH build, DFS triangle sortcreate— create/destroy, edge identification, validationfactory— grid/wave/torus/box/hollow/platform helperscast— AABB, ray cast, shape castquery— overlap, query, mover collide, triangle accessor
Deferred: world shape attach.
SPDX-FileCopyrightText: 2026 Erin Catto SPDX-License-Identifier: MIT
Structs§
- Mesh
- Mesh data re-used with different scales. (b3Mesh)
- Mesh
Data - Sorted triangle collision bounding volume hierarchy. (b3MeshData)
- MeshDef
- Data used to create a re-usable collision mesh. (b3MeshDef)
- Mesh
Node - A mesh BVH node. (b3MeshNode)
- Mesh
Triangle - A mesh triangle. (b3MeshTriangle)
Constants§
- ALL_
CONCAVE_ EDGES - ALL_
FLAT_ EDGES - CONCAVE_
EDGE1 - Triangle mesh edge flags. (b3MeshEdgeFlags)
- CONCAVE_
EDGE2 - CONCAVE_
EDGE3 - FLAT_
EDGE1 - FLAT_
EDGE2 - FLAT_
EDGE3 - INVERSE_
CONCAVE_ EDGE1 - INVERSE_
CONCAVE_ EDGE2 - INVERSE_
CONCAVE_ EDGE3 - LEAF_
NODE - Leaf node type tag in the packed node bitfield. (B3_LEAF_NODE)
- MESH_
DATA_ SIZE - Size of the C
b3MeshDataheader. - MESH_
NODE_ SIZE - Size of the C
b3MeshNode. - MESH_
STACK_ SIZE - BVH traversal stack size. (B3_MESH_STACK_SIZE)
- MESH_
TRIANGLE_ SIZE - Size of the C
b3MeshTriangle. - MESH_
VERSION - 64-bit mesh version. (B3_MESH_VERSION)
Functions§
- collide_
mover_ and_ mesh - Collide a capsule mover against a mesh, writing contact planes. (b3CollideMoverAndMesh)
- compute_
mesh_ aabb - Compute the AABB of a mesh. (b3ComputeMeshAABB)
- convert_
bytes_ to_ mesh - Restore a mesh from a contiguous blob. (inverse of
MeshData::to_bytes) - create_
box_ mesh - Create a box mesh. (b3CreateBoxMesh)
- create_
grid_ mesh - Create a grid mesh along the x and z axes. (b3CreateGridMesh)
- create_
hollow_ box_ mesh - Create a hollow (inward-facing) box mesh. (b3CreateHollowBoxMesh)
- create_
mesh - Create a mesh from a definition. (b3CreateMesh)
- create_
platform_ mesh - Create a platform mesh (truncated pyramid). (b3CreatePlatformMesh)
- create_
torus_ mesh - Create a torus mesh. (b3CreateTorusMesh)
- create_
wave_ mesh - Create a wave mesh along the x and z axes. (b3CreateWaveMesh)
- destroy_
mesh - Destroy a mesh (no-op drop for owned Rust data). (b3DestroyMesh)
- get_
height - Height of the mesh BVH. (b3GetHeight)
- get_
mesh_ flags - Mesh triangle flags. (b3GetMeshFlags)
- get_
mesh_ material_ indices - Mesh material indices. (b3GetMeshMaterialIndices)
- get_
mesh_ nodes - Mesh nodes. (b3GetMeshNodes)
- get_
mesh_ triangle - Get a scaled mesh triangle with edge flags. (b3GetMeshTriangle)
- get_
mesh_ triangles - Mesh triangles. (b3GetMeshTriangles)
- get_
mesh_ vertices - Mesh vertices. (b3GetMeshVertices)
- is_
valid_ mesh - Validate mesh version and size. (b3IsValidMesh)
- overlap_
mesh - Test overlap between a mesh and a shape proxy. (b3OverlapMesh)
- query_
mesh - Query mesh triangles overlapping an AABB.
Callback receives (a, b, c, triangle_index) and may return
falseto stop early. (b3QueryMesh) - ray_
cast_ mesh - Ray cast versus a mesh in local space. (b3RayCastMesh)
- shape_
cast_ mesh - Shape cast versus a mesh in local space. (b3ShapeCastMesh)