C Wrapper for the Jolt Physics engine.
#c #physics #3d #gamedev #simulation #collision #library #wrapper #cpp

Rasmus Brönnegård 03de437642 Remove JPC_SliderConstraint_to_Constraint hai 1 día
.github 2265632ee5 Get outta here, ubuntu-latestl+Release hai 1 ano
HelloWorld 50e60a3945 Add JobSystemSingleThreaded (#18) hai 2 meses
JoltC 03de437642 Remove JPC_SliderConstraint_to_Constraint hai 1 día
JoltCImpl 03de437642 Remove JPC_SliderConstraint_to_Constraint hai 1 día
JoltPhysics @ 0373ec0dd7 364f139b7f Update to Jolt Physics 5.3.0 hai 3 meses
generate 02f105558f Remove root Cargo.toml for packaging reasons hai 1 ano
.editorconfig a371375686 Add .editorconfig hai 1 ano
.gitignore 02f105558f Remove root Cargo.toml for packaging reasons hai 1 ano
.gitmodules 39b33067d3 Initial commit hai 1 ano
CMakeLists.txt 9cad13df67 Move C++ implementation to new module and start specializing to_jpc/to_jph hai 4 meses
LICENSE-APACHE 7907eaa304 Update license and README hai 1 ano
LICENSE-MIT 7907eaa304 Update license and README hai 1 ano
README.md 789e04100d Update README hai 4 meses
test-all-flags.sh cdcf8ecba2 Set up GitHub Actions correctly on my first try hai 1 ano

README.md

JoltC

C wrapper for Jolt Physics 5.x.

Currently a work in progress. Bindings contain functions that we've needed as part of our game or the Rust bindings we're working on in jolt-rust.

The JoltC directory contains headers for the C interface that you can bind to.

The JoltCImpl directory contains the C++ implementation of the C interface and serves as the glue between the C++ and C code.

Goals

  1. Sound C wrapper around current version of Jolt Physics
    • We avoid relying on unspecified C++ type layout, which means reflecting those types as opaque handles.
    • We always assert identical layout when creating FFI-compatible versions of C++ types in cases where it makes sense.
  2. Headers suitable for usage in automatic binding generation tools (i.e. Rust bindgen, LuaJIT FFI)

Building

Use CMake:

# Configure the build
cmake -B build

# Optionally, you can enable double precision, or make ObjectLayer use 32 bits
# We aim to support most of the configuration of Jolt's C++ API.
cmake -B build -DDOUBLE_PRECISION=ON -DOBJECT_LAYER_BITS=32

# Build
cmake --build build

Hello, world!

A port of Jolt's "HelloWorld" example is provided in HelloWorld/main.cpp.

Jolt's RefTarget Types

Jolt has internal reference counting for a few types along with good documentation about handling them in C++. This interface to Jolt does not have a generic Ref/RefConst wrapper, so it's important to be conscious of ref counts when handling these types.

Just like Jolt, this library will return those objects with a reference count of 0. Jolt APIs that accept these types will take ownership of the given value and increment the reference count.

You can use JPC_{type}_AddRef and JPC_{type}_Release, where {type} is the type that directly inherits from RefTarget<{type}>, to add or release references. For example, for FixedConstraint, use JPC_Constraint_AddRef to add a new reference.

Other C Wrappers

Other C wrappers for Jolt Physics include:

The goal of this project is to be a C wrapper around Jolt Physics that is not part of a larger binding project and to eliminate major sources of undefined behavior. It's intended to be useful for any other language-specific bindings, but naturally these bindings were born out of the goal of creating Rust bindings to Jolt Physics.

License

Licensed under either of

at your option.

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.