Rust binding and wrapper over NVIDIA PhysX, a popular and mature physics engine particularly well-suited for games.
Created and maintained by Embark and not officially supported by NVIDIA.
This repository contains 3 crates:
||High-level interface on top of
||Unsafe bindings to the PhysX C++ API|
||Utility macros used internally by the
Why use it?
- You want a feature-rich and performant physics engine to use in your project.
physxwrapper is work-in-progress, and only covers a part of PhysX functionality. You can follow our progress and see where contributions are needed in our Tracking Issue for High-Level API Completeness.
Any other features have to be accessed through the unsafe physx-sys crate.
It's a large C++ codebase which requires a C++ toolchain, and comes with a non-trivial build system.
- nphysics: a 2- and 3-dimensional physics engine for games and animations written in Rust. It is a good option for projects which do not require the full feature set of PhysX or prefer a native Rust solution.
The following code example shows how
physx can be initialized.
const PX_PHYSICS_VERSION: u32 = physx::version(4, 1, 0); let mut foundation = Foundation::new(PX_PHYSICS_VERSION); let mut physics = PhysicsBuilder::default() .load_extensions(false) // switch this flag to load extensions during setup .build(&mut foundation); let mut scene = physics.create_scene( SceneBuilder::default() .set_gravity(glm::vec3(0.0, -9.81, 0.0)) .set_simulation_threading(SimulationThreadType::Dedicated(1)), );
You can run an example with
cargo run --example ball, which should show the following output:
Information about all wrapper functionality can be found in the physx crate docs.
We welcome community contributions to this project.
Please read our Contributor Guide for more information on how to get started.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.