ncollide

Travis.ci Status Crates.io Status License (3-Clause BSD)


2D and 3D collision detection library

… for the Rust programming language.


Complex shapes  
Geometric queries for collision detection available for 2D and 3D shapes with various levels of complexity: from simple spheres to arbitrary triangle meshes and unions of convex shapes.
Bounding volumes  
Bound complex shapes with simpler ones like AABB and bounding spheres. Perform approximate geometric queries efficiently to avoid useless exact computations.
Ray casting  
Compute intersections between a ray and any shape.
Point projection  
Test a point for containment, compute distances to a point, or project it on any shape.
Contact points  
Find the closest points between objects in close proximity. If they are penetrating, the minimal translational distance can be obtained as well!
Time-of-impact  
Compute the time it would take for two moving shapes to start being in contact.
Smallest distance  
Compute the global minimal distance between two shapes.
Spacial partitioning  
Efficient data structures to perform geometric queries efficiently on hundreds of objects.
Collision detection pipeline  
A complete and efficient collision detection pipeline including a broad phase and a narrow phase. Featuring real-time contacts generation, proximity events, ray-casting, and more, for scenes with hundreds of objects.
Mesh generation  
Generate triangle meshes from smooth objects, compute their convex hull, or decompose them approximately into their convex components.

Demonstrations§

nphysics − a 2D and 3D physics engine available on crates.io as the nphysics2d and nphysics3d crates. It completely relies on ncollide for contact points computation and proximity detection. It has at least one example per collision detection algorithm provided by ncollide.

kiss3d − a simplistic 3d graphics engine available on crates.io. It relies on mesh generation to render everything that is not triangular (sphere, cone, Bézier surfaces, etc.) In particular it has a demo that uses most mesh generation algorithms of ncollide. Every single 3d illustration of the Mesh generation section has been rendered by kiss3d.

Mesh generation rendered by kiss3d

nrays − a toy ray tracer in Rust. Obviously, it is used to stress-test the ray-casting capabilities of ncollide. Most 3d illustrations of this guide have been rendered by nrays.

Ray tracing demo