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
use super::*;

/// Three-dimensional vector: `x`, `y`, and `z`.
///
/// Internally, this is a `Vec4`. The speed gains outweigh the extra memory
/// used.
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct Vec3 {
  raw: Vec4,
}
unsafe impl Zeroable for Vec3 {}
unsafe impl Pod for Vec3 {}
impl Default for Vec3 {
  fn default() -> Self {
    Self::zeroed()
  }
}
impl From<[f32; 3]> for Vec3 {
  fn from(val: [f32; 3]) -> Self {
    Self {
      raw: cast([val[0], val[1], val[2], 0.0]),
    }
  }
}
impl Vec3 {
  /// Component-wise absolute value.
  pub fn abs(self) -> Self {
    Self {
      raw: self.raw.abs(),
    }
  }
}