collide-mesh
Triangle mesh collision for character controllers: capsule-vs-mesh resolution with ground classification, plus raycasts. Built for walkable level geometry loaded from triangle meshes (glTF and similar).
Unlike the rest of the collide ecosystem, this crate is deliberately 3D-only and uses ga3::Vector<f32> directly: triangle meshes have no meaningful N-dimensional generalization, and Y-up ground semantics (walkable slopes, ground height) are inherently 3D gameplay concepts. The dimension-generic core traits of collide remain untouched by this exception.
Features
TriangleMesh: built from raw vertex positions and indices; degenerate triangles are skipped; per-face normals; automatic BVH above 16 triangles.CollisionWorld: a set of meshes behind a second BVH level.collide_capsuleresolves a vertical capsule against all meshes and reports ground contact (walkable if the face normal's Y exceeds 0.5), the supporting ground height and normal, and an accumulated push vector out of steep geometry.raycastreturns the closest hit distance.- Robust against degenerate input: zero-area triangles, broken indices and zero-length segments are tolerated.
Usage
use Capsule;
use Ray;
use ;
use Vector;
let mesh = from_vertices;
let world = new;
let result = world.collide_capsule;
if result.grounded
let hit = world.raycast;
The capsule is assumed to be vertical (a character controller). velocity_y distinguishes landing on ground from passing it while moving upward.
Future work
- Implementing
collide::Collider<Capsule>for plain penetration info (the rich ground classification does not map ontoCollisionInfo's contact-point semantics, so the dedicated API stays primary). - Moving platforms and per-triangle surface attributes.