• Stars
    star
    1,624
  • Rank 28,812 (Top 0.6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

2 and 3-dimensional rigid body physics engine for Rust.

crates.io

crates.io (nphysics2d) crates.io (nphysics3d) Build status

Users guide | 2D Documentation | 3D Documentation | Forum

⚠️**This crate is now passively-maintained. It is being superseded by the Rapier project.**⚠️


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. Interactive 3D are available there. Because those demos are based on WASM and WebGl 1.0 they should work on most modern browsers. 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 features an efficient implementation of multibodies using the reduced-coordinates approach. Constraint-based joints are also supported.
  • It shows that there is no need to write two separate engines 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 sexiness.

Features

  • Static, dynamic, and kinematic rigid bodies.
  • Common convex primitives: box, ball, convex polyhedron.
  • Concave geometries built from convex primitives: compound geometries, triangle mesh, polylines.
  • Multibodies using reduced-coordinates approaches or constraints-based joints.
  • Multibody joint limits and motors.
  • Stable stacking due to non-linear a position-based penetration correction and one-shot contact manifold generation.
  • Island based sleeping (objects deactivation when they are at rest).
  • Ray casting.
  • Swept sphere based continuous collision detection.
  • Ball-in-socket joint.
  • FixedJoint joint.
  • Sensors.
  • Deformable bodies (aka. soft-bodies)
  • Kinematic bodies
  • WASM support

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

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:

  • kiss3d: the 3d graphics engine.

More Repositories

1

nalgebra

Linear algebra library for Rust.
Rust
3,909
star
2

rapier

2D and 3D physics engines focused on performance.
Rust
3,894
star
3

bevy_rapier

Official Rapier plugin for the Bevy game engine.
Rust
1,218
star
4

ncollide

2 and 3-dimensional collision detection library in Rust.
Rust
921
star
5

parry

2D and 3D collision-detection library for Rust.
Rust
554
star
6

salva

2 and 3-dimensional fluid simulation library in Rust.
Rust
503
star
7

rapier.js

Official JavaScript bindings for the Rapier physics engine.
TypeScript
410
star
8

simba

Set of mathematical traits to facilitate the use of SIMD-based AoSoA (Array of Struct of Array) storage pattern.
Rust
288
star
9

alga

Abstract algebra for Rust.
Rust
194
star
10

sparkl

MPM physics simulation in Rust
Rust
39
star
11

rapier.rs

Official website for the Rapier physics engine.
HTML
19
star
12

bevy_salva

Official Salva plugin for the Bevy game engine.
13
star
13

nalgebra.org

Source code for the website of the nalgebra project.
JavaScript
7
star
14

Steadyum

Physics Sandbox with Rapier
Rust
6
star
15

ncollide.org

Source code for the website of the ncollide project.
CSS
4
star
16

rustsim.org

Official website of the rustsim organization.
JavaScript
4
star
17

nphysics.org

Source code for the website of the nphysics project.
CSS
3
star
18

parry.rs

Official website for the Parry collision-detection library
JavaScript
3
star
19

salva.rs

Source code for the website of the Salva project.
CSS
3
star
20

dimforge-bench

Continuous benchmarking tools for the Dimorge projects.
Rust
2
star
21

distributed-physics-prototype

Experiments on distributed physics with Rapier
Rust
2
star
22

github-ci-secrets-test

1
star