commonlibsse_ng\re\h/
hkBaseTypes.rs1pub type hkObjectIndex = u16;
3
4pub type hkTime = f32;
6
7#[commonlibsse_ng_derive_internal::ffi_enum]
9#[repr(i32)]
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub enum hkResult {
12 Success = 0,
13 Failure = 1,
14}
15
16#[repr(C)]
23#[derive(Debug, Clone, Copy, PartialEq)]
24pub struct hkHalf {
25 _value: i16,
28}
29
30const _: () = {
32 assert!(core::mem::offset_of!(hkHalf, _value) == 0x0);
33 assert!(core::mem::size_of::<hkHalf>() == 0x2);
34};
35
36impl hkHalf {
37 #[inline]
39 pub const fn new() -> Self {
40 Self { _value: 0 }
41 }
42
43 #[inline]
45 pub const fn from_f32(a_val: f32) -> Self {
46 let mut half = Self::new();
47 half.set_f32(a_val);
48 half
49 }
50
51 #[inline]
53 const fn set_f32(&mut self, a_val: f32) {
54 let bits = a_val.to_bits();
56 let sign = (bits >> 31) as i16;
57 let exp = ((bits >> 23) & 0xFF) as i16 - 127 + 15; let mantissa = (bits & 0x7FFFFF) >> 13; if exp <= 0 {
60 self._value = 0; } else if exp > 31 {
62 self._value = (sign << 15) | 0x7C00; } else {
64 self._value = (sign << 15) | (exp << 10) | mantissa as i16;
65 }
66 }
67
68 #[inline]
70 fn to_f32(self) -> f32 {
71 let sign = (self._value >> 15) & 0x1;
73 let exp = ((self._value >> 10) & 0x1F) as u32;
74 let mantissa = (self._value & 0x3FF) as u32;
75 if exp == 0 {
76 if mantissa == 0 {
77 0.0 } else {
79 f32::from_bits(((sign as u32) << 31) | (mantissa << 13))
81 * 2.0_f32.powi(-14 - 127 + 15)
82 }
83 } else if exp == 0x1F {
84 if mantissa == 0 {
85 if sign == 0 { f32::INFINITY } else { f32::NEG_INFINITY } } else {
87 f32::NAN }
89 } else {
90 f32::from_bits(((sign as u32) << 31) | ((exp + 127 - 15) << 23) | (mantissa << 13))
91 }
92 }
93}
94
95impl Default for hkHalf {
96 #[inline]
97 fn default() -> Self {
98 Self::new()
99 }
100}
101
102impl From<f32> for hkHalf {
103 #[inline]
104 fn from(a_val: f32) -> Self {
105 Self::from_f32(a_val)
106 }
107}
108
109impl From<hkHalf> for f32 {
110 #[inline]
111 fn from(val: hkHalf) -> Self {
112 val.to_f32()
113 }
114}
115
116#[repr(C)]
123#[derive(Debug, Default, Clone, Copy, PartialEq)]
124pub struct hkUFloat8 {
125 pub value: u8,
128}
129
130const _: () = {
132 assert!(core::mem::offset_of!(hkUFloat8, value) == 0x0);
133 assert!(core::mem::size_of::<hkUFloat8>() == 0x1);
134};