natiny_physics_mesh

C
NatinyBody natiny_physics_mesh(NatinyMesh mesh);

Creates a static body whose collider is a mesh, triangle for triangle.

Parameters

Name Type Description
mesh NatinyMesh Mesh handle, from natiny_mesh_load or a generated shape

Returns

Type Description
NatinyBody Body handle, also usable as a NatinyEntity; 0 on failure

Example

C
NatinyMesh level = natiny_mesh_load(natiny_resource_load("level.glb"));
NatinyBody body  = natiny_physics_mesh(level);

Notes

  • Every mesh part contributes triangles to one collider.
  • The mesh is read once, here. Destroying or changing it afterwards leaves the collider as it was.
  • The body is static and starts at the world origin. Vertex positions are interpreted in the body's local space.
  • Returns 0 when physics is not running, the handle is not a mesh, or a collider cannot be built from its triangles.