Skip to main content

Module shape

Module shape 

Source
Expand description

Collision shapes attached to bodies (sphere, capsule, hull, mesh, …).

Create shapes with create_sphere_shape, create_capsule_shape, create_hull_shape, and the mesh/height-field/compound helpers, using a crate::types::ShapeDef from crate::types::default_shape_def. Geometry primitives live in crate::geometry and crate::hull.

Port of shape.h / shape.c. This file holds the data model and filter predicates; create/destroy and mutators are re-exported from submodules.

SPDX-FileCopyrightText: 2025 Erin Catto SPDX-License-Identifier: MIT

Modules§

shape_flags
Shape flag bits. (enum b3ShapeFlags)

Structs§

Shape
Internal shape. (b3Shape)

Enums§

ShapeGeometry
Concrete shape geometry. Maps to C’s type tag + anonymous union.

Functions§

collide_mover
Collide a capsule mover with a shape, writing contact planes into planes. Transforms the mover into local space, dispatches, then rotates results back. (b3CollideMover)
compute_fat_shape_aabb
(b3ComputeFatShapeAABB)
compute_shape_aabb
(b3ComputeShapeAABB)
compute_shape_extent
(b3ComputeShapeExtent)
compute_shape_mass
(b3ComputeShapeMass)
compute_swept_shape_aabb
Swept AABB of a convex shape along a sweep at time in [0, 1]. (b3ComputeSweptShapeAABB)
create_capsule_shape
(b3CreateCapsuleShape)
create_compound_shape
(b3CreateCompoundShape)
create_height_field_shape
(b3CreateHeightFieldShape)
create_hull_shape
(b3CreateHullShape)
create_mesh_shape
(b3CreateMeshShape)
create_shape_proxy
(b3CreateShapeProxy)
create_sphere_shape
(b3CreateSphereShape)
destroy_shape
Destroy a shape. (b3DestroyShape)
destroy_shape_proxy
(b3DestroyShapeProxy)
get_shape
Resolve a ShapeId to the shape index. (b3GetShape)
get_shape_centroid
(b3GetShapeCentroid)
get_shape_projected_area
Projected area of a shape onto a plane with the given normal. Used by explosions. (b3GetShapeProjectedArea)
make_shape_proxy
Convex shape proxy for distance / TOI. Mesh, height, and compound need their own query paths. (b3MakeShapeProxy)
mesh_geometry
Convenience: unit-scale mesh geometry. (b3Mesh with identity scale)
overlap_shape
Test overlap between a shape and a shape proxy. (b3OverlapShape)
ray_cast_shape
Ray cast a shape in world (or relative) space. Transforms the ray into local space, dispatches, then transforms the hit back. (b3RayCastShape)
shape_apply_wind
Apply a wind force to the body for this shape using the density of air. (b3Shape_ApplyWind)
shape_are_contact_events_enabled
(b3Shape_AreContactEventsEnabled)
shape_are_hit_events_enabled
(b3Shape_AreHitEventsEnabled)
shape_are_pre_solve_events_enabled
(b3Shape_ArePreSolveEventsEnabled)
shape_are_sensor_events_enabled
(b3Shape_AreSensorEventsEnabled)
shape_cast_shape
Shape cast a shape in world (or relative) space. (b3ShapeCastShape)
shape_compute_mass_data
Compute the mass data for a shape. (b3Shape_ComputeMassData)
shape_enable_contact_events
(b3Shape_EnableContactEvents)
shape_enable_hit_events
(b3Shape_EnableHitEvents)
shape_enable_pre_solve_events
(b3Shape_EnablePreSolveEvents)
shape_enable_sensor_events
(b3Shape_EnableSensorEvents)
shape_get_aabb
(b3Shape_GetAABB)
shape_get_body
(b3Shape_GetBody)
shape_get_capsule
(b3Shape_GetCapsule)
shape_get_closest_point
Closest point on a shape to a target in the query frame. (b3Shape_GetClosestPoint)
shape_get_contact_capacity
Conservative contact capacity for a non-sensor shape. (b3Shape_GetContactCapacity)
shape_get_contact_data
Touching contact data involving this shape. (b3Shape_GetContactData)
shape_get_density
(b3Shape_GetDensity)
shape_get_filter
(b3Shape_GetFilter)
shape_get_friction
(b3Shape_GetFriction)
shape_get_hull
(b3Shape_GetHull) — returns None for non-hull shapes.
shape_get_mesh_material_count
(b3Shape_GetMeshMaterialCount)
shape_get_mesh_surface_material
(b3Shape_GetMeshSurfaceMaterial)
shape_get_name
(b3Shape_GetName)
shape_get_restitution
(b3Shape_GetRestitution)
shape_get_sensor_capacity
Capacity required for shape_get_sensor_data / sensor overlaps. Returns 0 if the shape is not a sensor. (b3Shape_GetSensorCapacity)
shape_get_sensor_data
Overlapped shapes for a sensor. Overlaps may contain destroyed shapes — use super::shape_is_valid to confirm each. (b3Shape_GetSensorData; docs also call this GetSensorOverlaps)
shape_get_sensor_overlaps
Alias for shape_get_sensor_data matching the header doc name b3Shape_GetSensorOverlaps.
shape_get_sphere
(b3Shape_GetSphere)
shape_get_surface_material
(b3Shape_GetSurfaceMaterial)
shape_get_type
(b3Shape_GetType)
shape_get_user_data
(b3Shape_GetUserData)
shape_get_world
(b3Shape_GetWorld)
shape_is_sensor
(b3Shape_IsSensor)
shape_is_valid
Shape identifier validation. (b3Shape_IsValid)
shape_ray_cast
World-space ray cast against a single shape. (b3Shape_RayCast)
shape_set_capsule
(b3Shape_SetCapsule)
shape_set_density
(b3Shape_SetDensity)
shape_set_filter
(b3Shape_SetFilter)
shape_set_friction
(b3Shape_SetFriction)
shape_set_hull
(b3Shape_SetHull)
shape_set_mesh
(b3Shape_SetMesh)
shape_set_mesh_material
(b3Shape_SetMeshMaterial)
shape_set_name
Set the shape name (truncated to SHAPE_NAME_LENGTH). Uses the world name cache rather than C’s fixed char buffer. (b3Shape_SetName)
shape_set_restitution
(b3Shape_SetRestitution)
shape_set_sphere
(b3Shape_SetSphere)
shape_set_surface_material
(b3Shape_SetSurfaceMaterial)
shape_set_user_data
(b3Shape_SetUserData) — Rust stores u64 instead of void*.
shape_time_of_impact
Time of impact between two shapes along sweeps. Convex vs convex uses GJK TOI; mesh/height/compound use triangle/child queries. (b3ShapeTimeOfImpact)
should_query_collide
(static inline b3ShouldQueryCollide)
should_shapes_collide
(static inline b3ShouldShapesCollide)