commonlibsse_ng\re\h/
hkTransform.rs

1use crate::re::hkRotation::hkRotation;
2use crate::re::hkVector4::hkVector4;
3
4/// Represents a 3D transform in the Havok system, combining rotation and translation.
5///
6/// This struct consists of a rotation matrix and a translation vector.
7///
8/// # Memory Layout:
9/// - `rotation`: 3x3 rotation matrix (0x00 - 0x2F)
10/// - `translation`: 4D translation vector (0x30 - 0x3F)
11#[repr(C)]
12#[derive(Debug, Clone, Copy)]
13pub struct hkTransform {
14    /// The rotation component of the transform.
15    /// - Offset: 0x00
16    pub rotation: hkRotation,
17
18    /// The translation component of the transform.
19    /// - Offset: 0x30
20    pub translation: hkVector4,
21}
22
23// Compile-time memory layout verification
24const _: () = {
25    assert!(core::mem::offset_of!(hkTransform, rotation) == 0x0);
26    assert!(core::mem::offset_of!(hkTransform, translation) == 0x30);
27    assert!(core::mem::size_of::<hkTransform>() == 0x40);
28};
29
30impl hkTransform {
31    /// Creates a new `hkTransform` with an identity rotation and zero translation.
32    #[inline]
33    pub fn new() -> Self {
34        Self {
35            rotation: hkRotation::new(),   // Assuming hkRotation has a new() method
36            translation: hkVector4::new(), // Zero translation
37        }
38    }
39}
40
41impl Default for hkTransform {
42    #[inline]
43    fn default() -> Self {
44        Self::new()
45    }
46}