1use crate::re::hkBaseTypes::hkHalf;
2use crate::re::hkMatrix3::hkMatrix3;
3use crate::re::hkMotionState::hkMotionState;
4use crate::re::hkQuaternion::hkQuaternion;
5use crate::re::hkReferencedObject::hkReferencedObject;
6use crate::re::hkTransform::hkTransform;
7use crate::re::hkVector4::hkVector4;
8use crate::re::hkpKeyframedRigidMotion::hkpMaxSizeMotion;
9use crate::re::offsets_rtti::RTTI_hkpMotion;
10use crate::re::offsets_vtable::VTABLE_hkpMotion;
11use crate::re::{hkClass, hkStatisticsCollector};
12use crate::rel::id::VariantID;
13
14#[repr(C)]
18#[derive(Debug)]
19pub struct hkpMotion {
20 pub __base: hkReferencedObject,
22
23 pub type_: MotionType_CEnum,
26
27 pub deactivationIntegrateCounter: u8,
30
31 pub deactivationNumInactiveFrames: [u16; 2],
34
35 pub pad016: u16,
38
39 pub pad018: u64,
42
43 pub motionState: hkMotionState,
46
47 pub inertiaAndMassInv: hkVector4,
50
51 pub linearVelocity: hkVector4,
54
55 pub angularVelocity: hkVector4,
58
59 pub deactivationRefPosition: [hkVector4; 2],
62
63 pub deactivationRefOrientation: [u32; 2],
66
67 pub savedMotion: *mut hkpMaxSizeMotion,
70
71 pub savedQualityTypeIndex: u16,
74
75 pub pad132: u16,
78
79 pub gravityFactor: hkHalf,
82
83 pub pad138: u64,
86}
87
88const _: () = {
90 assert!(core::mem::offset_of!(hkpMotion, __base) == 0x0);
91 assert!(core::mem::offset_of!(hkpMotion, type_) == 0x010);
92 assert!(core::mem::offset_of!(hkpMotion, deactivationIntegrateCounter) == 0x011);
93 assert!(core::mem::offset_of!(hkpMotion, deactivationNumInactiveFrames) == 0x012);
94 assert!(core::mem::offset_of!(hkpMotion, pad016) == 0x016);
95 assert!(core::mem::offset_of!(hkpMotion, pad018) == 0x018);
96 assert!(core::mem::offset_of!(hkpMotion, motionState) == 0x020);
97 assert!(core::mem::offset_of!(hkpMotion, inertiaAndMassInv) == 0x0D0);
98 assert!(core::mem::offset_of!(hkpMotion, linearVelocity) == 0x0E0);
99 assert!(core::mem::offset_of!(hkpMotion, angularVelocity) == 0x0F0);
100 assert!(core::mem::offset_of!(hkpMotion, deactivationRefPosition) == 0x100);
101 assert!(core::mem::offset_of!(hkpMotion, deactivationRefOrientation) == 0x120);
102 assert!(core::mem::offset_of!(hkpMotion, savedMotion) == 0x128);
103 assert!(core::mem::offset_of!(hkpMotion, savedQualityTypeIndex) == 0x130);
104 assert!(core::mem::offset_of!(hkpMotion, pad132) == 0x132);
105 assert!(core::mem::offset_of!(hkpMotion, gravityFactor) == 0x134);
106 assert!(core::mem::offset_of!(hkpMotion, pad138) == 0x138);
107 assert!(core::mem::size_of::<hkpMotion>() == 0x140);
108};
109
110#[commonlibsse_ng_derive_internal::ffi_enum]
112#[repr(u8)]
113#[derive(Debug, Clone, Copy)]
114pub enum MotionType {
115 Invalid = 0,
116 Dynamic = 1,
117 SphereInertia = 2,
118 BoxInertia = 3,
119 Keyframed = 4,
120 Fixed = 5,
121 ThinBoxInertia = 6,
122 Character = 7,
123 Total = 8,
124}
125
126impl hkpMotion {
127 pub const RTTI: VariantID = RTTI_hkpMotion;
129
130 pub const VTABLE: [VariantID; 1] = VTABLE_hkpMotion;
132
133 pub const NUM_INACTIVE_FRAMES_TO_DEACTIVATE: i32 = 5;
135
136 #[inline]
138 pub fn new() -> Self {
139 Self {
140 __base: hkReferencedObject::new(),
141 type_: MotionType_CEnum::Invalid,
142 deactivationIntegrateCounter: 0,
143 deactivationNumInactiveFrames: [0; 2],
144 pad016: 0,
145 pad018: 0,
146 motionState: hkMotionState::default(),
147 inertiaAndMassInv: hkVector4::default(),
148 linearVelocity: hkVector4::default(),
149 angularVelocity: hkVector4::default(),
150 deactivationRefPosition: [hkVector4::default(); 2],
151 deactivationRefOrientation: [0; 2],
152 savedMotion: core::ptr::null_mut(),
153 savedQualityTypeIndex: 0,
154 pad132: 0,
155 gravityFactor: hkHalf::default(), pad138: 0,
157 }
158 }
159
160 #[inline]
162 pub fn GetMass(&self) -> f32 {
163 let mass_inv = self.inertiaAndMassInv.get_component(3); if mass_inv != 0.0 { 1.0 / mass_inv } else { 0.0 }
165 }
166}
167
168#[repr(C)]
170pub struct hkpMotionVtbl {
171 pub CxxDrop: fn(this: &mut hkpMotion),
173
174 pub GetClassType: fn(this: &hkpMotion) -> Option<&hkClass>,
176
177 pub CalcContentStatistics:
179 fn(this: &hkpMotion, collector: &mut hkStatisticsCollector, cls: Option<&hkClass>),
180
181 pub SetMass: fn(this: &mut hkpMotion, a_mass: f32),
183
184 pub SetMassInv: fn(this: &mut hkpMotion, a_massInv: f32),
186
187 pub GetInertiaLocal: fn(this: &hkpMotion, a_inertiaOut: &mut hkMatrix3),
189
190 pub GetInertiaWorld: fn(this: &hkpMotion, a_inertiaOut: &mut hkMatrix3),
192
193 pub SetInertiaLocal: fn(this: &mut hkpMotion, a_inertia: &hkMatrix3),
195
196 pub SetInertiaInvLocal: fn(this: &mut hkpMotion, a_inertiaInv: &hkMatrix3),
198
199 pub GetInertiaInvLocal: fn(this: &hkpMotion, a_inertiaInvOut: &mut hkMatrix3),
201
202 pub GetInertiaInvWorld: fn(this: &hkpMotion, a_inertiaInvOut: &mut hkMatrix3),
204
205 pub SetCenterOfMassInLocal: fn(this: &mut hkpMotion, a_centerOfMass: hkVector4),
207
208 pub SetPosition: fn(this: &mut hkpMotion, a_position: hkVector4),
210
211 pub SetRotation: fn(this: &mut hkpMotion, a_rotation: hkQuaternion),
213
214 pub SetPositionAndRotation:
216 fn(this: &mut hkpMotion, a_position: hkVector4, a_rotation: hkQuaternion),
217
218 pub SetTransform: fn(this: &mut hkpMotion, a_transform: hkTransform),
220
221 pub SetLinearVelocity: fn(this: &mut hkpMotion, a_newVel: hkVector4),
223
224 pub SetAngularVelocity: fn(this: &mut hkpMotion, a_newVel: hkVector4),
226
227 pub GetProjectedPointVelocity: fn(
229 this: &hkpMotion,
230 a_point: hkVector4,
231 a_normal: hkVector4,
232 a_velOut: &mut f32,
233 a_invVirtMassOut: &mut f32,
234 ),
235
236 pub ApplyLinearImpulse: fn(this: &mut hkpMotion, a_impulse: hkVector4),
238
239 pub ApplyPointImpulse: fn(this: &mut hkpMotion, a_impulse: hkVector4, a_point: hkVector4),
241
242 pub ApplyAngularImpulse: fn(this: &mut hkpMotion, a_impulse: hkVector4),
244
245 pub ApplyForce: fn(this: &mut hkpMotion, a_deltaTime: f32, a_force: hkVector4),
247
248 pub ApplyForceAtPoint:
250 fn(this: &mut hkpMotion, a_deltaTime: f32, a_force: hkVector4, a_point: hkVector4),
251
252 pub ApplyTorque: fn(this: &mut hkpMotion, a_deltaTime: f32, a_torque: hkVector4),
254
255 pub GetMotionStateAndVelocitiesAndDeactivationType:
257 fn(this: &hkpMotion, a_motionOut: &mut hkpMotion),
258}
259
260impl Default for hkpMotion {
261 #[inline]
262 fn default() -> Self {
263 Self::new()
264 }
265}