11use std:: marker:: PhantomData ;
22
3+ use glam:: Quat ;
34use joltc_sys:: * ;
45
5- use crate :: { Body , BodyId , IntoJolt , IntoRolt , RVec3 , Vec3 } ;
6+ use crate :: { Body , BodyId , IntoJolt , IntoRolt , ObjectLayer , RVec3 , Vec3 } ;
67
78/// See also: Jolt's [`BodyInterface`](https://jrouwe.github.io/JoltPhysicsDocs/5.1.0/class_body_interface.html) class.
89pub struct BodyInterface < ' physics_system > {
@@ -44,6 +45,24 @@ impl<'physics_system> BodyInterface<'physics_system> {
4445 unsafe { JPC_BodyInterface_DestroyBody ( self . raw , body_id. raw ( ) ) }
4546 }
4647
48+ /// # Safety
49+ /// `shape` must be a valid shape.
50+ pub unsafe fn set_shape (
51+ & self ,
52+ body_id : BodyId ,
53+ shape : * const JPC_Shape ,
54+ update_mass_properties : bool ,
55+ activation : JPC_Activation ,
56+ ) {
57+ JPC_BodyInterface_SetShape (
58+ self . raw ,
59+ body_id. raw ( ) ,
60+ shape,
61+ update_mass_properties,
62+ activation,
63+ )
64+ }
65+
4766 pub fn is_active ( & self , body_id : BodyId ) -> bool {
4867 unsafe { JPC_BodyInterface_IsActive ( self . raw , body_id. raw ( ) ) }
4968 }
@@ -70,6 +89,46 @@ impl<'physics_system> BodyInterface<'physics_system> {
7089 }
7190 }
7291
92+ pub fn set_object_layer ( & self , body_id : BodyId , object_layer : ObjectLayer ) {
93+ unsafe { JPC_BodyInterface_SetObjectLayer ( self . raw , body_id. raw ( ) , object_layer. raw ( ) ) }
94+ }
95+
96+ pub fn notify_shape_changed (
97+ & self ,
98+ body_id : BodyId ,
99+ old_com : Vec3 ,
100+ update_mass_properties : bool ,
101+ activation : JPC_Activation ,
102+ ) {
103+ unsafe {
104+ JPC_BodyInterface_NotifyShapeChanged (
105+ self . raw ,
106+ body_id. raw ( ) ,
107+ old_com. into_jolt ( ) ,
108+ update_mass_properties,
109+ activation,
110+ )
111+ }
112+ }
113+
114+ pub fn set_position_and_rotation_when_changed (
115+ & self ,
116+ body_id : BodyId ,
117+ pos : RVec3 ,
118+ rot : Quat ,
119+ activation : JPC_Activation ,
120+ ) {
121+ unsafe {
122+ JPC_BodyInterface_SetPositionAndRotationWhenChanged (
123+ self . raw ,
124+ body_id. raw ( ) ,
125+ pos. into_jolt ( ) ,
126+ rot. into_jolt ( ) ,
127+ activation,
128+ )
129+ }
130+ }
131+
73132 pub fn as_raw ( & self ) -> * mut JPC_BodyInterface {
74133 self . raw
75134 }
0 commit comments