commonlibsse_ng\re\h/
hkpKeyframedRigidMotion.rs1use core::ops::{Add as _, Sub as _};
2
3use crate::re::hkMatrix3::hkMatrix3;
4use crate::re::hkVector4::hkVector4;
5use crate::re::hkpMotion::{MotionType, hkpMotion};
6use crate::re::offsets_rtti::RTTI_hkpKeyframedRigidMotion;
7use crate::re::offsets_rtti::RTTI_hkpMaxSizeMotion;
8use crate::re::offsets_vtable::VTABLE_hkpKeyframedRigidMotion;
9use crate::re::{hkClass, hkStatisticsCollector};
10use crate::rel::id::VariantID;
11
12use super::hkQuaternion::hkQuaternion;
13use super::hkTransform::hkTransform;
14
15#[repr(C)]
22#[derive(Debug)]
23pub struct hkpKeyframedRigidMotion {
24 pub __base: hkpMotion,
27}
28
29const _: () = {
31 assert!(core::mem::offset_of!(hkpKeyframedRigidMotion, __base) == 0x0);
32 assert!(core::mem::size_of::<hkpKeyframedRigidMotion>() == 0x140);
33};
34
35impl hkpKeyframedRigidMotion {
36 pub const RTTI: VariantID = RTTI_hkpKeyframedRigidMotion;
38
39 pub const VTABLE: [VariantID; 1] = VTABLE_hkpKeyframedRigidMotion;
41
42 #[inline]
44 pub fn new() -> Self {
45 let mut motion = hkpMotion::new();
46 motion.type_ = MotionType::Keyframed.into(); Self { __base: motion }
48 }
49
50 #[inline]
52 pub fn GetPointVelocity(&self, a_point: &hkVector4) -> hkVector4 {
53 let center_of_mass_in_world = self.__base.motionState.sweptTransform.centerOfMass1;
54 let relative_point = a_point.sub(center_of_mass_in_world);
55 self.__base.linearVelocity.add(self.__base.angularVelocity.Cross(relative_point))
56 }
57}
58
59#[repr(C)]
61pub struct hkpKeyframedRigidMotionVtbl {
62 pub CxxDrop: fn(this: &mut hkpKeyframedRigidMotion),
64
65 pub GetClassType: fn(this: &hkpKeyframedRigidMotion) -> Option<&hkClass>,
67
68 pub CalcContentStatistics: fn(
70 this: &hkpKeyframedRigidMotion,
71 collector: &mut hkStatisticsCollector,
72 cls: Option<&hkClass>,
73 ),
74
75 pub SetMass: fn(this: &mut hkpKeyframedRigidMotion, a_mass: f32),
77
78 pub SetMassInv: fn(this: &mut hkpKeyframedRigidMotion, a_massInv: f32),
80
81 pub GetInertiaLocal: fn(this: &hkpKeyframedRigidMotion, a_inertiaOut: &mut hkMatrix3),
83
84 pub GetInertiaWorld: fn(this: &hkpKeyframedRigidMotion, a_inertiaOut: &mut hkMatrix3),
86
87 pub SetInertiaLocal: fn(this: &mut hkpKeyframedRigidMotion, a_inertia: &hkMatrix3),
89
90 pub SetInertiaInvLocal: fn(this: &mut hkpKeyframedRigidMotion, a_inertiaInv: &hkMatrix3),
92
93 pub GetInertiaInvLocal: fn(this: &hkpKeyframedRigidMotion, a_inertiaInvOut: &mut hkMatrix3),
95
96 pub GetInertiaInvWorld: fn(this: &hkpKeyframedRigidMotion, a_inertiaInvOut: &mut hkMatrix3),
98
99 pub SetCenterOfMassInLocal: fn(this: &mut hkpKeyframedRigidMotion, a_centerOfMass: hkVector4),
101
102 pub SetPosition: fn(this: &mut hkpKeyframedRigidMotion, a_position: hkVector4),
104
105 pub SetRotation: fn(this: &mut hkpKeyframedRigidMotion, a_rotation: hkQuaternion),
107
108 pub SetPositionAndRotation:
110 fn(this: &mut hkpKeyframedRigidMotion, a_position: hkVector4, a_rotation: hkQuaternion),
111
112 pub SetTransform: fn(this: &mut hkpKeyframedRigidMotion, a_transform: hkTransform),
114
115 pub SetLinearVelocity: fn(this: &mut hkpKeyframedRigidMotion, a_newVel: hkVector4),
117
118 pub SetAngularVelocity: fn(this: &mut hkpKeyframedRigidMotion, a_newVel: hkVector4),
120
121 pub GetProjectedPointVelocity: fn(
123 this: &hkpKeyframedRigidMotion,
124 a_point: hkVector4,
125 a_normal: hkVector4,
126 a_velOut: &mut f32,
127 a_invVirtMassOut: &mut f32,
128 ),
129
130 pub ApplyLinearImpulse: fn(this: &mut hkpKeyframedRigidMotion, a_impulse: hkVector4),
132
133 pub ApplyPointImpulse:
135 fn(this: &mut hkpKeyframedRigidMotion, a_impulse: hkVector4, a_point: hkVector4),
136
137 pub ApplyAngularImpulse: fn(this: &mut hkpKeyframedRigidMotion, a_impulse: hkVector4),
139
140 pub ApplyForce: fn(this: &mut hkpKeyframedRigidMotion, a_deltaTime: f32, a_force: hkVector4),
142
143 pub ApplyForceAtPoint: fn(
145 this: &mut hkpKeyframedRigidMotion,
146 a_deltaTime: f32,
147 a_force: hkVector4,
148 a_point: hkVector4,
149 ),
150
151 pub ApplyTorque: fn(this: &mut hkpKeyframedRigidMotion, a_deltaTime: f32, a_torque: hkVector4),
153
154 pub GetMotionStateAndVelocitiesAndDeactivationType:
156 fn(this: &hkpKeyframedRigidMotion, a_motionOut: &mut hkpMotion),
157
158 pub SetStepPosition: fn(this: &mut hkpKeyframedRigidMotion, a_position: f32, a_timestep: f32),
160
161 pub SetStoredMotion:
163 fn(this: &mut hkpKeyframedRigidMotion, a_savedMotion: Option<&mut hkpMaxSizeMotion>),
164}
165
166impl Default for hkpKeyframedRigidMotion {
167 #[inline]
168 fn default() -> Self {
169 Self::new()
170 }
171}
172
173#[repr(C)]
180pub struct hkpMaxSizeMotion {
181 pub __base: hkpKeyframedRigidMotion,
184}
185
186const _: () = {
188 assert!(core::mem::offset_of!(hkpMaxSizeMotion, __base) == 0x0);
189 assert!(core::mem::size_of::<hkpMaxSizeMotion>() == 0x140);
190};
191
192impl hkpMaxSizeMotion {
193 pub const RTTI: VariantID = RTTI_hkpMaxSizeMotion;
195
196 #[inline]
198 pub fn new() -> Self {
199 Self { __base: hkpKeyframedRigidMotion::new() }
200 }
201}
202
203impl Default for hkpMaxSizeMotion {
204 #[inline]
205 fn default() -> Self {
206 Self::new()
207 }
208}