mxnemu / nphysics

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nphysics Build Status

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.

Its most distinctive feature is its genericity wrt the simulation dimension. That means you can use it for both 2-dimensional physics and 3-dimensional physics. Higher dimensions could be possible, but nphysics has not be written/tested with those in thought.

Examples are available on the examples directory. There is also a short (outdated) demonstration video.

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.

Compilation

You will need the last rust compiler from the master branch. If you encounter problems, make sure you have the last version before creating an issue.

The simplest way to build nphysics and all its dependencies is to do a recursive clone:

git clone --recursive git://github.com/sebcrozet/nphysics.git
cd nphysics
make deps
make

To build the examples to the bin folder:

make examples_deps
make examples

Use ./your_favorite_example_here --help to see all the cool stuffs you can do.

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
  • fixed joint

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:

  • kinematic bodies
  • efficient signaling system
  • more joints, joint limits, joint motors and breakable joints.
  • soft-bodies (see https://github.com/natal/roft for a draft)
  • 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:

About

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

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Rust 100.0%