Skip to main content

Module geometry

Module geometry 

Source
Expand description

Shape geometry queries: sphere, capsule, and hull mass/AABB/overlap/cast.

Port of box3d-cpp-reference/src/sphere.c, capsule.c, and the query APIs at the end of hull.c. Types come from include/box3d/types.h.

Layout (mirrors box2d-rust geometry/):

  • types.rs — MassData, Sphere, Capsule, RayCastInput, ShapeCastInput
  • sphere.rs — sphere mass, AABB, overlap, ray/shape cast
  • capsule.rs — capsule mass, AABB, overlap, ray/shape cast

Hull queries live in [crate::hull::queries] and are re-exported here.

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

Re-exports§

pub use crate::distance::CastOutput;
pub use crate::hull::collide_mover_and_hull;
pub use crate::hull::compute_hull_aabb;
pub use crate::hull::compute_hull_mass;
pub use crate::hull::compute_swept_hull_aabb;
pub use crate::hull::overlap_hull;
pub use crate::hull::ray_cast_hull;
pub use crate::hull::shape_cast_hull;

Structs§

Capsule
A solid capsule can be viewed as two hemispheres connected by a cylinder. (b3Capsule)
CollisionPlane
Collision planes that can be fed to crate::mover::solve_planes. Normally assembled by the user from PlaneResult values. (b3CollisionPlane)
MassData
This holds the mass data computed for a shape. (b3MassData)
PlaneResult
The plane between a character mover and a shape. (b3PlaneResult)
PlaneSolverResult
Result returned by crate::mover::solve_planes. (b3PlaneSolverResult)
RayCastInput
Low level ray cast input data. (b3RayCastInput)
ShapeCastInput
Low level shape cast input in generic form. This allows casting an arbitrary point cloud wrapped with a radius. For example, a sphere is a single point with a non-zero radius. A capsule is two points with a non-zero radius. A box is eight points with a zero radius. (b3ShapeCastInput)
ShapeExtent
Minimum and maximum extent of a shape relative to a local origin. (math_internal.h: b3ShapeExtent)
Sphere
A solid sphere. (b3Sphere)
SurfaceMaterial
Material properties supported per triangle on meshes and height fields. (b3SurfaceMaterial)

Enums§

ShapeType
Shape type. (b3ShapeType)

Constants§

SURFACE_MATERIAL_SIZE
Size of C b3SurfaceMaterial including trailing padding to 8-byte alignment.

Functions§

collide_mover_and_capsule
Collide a capsule mover against a capsule. (b3CollideMoverAndCapsule)
collide_mover_and_sphere
Collide a capsule mover against a sphere. (b3CollideMoverAndSphere)
compute_capsule_aabb
Compute the AABB of a capsule. (b3ComputeCapsuleAABB)
compute_capsule_mass
Compute mass properties of a capsule. (b3ComputeCapsuleMass)
compute_sphere_aabb
Compute the AABB of a sphere. (b3ComputeSphereAABB)
compute_sphere_mass
Compute mass properties of a sphere. (b3ComputeSphereMass)
compute_swept_capsule_aabb
Compute the swept AABB of a capsule between two transforms. (b3ComputeSweptCapsuleAABB)
compute_swept_sphere_aabb
Compute the swept AABB of a sphere between two transforms. (b3ComputeSweptSphereAABB)
default_surface_material
Use this to initialize your surface material. (b3DefaultSurfaceMaterial)
is_valid_ray
Validate ray cast input data (NaN, etc). (b3IsValidRay)
overlap_capsule
Test overlap between a capsule and a shape proxy. (b3OverlapCapsule)
overlap_sphere
Test overlap between a sphere and a shape proxy. (b3OverlapSphere)
ray_cast_capsule
Ray cast versus capsule shape in local space. (b3RayCastCapsule)
ray_cast_hollow_sphere
Ray cast versus a hollow sphere (interior hits allowed). (b3RayCastHollowSphere)
ray_cast_sphere
Ray cast versus sphere shape in local space. (b3RayCastSphere)
shape_cast_capsule
Shape cast versus a capsule. (b3ShapeCastCapsule)
shape_cast_sphere
Shape cast versus a sphere. (b3ShapeCastSphere)