Skip to main content

Module collision

Module collision 

Source
Expand description

Collision detection primitives: GJK/EPA narrowphase, SAT, sphere/capsule tests, BVH broadphase, and contact manifold generation.

All geometry is represented with [f64; 3] arrays to avoid nalgebra dependencies inside this module.

Structs§

AabbRaw
Axis-aligned bounding box, stored as (min, max).
Box3
An axis-aligned box centred at center with half_extents.
Bvh
A simple axis-aligned BVH built with a median-split strategy.
BvhLeaf
A leaf entry in the BVH.
Capsule
A capsule: the Minkowski sum of a line segment and a sphere.
Contact
A collision contact point.
ContactManifold
A contact manifold: up to 4 persistent contact points between two bodies.
ConvexPointCloud
A convex shape defined by a set of points.
EpaResult
Result of an EPA penetration-depth query.
GjkResult
Result of a GJK query.
Obb
An oriented bounding box.
RayAabbHit
Result of a ray–AABB intersection test.
Sphere
A sphere centred at center with radius.
SphereSphereContact
Result of a sphere–sphere intersection test.
Triangle
A triangle as a convex shape (degenerate 2-D polyhedron).

Traits§

ConvexShape
Trait for convex shapes defined by a support function.

Functions§

epa
Run EPA to compute the penetration depth between two overlapping convex shapes.
gjk
Run the GJK algorithm to determine if two convex shapes intersect and, if not, compute their minimum distance.
minkowski_sum_support
Support function of the Minkowski sum of two shapes.
obb_obb_sat
Test two OBBs using the Separating Axis Theorem. Returns None if separated, or Some(depth, axis) with penetration info.
point_segment_closest
Signed distance from point p to the line segment (a→b), and the closest point on the segment.
ray_aabb
Intersect a ray (origin, dir) with an AABB.
ray_sphere
Intersect a ray with a sphere. Returns parameter t at first hit or None.
shape_cast_sphere_vs_aabb
Cast a sphere along velocity against an AABB. Returns t ∈ [0, max_t] or None.
shape_cast_sphere_vs_sphere
Cast a moving sphere along velocity direction (magnitude = max travel distance) against a static sphere. Returns the first time of contact t ∈ [0, max_t] or None if no contact.
sphere_capsule
Test a sphere and capsule for intersection. Returns (overlapping, depth, normal, point).
sphere_sphere
Test two spheres for intersection and compute the contact manifold.