Skip to content

Commit

Permalink
Update to latest JoltC
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Apr 20, 2024
1 parent 2fb9667 commit 04d2d68
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
22 changes: 8 additions & 14 deletions crates/hello-world-sys/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,14 @@ fn main() {
jolt_sys::JPC_MAX_PHYSICS_BARRIERS as _,
);

let broad_phase_layer_interface = jolt_sys::JPC_BroadPhaseLayerInterface {
self_: ptr::null(),
fns: BPL,
};

let object_vs_broad_phase_layer_filter = jolt_sys::JPC_ObjectVsBroadPhaseLayerFilter {
self_: ptr::null(),
fns: OVB,
};

let object_vs_object_layer_filter = jolt_sys::JPC_ObjectLayerPairFilter {
self_: ptr::null(),
fns: OVO,
};
let broad_phase_layer_interface =
jolt_sys::JPC_BroadPhaseLayerInterface_new(ptr::null(), BPL);

let object_vs_broad_phase_layer_filter =
jolt_sys::JPC_ObjectVsBroadPhaseLayerFilter_new(ptr::null_mut(), OVB);

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

let physics_system = jolt_sys::JPC_PhysicsSystem_new();

Expand Down
14 changes: 5 additions & 9 deletions crates/hello-world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,11 @@ fn main() {

let broad_phase_layer_interface = BroadPhaseLayers;

let object_vs_broad_phase_layer_filter = jolt_sys::JPC_ObjectVsBroadPhaseLayerFilter {
self_: ptr::null_mut(),
fns: OVB,
};

let object_vs_object_layer_filter = jolt_sys::JPC_ObjectLayerPairFilter {
self_: ptr::null_mut(),
fns: OVO,
};
let object_vs_broad_phase_layer_filter =
jolt_sys::JPC_ObjectVsBroadPhaseLayerFilter_new(ptr::null_mut(), OVB);

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

let physics_system = jolt_sys::JPC_PhysicsSystem_new();

Expand Down
2 changes: 1 addition & 1 deletion crates/jolt-sys/JoltC
11 changes: 4 additions & 7 deletions crates/jolt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ptr;

use jolt_sys::{
JPC_BroadPhaseLayer, JPC_BroadPhaseLayerInterface, JPC_BroadPhaseLayerInterfaceFns,
JPC_ObjectLayer,
JPC_BroadPhaseLayerInterface_new, JPC_ObjectLayer,
};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -37,7 +37,7 @@ pub trait BroadPhaseLayerInterface: Sized {
fn get_num_broad_phase_layers(&self) -> u32;
fn get_broad_phase_layer(&self, layer: ObjectLayer) -> BroadPhaseLayer;

fn as_raw(&self) -> JPC_BroadPhaseLayerInterface {
fn as_raw(&self) -> *mut JPC_BroadPhaseLayerInterface {
jpc_bpli(self)
}
}
Expand Down Expand Up @@ -65,7 +65,7 @@ impl<T: BroadPhaseLayerInterface> BroadPhaseLayerInterfaceBridge<T> {
}
}

fn jpc_bpli<T>(input: &T) -> JPC_BroadPhaseLayerInterface
fn jpc_bpli<T>(input: &T) -> *mut JPC_BroadPhaseLayerInterface
where
T: BroadPhaseLayerInterface,
{
Expand All @@ -76,8 +76,5 @@ where
GetBroadPhaseLayer: Some(Bridge::<T>::GetBroadPhaseLayer as _),
};

JPC_BroadPhaseLayerInterface {
self_: ptr::from_ref(input).cast::<c_void>(),
fns,
}
unsafe { JPC_BroadPhaseLayerInterface_new(ptr::from_ref(input).cast::<c_void>(), fns) }
}

0 comments on commit 04d2d68

Please sign in to comment.