Rapier2d
Fast, cross-platform 2D physics engine for Rust games, animation, and robotics
Repository Health
Technical Analysis
Rapier2d is a high-performance 2D physics engine written in pure Rust by the Dimforge team. It provides rigid-body dynamics, collision detection, joints, and contact solving suitable for video games, animation, and robotics simulations.
Built on the parry collision library and nalgebra, Rapier2d supports cross-platform deterministic simulation, state snapshotting for networked and collaborative applications, optional SIMD acceleration, and parallel solving. It compiles to native targets as well as WebAssembly, and is forever free and open-source under the Apache-2.0 license.
What You Get
- A complete 2D rigid-body dynamics engine with a fast constraint solver
- Collision detection and contact generation powered by the parry library
- Impulse and multibody joints, sensors, and event/contact querying
- Deterministic cross-platform simulation with state snapshot and restore
Common Use Cases
- Adding realistic 2D physics to games and interactive experiences
- Driving procedural animation with rigid-body dynamics
- Simulating 2D robotics or mechanical systems
- Building networked or collaborative apps that need deterministic replay
Under The Hood
Architecture - Rapier2d is organized into dynamics, geometry, pipeline, control, counters, and data modules under src/, with the crate compiled in 2D/f32 mode via Cargo features (dim2, f32, std). The pipeline orchestrates broad-phase, narrow-phase, and the constraint solver over rigid bodies and colliders managed in arena-style sets.
Tech Stack - Pure Rust, #![no_std]-capable, layered on nalgebra for linear algebra, parry2d for collision, simba/num-traits for scalar abstraction, and optional rayon for parallelism plus wide for SIMD. Distributed as the rapier2d crate within the dimforge/rapier Cargo workspace.
Code Quality - The codebase enforces #![warn(missing_docs)] and deny(bare_trait_objects), has extensive examples in examples2d/, a dedicated testbed, and CI checks; the project documents its human-reviewed AI-assisted contribution policy.
API Design - The public API exposes ergonomic builder-style types (RigidBodyBuilder, ColliderBuilder) and a PhysicsPipeline::step entry point, backed by thorough user guides at rapier.rs, though the breadth of physics concepts gives it a moderate learning curve.