Skip to content

Commit

Permalink
New crate names, improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Apr 22, 2024
1 parent 3b18af4 commit 9b670e0
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "crates/jolt-sys/JoltC"]
path = crates/jolt-sys/JoltC
[submodule "crates/joltc-sys/JoltC"]
path = crates/joltc-sys/JoltC
url = ../JoltC.git
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Rust bindings for [Jolt Physics](https://github.com/jrouwe/JoltPhysics) 5.0.0 us
This project is an early work in progress. Watch for exposed nails.

## Goals
1. `jolt-sys`: Functioning, up-to-date unsafe bindings to Jolt Physics
2. `jolt`: Ergonomic, safe bindings to Jolt Physics
1. `joltc-sys`: Functioning, up-to-date unsafe bindings to Jolt Physics
2. `rolt`: Ergonomic, safe bindings to Jolt Physics

## Crates

### `jolt-sys` — Jolt bindings via [JoltC]
### `joltc-sys` — Jolt bindings via [JoltC]
This crate contains unsafe bindings to JoltC.

### `jolt` — aspirationally safe Rust Jolt bindings
### `rolt` — aspirationally safe Rust Jolt bindings
This crate contains a higher-level wrapper around JoltC, providing ergonomics comparable to using Jolt from C++.

The safety of this crate is currently provided on a best-effort basis.
Expand All @@ -23,6 +23,13 @@ This is a port of Jolt's [HelloWorld] example to Rust using `jolt-sys`. It isn't
### `hello-world` — HelloWorld using `jolt`
This is a port of Jolt's [HelloWorld] example to Rust using the `jolt` crate. The goal of this example is to replicate the behavior of the original example entirely in safe Rust.

## Submodules
This repository uses Git submodules. Make sure to initialize submodules recursively so that JoltC and Jolt are both referenced correctly in your checkout:

```bash
git submodule update --init --recursive
```

## License
Licensed under either of

Expand Down
2 changes: 1 addition & 1 deletion crates/hello-world-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
jolt-sys = { path = "../jolt-sys" }
joltc-sys = { path = "../joltc-sys" }
4 changes: 2 additions & 2 deletions crates/hello-world-sys/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hello World (jolt-sys)
A port of the Jolt Physics "HelloWorld" sample using `jolt-sys`.
# Hello World (joltc-sys)
A port of the Jolt Physics "HelloWorld" sample using `joltc-sys`.

This example is full of unsafe code because it's using the JoltC API.
4 changes: 2 additions & 2 deletions crates/hello-world-sys/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::ffi::{c_uint, c_void, CStr};
use std::mem::MaybeUninit;
use std::ptr;

// Everything prefixed with `JPC_` comes from the jolt_sys crate.
use jolt_sys::*;
// Everything prefixed with `JPC_` comes from the joltc_sys crate.
use joltc_sys::*;

const OL_NON_MOVING: JPC_ObjectLayer = 0;
const OL_MOVING: JPC_ObjectLayer = 1;
Expand Down
4 changes: 2 additions & 2 deletions crates/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
jolt = { path = "../jolt" }
jolt-sys = { path = "../jolt-sys" }
rolt = { path = "../rolt" }
joltc-sys = { path = "../joltc-sys" }
18 changes: 9 additions & 9 deletions crates/hello-world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::ffi::{c_void, CStr};
use std::mem::MaybeUninit;
use std::ptr;

// Everything prefixed with `JPC_` comes from the jolt_sys crate.
use jolt_sys::*;
// Everything prefixed with `JPC_` comes from the joltc_sys crate.
use joltc_sys::*;

use jolt::{BodyId, BroadPhaseLayer, BroadPhaseLayerInterface, ObjectLayer, Vec3};
use rolt::{BodyId, BroadPhaseLayer, BroadPhaseLayerInterface, ObjectLayer, Vec3};

const OL_NON_MOVING: JPC_ObjectLayer = 0;
const OL_MOVING: JPC_ObjectLayer = 1;
Expand Down Expand Up @@ -74,9 +74,9 @@ fn rvec3(x: Real, y: Real, z: Real) -> JPC_RVec3 {
}

fn main() {
jolt::register_default_allocator();
jolt::factory_init();
jolt::register_types();
rolt::register_default_allocator();
rolt::factory_init();
rolt::register_types();

unsafe {
let temp_allocator = JPC_TempAllocatorImpl_new(10 * 1024 * 1024);
Expand All @@ -91,7 +91,7 @@ fn main() {

let object_vs_object_layer_filter = JPC_ObjectLayerPairFilter_new(ptr::null_mut(), OVO);

let physics_system = jolt::PhysicsSystem::new();
let physics_system = rolt::PhysicsSystem::new();

let max_bodies = 1024;
let num_body_mutexes = 0;
Expand Down Expand Up @@ -197,8 +197,8 @@ fn main() {
JPC_TempAllocatorImpl_delete(temp_allocator);
}

jolt::unregister_types();
jolt::factory_delete();
rolt::unregister_types();
rolt::factory_delete();

println!("Hello, world!");
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/jolt-sys/Cargo.toml → crates/joltc-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jolt-sys"
description = "Unsafe bindings to Jolt Physics"
name = "joltc-sys"
description = "Unsafe bindings to Jolt Physics using JoltC"
version = "0.1.0+Jolt-5.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/SecondHalfGames/jolt-rust"
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions crates/jolt/Cargo.toml → crates/rolt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "jolt"
name = "rolt"
description = "Safe(-ish) bindings to Jolt Physics"
version = "0.1.0+Jolt-5.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/SecondHalfGames/jolt-rust"
edition = "2021"

[features]
double-precision = ["jolt-sys/double-precision"]
object-layer-u32 = ["jolt-sys/object-layer-u32"]
double-precision = ["joltc-sys/double-precision"]
object-layer-u32 = ["joltc-sys/object-layer-u32"]

[dependencies]
jolt-sys = { version = "0.1.0", path = "../jolt-sys" }
joltc-sys = { version = "0.1.0", path = "../joltc-sys" }

[lints.clippy]
new_without_default = { level = "allow" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::PhantomData;

use jolt_sys::*;
use joltc_sys::*;

use crate::{BodyId, RVec3, Vec3};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ffi::{c_uint, c_void};
use std::marker::PhantomData;
use std::ptr;

use jolt_sys::*;
use joltc_sys::*;

use crate::{BroadPhaseLayer, ObjectLayer};

Expand Down
2 changes: 1 addition & 1 deletion crates/jolt/src/lib.rs → crates/rolt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use jolt_sys::*;
use joltc_sys::*;

mod body_interface;
mod interfaces;
Expand Down
4 changes: 2 additions & 2 deletions crates/jolt/src/math.rs → crates/rolt/src/math.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use jolt_sys::{JPC_Color, JPC_DVec3, JPC_Quat, JPC_Vec3};
use joltc_sys::{JPC_Color, JPC_DVec3, JPC_Quat, JPC_Vec3};

pub use jolt_sys::Real;
pub use joltc_sys::Real;

#[cfg(feature = "double-precision")]
pub type RVec3 = DVec3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ptr;

use jolt_sys::*;
use joltc_sys::*;

use crate::{BodyInterface, IntoBroadPhaseLayerInterface};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use jolt_sys::*;
use joltc_sys::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ObjectLayer(JPC_ObjectLayer);
Expand Down

0 comments on commit 9b670e0

Please sign in to comment.