Crate nphysics2d

Source
Expand description

§nphysics

nphysics is a 2 and 3-dimensional physics engine for games and animations. It uses ncollide for collision detection, and nalgebra for vector/matrix math. 2D and 3D implementations both share the same code!

Examples are available in the examples2d and examples3d directories. There is also a short (outdated) demonstration video. An on-line version of this documentation is available here. Feel free to ask for help and discuss features on the official user forum.

§Why another physics engine?

There are a lot of physics engine out there. However having a physics engine written in Rust is much more fun than writing bindings and has several advantages:

  • it shows that Rust is suitable for soft real-time applications
  • it shows how well Rust behaves with highly generic code
  • it shows that there is no need to write two separate engine for 2D and 3D: genericity wrt the dimension is possible (modulo low level arithmetic specializations for each dimension).
  • in a not-that-near future, C++ will die of ugliness. Then, people will search for a physics engine and nphysics will be there, proudly exhibiting its Rusty sexyness.

§Features

  • Static and dynamic rigid bodies.
  • Common convex primitives: cone, box, ball, cylinder.
  • Concave geometries build from convex primitives (aka. compound geometries).
  • Stable stacking.
  • Island based sleeping (objects deactivation).
  • Ray casting.
  • Swept sphere based continuous collision detection.
  • Ball-in-socket joint.
  • FixedJoint joint.
  • Sensors.
  • Deformable bodies (aka. soft-bodies)
  • Kinematic bodies

§What is missing?

nphysics is a very young library and needs to learn a lot of things to become a grown up. Many missing features are because of missing features on ncollide. Features missing from nphysics itself include:

  • more joints, joint limits, joint motors and breakable joints.
  • parallel pipeline
  • GPU-based pipeline

§Dependencies

All dependencies are automatically cloned with a recursive clone. The libraries needed to compile the physics engine are:

  • ncollide: the collision detection library.
  • nalgebra: the linear algebra library.

The libraries needed to compile the examples are:

Re-exports§

pub use nalgebra;
pub use ncollide2d;
pub use simba;

Modules§

algebra
Dynamics-specific algebraic entities: velocity, forces, and inertias.
counters
Counters for benchmarking various parts of the physics engine.
detection
Collision detection information.
force_generator
Persistent force generation.
joint
Joints using the reduced-coordinates formalism or using constraints.
material
Material data structures.
math
Compilation flags dependent aliases for mathematical types.
object
Objects that may be added to the physical world.
solver
Constraint solver.
utils
Miscellaneous utilities.
volumetric
Volume and inertia tensor computation.
world
The physics world.