1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#![warn(clippy::all)]
#![warn(rust_2018_idioms)]
use super::transform::{gl_to_px_tf, px_to_gl_tf};
use super::{
articulation_joint_reduced_coordinate::ArticulationJointReducedCoordinate,
articulation_link::ArticulationLink, base::Base, px_type::*,
};
use glam::Mat4;
use physx_macros::*;
use physx_sys::{
PxArticulationJointBase, PxArticulationJointBase_getChildPose,
PxArticulationJointBase_getParentArticulationLink, PxArticulationJointBase_getParentPose,
PxArticulationJointBase_setChildPose_mut, PxArticulationJointBase_setParentPose_mut,
};
#[physx_type(inherit = "Base")]
impl ArticulationJointBase {
pub fn set_child_pose(&mut self, pose: Mat4) {
unsafe {
PxArticulationJointBase_setChildPose_mut(self.get_raw_mut(), &gl_to_px_tf(pose));
}
}
pub fn get_child_pose(&self) -> Mat4 {
px_to_gl_tf(unsafe { PxArticulationJointBase_getChildPose(self.get_raw()) })
}
pub fn set_parent_pose(&mut self, pose: Mat4) {
unsafe {
PxArticulationJointBase_setParentPose_mut(self.get_raw_mut(), &gl_to_px_tf(pose));
}
}
pub fn get_parent_pose(&self) -> Mat4 {
px_to_gl_tf(unsafe { PxArticulationJointBase_getParentPose(self.get_raw()) })
}
pub fn get_parent_articulation_link(&self) -> ArticulationLink {
ArticulationLink::from_ptr(unsafe {
PxArticulationJointBase_getParentArticulationLink(self.get_raw())
})
}
pub fn get_joint_transform_global(&self) -> Mat4 {
let outbound_link = self.get_parent_articulation_link();
let outbound_link_global_pose = outbound_link.get_global_pose();
let joint_pose = self.get_parent_pose();
outbound_link_global_pose * joint_pose
}
pub fn as_reduced_joint_mut(&mut self) -> &mut ArticulationJointReducedCoordinate {
assert!(self.is_type("PxArticulationJointReducedCoordinate"));
unsafe {
&mut *(self as *mut ArticulationJointBase as *mut ArticulationJointReducedCoordinate)
}
}
pub fn as_reduced_joint(&self) -> &ArticulationJointReducedCoordinate {
assert!(self.is_type("PxArticulationJointReducedCoordinate"));
unsafe {
&*(self as *const ArticulationJointBase as *const ArticulationJointReducedCoordinate)
}
}
}