About this project

BepuPhysics for Rust is a line-by-line translation of BepuPhysics v2, described by its author as an extremely high performance physics engine originally written in C#. The port keeps the original's emphasis on SIMD-optimized collision detection and constraint solving, adds lock-free task scheduling with automatic work distribution for multithreading, and provides optional integration with the Bevy game engine. Spatial query support includes filtered ray casts and shape sweeps. Build requirements are notable: the crate needs Rust nightly 1.95.0 or newer because it uses the portable_simd and generic_const_exprs features, and it targets macOS (NEON SIMD) or x86_64 (SSE/AVX2). Installation is a normal Cargo dependency, with a bevy feature flag enabling the plugin. The Bevy path is presented as the simplest way to get started. A BepuPhysicsPlugin is added alongside the default plugins, gravity is inserted as a resource, and bodies are spawned with components: RigidBody variants for Dynamic, Static and Kinematic bodies; colliders for spheres, cuboids, capsules and cylinders; and material properties for mass, friction, restitution and linear or angular damping. Velocity components sync bidirectionally with the simulation. Additional tuning components cover locked rotation about body-local axes (including an UPRIGHT preset that frees yaw, and an ALL preset), speculative margins controlling how far ahead of a surface contacts are created, sleep thresholds, and query layer masks used only for filtering spatial queries rather than collision response. Resources include Gravity and a BepuConfig for timestep, substeps, thread count and determinism, the latter intended for replay or networking scenarios. Spatial queries are exposed through a BepuSpatialQuery system parameter that borrows the simulation in shared mode, so several query systems can run in parallel, with scratch memory allocated per system. Queries should be scheduled outside the physics step set. The API covers closest-hit and all-hit ray casts plus shape sweeps, with a QueryFilter supporting entity exclusion, layer masks, and statics-only or bodies-only restrictions. The README singles out a SweepResult::StartPenetrating variant for sweeps that begin already in contact: because no time of impact, contact point or normal is defined in that case, the port keeps it separate from a miss or a hit so callers must decide how to handle it. Entity resolution is documented as branching on collidable mobility before using a handle, since body and static handles with the same raw value refer to unrelated objects. The repository ships Bevy examples such as rain, tower and hello_physics, and stresses that they must be run in release mode because debug builds are 10 to 100 times slower without SIMD optimizations. Comparison benchmarks live in a separate bepu-benchmarks workspace member so their heavy, platform-specific dependencies stay out of the library; these include an Avian comparison and, behind an optional csharp feature, the same scene run against the original C# BepuPhysics through FFI. That feature is kept optional because its native dependency fails to link on MSVC. The project is licensed under Apache 2.0, matching the original BepuPhysics v2, and credits Ross Nordby as the original author, with the Bevy wrapper described as inspired by the Avian physics engine's design.