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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::{Vec3, Vec3Mask};
#[deprecated(since = "0.7.1", note = "please use `Vec3Mask` instead")]
pub type Vec3b = Vec3Mask;
#[inline]
pub fn vec3(x: f32, y: f32, z: f32) -> Vec3 {
Vec3::new(x, y, z)
}
impl Vec3 {
#[inline]
pub fn sign(self) -> Self {
let mask = self.cmpge(Self::zero());
mask.select(Self::splat(1.0), Self::splat(-1.0))
}
#[inline]
pub fn reciprocal(self) -> Self {
Self::one() / self
}
#[inline]
pub fn lerp(self, rhs: Self, s: f32) -> Self {
self + ((rhs - self) * s)
}
#[inline]
pub fn is_normalized(self) -> bool {
is_normalized!(self)
}
}
impl AsRef<[f32; 3]> for Vec3 {
#[inline]
fn as_ref(&self) -> &[f32; 3] {
unsafe { &*(self as *const Vec3 as *const [f32; 3]) }
}
}
impl AsMut<[f32; 3]> for Vec3 {
#[inline]
fn as_mut(&mut self) -> &mut [f32; 3] {
unsafe { &mut *(self as *mut Vec3 as *mut [f32; 3]) }
}
}