Code Monkey home page Code Monkey logo

physx-rs's Introduction

๐ŸŽณ physx-rs

Rust binding for NVIDIA PhysX, a popular and mature physics engine well-suited for games

Embark Embark Crates.io Docs dependency status Build status

Created and maintained by Embark and not officially supported by NVIDIA.

This repository contains 2 crates:

Name Description Links
physx High-level interface on top of physx-sys ๐Ÿšง Crates.io Docs
physx-sys Unsafe bindings to the PhysX C++ API Crates.io Docs

Why use it?

  • You want a feature-rich and performant physics engine to use in your project.

Caveats

  • The high-level physx wrapper 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.

Alternatives

  • Rapier: a 2D and 3D physics engine for games, animation, and robotics written in Rust. Fully cross-platform, with web support and optional cross-platform determinism on IEEE 754-2008 compliant systems.

  • 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.

Presentation

Tomasz Stachowiak did a presentation at the Stockholm Rust Meetup on October 2019 about this project that goes through the technical details of how C++ to Rust bindings of physx-sys works:

An unholy fusion of Rust and C++ in physx-rs (Stockholm Rust Meetup, October 2019)

Usage

The following code example shows how physx can be initialized.

const PX_PHYSICS_VERSION: u32 = physx::version(4, 1, 1);
let mut foundation = Foundation::new(PX_PHYSICS_VERSION);

let mut physics = PhysicsFoundation::default();

let mut scene = physics.create(
    SceneDescriptor {
        gravity: PxVec3::new(0.0, 0.0, -9.81),
        ..SceneDescriptor::new(MySceneUserData::default())
    }
);

You can run an example with cargo run --example ball, which should show the following output:

Example

Information about all wrapper functionality can be found in the physx crate docs.

If you require functionality not covered by the physx wrapper you can use the low level physx-sys crate, which closely maps to the official PhysX SDK. You can find the PhysX user guide here.

Prerequisites

How to build

git submodule update --init
cargo build --release

Windows Note

It is highly recommended to not enable debug info in release mode when building with MSVC, as the Physx C++ code will take an extremely long time to compile. You can disable this by putting the following in your Cargo.toml

[profile.release.package.physx-sys]
debug = false

How to release (maintainers only)

  1. Install cargo-release
  2. Look at physx/CHANGELOG.md and physx-sys/CHANGELOG.md to determine whether both or only one of the crate needs updating, and what semantic version bump we need
  3. Review the list of changes in the changelogs and compare with the git commit diffs to the previous release and make sure we've captured and described all changes well and that they are semantically correct
  4. Run cargo release --manifest-path <physx|physx-sys>/Cargo.toml <major|minor|patch> to automatically update the CHANGELOG, publish, tag, and push the release. If you are publishing both physx and physx-sys, you can just add the --skip-push flag to avoid pushing each crate individually and then do git push --follow-tags to push both at the same time.

Contributing

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

License

Licensed under either of

at your option.

Note that the PhysX C++ SDK has its own BSD 3 license and depends on additional C++ third party libraries.

Contribution

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.