Skip to main content

Module mesh

Module mesh 

Source
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 serialization
  • bvh — vertex welding, SAH/median BVH build, DFS triangle sort
  • create — create/destroy, edge identification, validation
  • factory — grid/wave/torus/box/hollow/platform helpers
  • cast — AABB, ray cast, shape cast
  • query — 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)
MeshData
Sorted triangle collision bounding volume hierarchy. (b3MeshData)
MeshDef
Data used to create a re-usable collision mesh. (b3MeshDef)
MeshNode
A mesh BVH node. (b3MeshNode)
MeshTriangle
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 b3MeshData header.
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 false to 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)