Expand description
Original, dependency-free 2D/3D translational rigid-body physics.
The same fixed-step solver handles circles/spheres and axis-aligned boxes. This foundation deliberately does not claim a full rotational rigid-body or general-purpose dynamics API. See the crate README for numerical and feature limits.
use ferravex_dynamics::{BodyDesc, PhysicsWorld, Shape};
let mut world = PhysicsWorld::<3>::new([0., -9.81, 0.]);
world.insert(BodyDesc::fixed(Shape::cuboid([5., 0.5, 5.]), [0., -0.5, 0.])).unwrap();
let ball = world.insert(BodyDesc::dynamic(Shape::ball(0.5), [0., 3., 0.], 1.)).unwrap();
for _ in 0..240 { world.step(1. / 120.).unwrap(); }
assert!((world.body(ball).unwrap().position()[1] - 0.5).abs() < 0.02);Modules§
Structs§
- Body
- Body
Desc - Validated when inserted. One primitive collider belongs to each body.
- Body
Handle - Non-reusable identity: removing a body invalidates its handle immediately.
- Character
Motion - Character
Settings - A compact kinematic sphere controller, with positive Y as its up axis. The caller supplies displacement (including gravity) and owns velocity.
- Collision
Layers - Contact
- Contact
Event - Physics
World - Reuses bounded scratch buffers and returns an error rather than dropping overflowing collision pairs. Failed steps restore all body motion and forces. Buffers grow lazily to the configured bounds, then reuse their storage.
- Query
Filter - RayHit
- Step
Stats - World
Config