| // Generated from vec.rs.tera template. Edit the template, not the generated file. |
| |
| use crate::{BVec3, UVec2, UVec4}; |
| |
| #[cfg(not(target_arch = "spirv"))] |
| use core::fmt; |
| use core::iter::{Product, Sum}; |
| use core::{f32, ops::*}; |
| |
| /// Creates a 3-dimensional vector. |
| #[inline(always)] |
| pub const fn uvec3(x: u32, y: u32, z: u32) -> UVec3 { |
| UVec3::new(x, y, z) |
| } |
| |
| /// A 3-dimensional vector. |
| #[cfg_attr(not(target_arch = "spirv"), derive(Hash))] |
| #[derive(Clone, Copy, PartialEq, Eq)] |
| #[cfg_attr(not(target_arch = "spirv"), repr(C))] |
| #[cfg_attr(target_arch = "spirv", repr(simd))] |
| pub struct UVec3 { |
| pub x: u32, |
| pub y: u32, |
| pub z: u32, |
| } |
| |
| impl UVec3 { |
| /// All zeroes. |
| pub const ZERO: Self = Self::splat(0); |
| |
| /// All ones. |
| pub const ONE: Self = Self::splat(1); |
| |
| /// A unit-length vector pointing along the positive X axis. |
| pub const X: Self = Self::new(1, 0, 0); |
| |
| /// A unit-length vector pointing along the positive Y axis. |
| pub const Y: Self = Self::new(0, 1, 0); |
| |
| /// A unit-length vector pointing along the positive Z axis. |
| pub const Z: Self = Self::new(0, 0, 1); |
| |
| /// The unit axes. |
| pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z]; |
| |
| /// Creates a new vector. |
| #[inline(always)] |
| pub const fn new(x: u32, y: u32, z: u32) -> Self { |
| Self { x, y, z } |
| } |
| |
| /// Creates a vector with all elements set to `v`. |
| #[inline] |
| pub const fn splat(v: u32) -> Self { |
| Self { x: v, y: v, z: v } |
| } |
| |
| /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use |
| /// for each element of `self`. |
| /// |
| /// A true element in the mask uses the corresponding element from `if_true`, and false |
| /// uses the element from `if_false`. |
| #[inline] |
| pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self { |
| Self { |
| x: if mask.x { if_true.x } else { if_false.x }, |
| y: if mask.y { if_true.y } else { if_false.y }, |
| z: if mask.z { if_true.z } else { if_false.z }, |
| } |
| } |
| |
| /// Creates a new vector from an array. |
| #[inline] |
| pub const fn from_array(a: [u32; 3]) -> Self { |
| Self::new(a[0], a[1], a[2]) |
| } |
| |
| /// `[x, y, z]` |
| #[inline] |
| pub const fn to_array(&self) -> [u32; 3] { |
| [self.x, self.y, self.z] |
| } |
| |
| /// Creates a vector from the first 3 values in `slice`. |
| /// |
| /// # Panics |
| /// |
| /// Panics if `slice` is less than 3 elements long. |
| #[inline] |
| pub const fn from_slice(slice: &[u32]) -> Self { |
| Self::new(slice[0], slice[1], slice[2]) |
| } |
| |
| /// Writes the elements of `self` to the first 3 elements in `slice`. |
| /// |
| /// # Panics |
| /// |
| /// Panics if `slice` is less than 3 elements long. |
| #[inline] |
| pub fn write_to_slice(self, slice: &mut [u32]) { |
| slice[0] = self.x; |
| slice[1] = self.y; |
| slice[2] = self.z; |
| } |
| |
| /// Internal method for creating a 3D vector from a 4D vector, discarding `w`. |
| #[allow(dead_code)] |
| #[inline] |
| pub(crate) fn from_vec4(v: UVec4) -> Self { |
| Self { |
| x: v.x, |
| y: v.y, |
| z: v.z, |
| } |
| } |
| |
| /// Creates a 4D vector from `self` and the given `w` value. |
| #[inline] |
| pub fn extend(self, w: u32) -> UVec4 { |
| UVec4::new(self.x, self.y, self.z, w) |
| } |
| |
| /// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. |
| /// |
| /// Truncation may also be performed by using `self.xy()` or `UVec2::from()`. |
| #[inline] |
| pub fn truncate(self) -> UVec2 { |
| use crate::swizzles::Vec3Swizzles; |
| self.xy() |
| } |
| |
| /// Computes the dot product of `self` and `rhs`. |
| #[inline] |
| pub fn dot(self, rhs: Self) -> u32 { |
| (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) |
| } |
| |
| /// Returns a vector where every component is the dot product of `self` and `rhs`. |
| #[inline] |
| pub fn dot_into_vec(self, rhs: Self) -> Self { |
| Self::splat(self.dot(rhs)) |
| } |
| |
| /// Computes the cross product of `self` and `rhs`. |
| #[inline] |
| pub fn cross(self, rhs: Self) -> Self { |
| Self { |
| x: self.y * rhs.z - rhs.y * self.z, |
| y: self.z * rhs.x - rhs.z * self.x, |
| z: self.x * rhs.y - rhs.x * self.y, |
| } |
| } |
| |
| /// Returns a vector containing the minimum values for each element of `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. |
| #[inline] |
| pub fn min(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.min(rhs.x), |
| y: self.y.min(rhs.y), |
| z: self.z.min(rhs.z), |
| } |
| } |
| |
| /// Returns a vector containing the maximum values for each element of `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. |
| #[inline] |
| pub fn max(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.max(rhs.x), |
| y: self.y.max(rhs.y), |
| z: self.z.max(rhs.z), |
| } |
| } |
| |
| /// Component-wise clamping of values, similar to [`u32::clamp`]. |
| /// |
| /// Each element in `min` must be less-or-equal to the corresponding element in `max`. |
| /// |
| /// # Panics |
| /// |
| /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. |
| #[inline] |
| pub fn clamp(self, min: Self, max: Self) -> Self { |
| glam_assert!(min.cmple(max).all(), "clamp: expected min <= max"); |
| self.max(min).min(max) |
| } |
| |
| /// Returns the horizontal minimum of `self`. |
| /// |
| /// In other words this computes `min(x, y, ..)`. |
| #[inline] |
| pub fn min_element(self) -> u32 { |
| self.x.min(self.y.min(self.z)) |
| } |
| |
| /// Returns the horizontal maximum of `self`. |
| /// |
| /// In other words this computes `max(x, y, ..)`. |
| #[inline] |
| pub fn max_element(self) -> u32 { |
| self.x.max(self.y.max(self.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `==` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmpeq(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `!=` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmpne(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `>=` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmpge(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `>` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmpgt(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `<=` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmple(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z)) |
| } |
| |
| /// Returns a vector mask containing the result of a `<` comparison for each element of |
| /// `self` and `rhs`. |
| /// |
| /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all |
| /// elements. |
| #[inline] |
| pub fn cmplt(self, rhs: Self) -> BVec3 { |
| BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z)) |
| } |
| |
| /// Casts all elements of `self` to `f32`. |
| #[inline] |
| pub fn as_vec3(&self) -> crate::Vec3 { |
| crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32) |
| } |
| |
| /// Casts all elements of `self` to `f32`. |
| #[inline] |
| pub fn as_vec3a(&self) -> crate::Vec3A { |
| crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32) |
| } |
| |
| /// Casts all elements of `self` to `f64`. |
| #[inline] |
| pub fn as_dvec3(&self) -> crate::DVec3 { |
| crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64) |
| } |
| |
| /// Casts all elements of `self` to `i32`. |
| #[inline] |
| pub fn as_ivec3(&self) -> crate::IVec3 { |
| crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32) |
| } |
| } |
| |
| impl Default for UVec3 { |
| #[inline(always)] |
| fn default() -> Self { |
| Self::ZERO |
| } |
| } |
| |
| impl Div<UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn div(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.div(rhs.x), |
| y: self.y.div(rhs.y), |
| z: self.z.div(rhs.z), |
| } |
| } |
| } |
| |
| impl DivAssign<UVec3> for UVec3 { |
| #[inline] |
| fn div_assign(&mut self, rhs: Self) { |
| self.x.div_assign(rhs.x); |
| self.y.div_assign(rhs.y); |
| self.z.div_assign(rhs.z); |
| } |
| } |
| |
| impl Div<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn div(self, rhs: u32) -> Self { |
| Self { |
| x: self.x.div(rhs), |
| y: self.y.div(rhs), |
| z: self.z.div(rhs), |
| } |
| } |
| } |
| |
| impl DivAssign<u32> for UVec3 { |
| #[inline] |
| fn div_assign(&mut self, rhs: u32) { |
| self.x.div_assign(rhs); |
| self.y.div_assign(rhs); |
| self.z.div_assign(rhs); |
| } |
| } |
| |
| impl Div<UVec3> for u32 { |
| type Output = UVec3; |
| #[inline] |
| fn div(self, rhs: UVec3) -> UVec3 { |
| UVec3 { |
| x: self.div(rhs.x), |
| y: self.div(rhs.y), |
| z: self.div(rhs.z), |
| } |
| } |
| } |
| |
| impl Mul<UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn mul(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.mul(rhs.x), |
| y: self.y.mul(rhs.y), |
| z: self.z.mul(rhs.z), |
| } |
| } |
| } |
| |
| impl MulAssign<UVec3> for UVec3 { |
| #[inline] |
| fn mul_assign(&mut self, rhs: Self) { |
| self.x.mul_assign(rhs.x); |
| self.y.mul_assign(rhs.y); |
| self.z.mul_assign(rhs.z); |
| } |
| } |
| |
| impl Mul<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn mul(self, rhs: u32) -> Self { |
| Self { |
| x: self.x.mul(rhs), |
| y: self.y.mul(rhs), |
| z: self.z.mul(rhs), |
| } |
| } |
| } |
| |
| impl MulAssign<u32> for UVec3 { |
| #[inline] |
| fn mul_assign(&mut self, rhs: u32) { |
| self.x.mul_assign(rhs); |
| self.y.mul_assign(rhs); |
| self.z.mul_assign(rhs); |
| } |
| } |
| |
| impl Mul<UVec3> for u32 { |
| type Output = UVec3; |
| #[inline] |
| fn mul(self, rhs: UVec3) -> UVec3 { |
| UVec3 { |
| x: self.mul(rhs.x), |
| y: self.mul(rhs.y), |
| z: self.mul(rhs.z), |
| } |
| } |
| } |
| |
| impl Add<UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn add(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.add(rhs.x), |
| y: self.y.add(rhs.y), |
| z: self.z.add(rhs.z), |
| } |
| } |
| } |
| |
| impl AddAssign<UVec3> for UVec3 { |
| #[inline] |
| fn add_assign(&mut self, rhs: Self) { |
| self.x.add_assign(rhs.x); |
| self.y.add_assign(rhs.y); |
| self.z.add_assign(rhs.z); |
| } |
| } |
| |
| impl Add<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn add(self, rhs: u32) -> Self { |
| Self { |
| x: self.x.add(rhs), |
| y: self.y.add(rhs), |
| z: self.z.add(rhs), |
| } |
| } |
| } |
| |
| impl AddAssign<u32> for UVec3 { |
| #[inline] |
| fn add_assign(&mut self, rhs: u32) { |
| self.x.add_assign(rhs); |
| self.y.add_assign(rhs); |
| self.z.add_assign(rhs); |
| } |
| } |
| |
| impl Add<UVec3> for u32 { |
| type Output = UVec3; |
| #[inline] |
| fn add(self, rhs: UVec3) -> UVec3 { |
| UVec3 { |
| x: self.add(rhs.x), |
| y: self.add(rhs.y), |
| z: self.add(rhs.z), |
| } |
| } |
| } |
| |
| impl Sub<UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn sub(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.sub(rhs.x), |
| y: self.y.sub(rhs.y), |
| z: self.z.sub(rhs.z), |
| } |
| } |
| } |
| |
| impl SubAssign<UVec3> for UVec3 { |
| #[inline] |
| fn sub_assign(&mut self, rhs: UVec3) { |
| self.x.sub_assign(rhs.x); |
| self.y.sub_assign(rhs.y); |
| self.z.sub_assign(rhs.z); |
| } |
| } |
| |
| impl Sub<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn sub(self, rhs: u32) -> Self { |
| Self { |
| x: self.x.sub(rhs), |
| y: self.y.sub(rhs), |
| z: self.z.sub(rhs), |
| } |
| } |
| } |
| |
| impl SubAssign<u32> for UVec3 { |
| #[inline] |
| fn sub_assign(&mut self, rhs: u32) { |
| self.x.sub_assign(rhs); |
| self.y.sub_assign(rhs); |
| self.z.sub_assign(rhs); |
| } |
| } |
| |
| impl Sub<UVec3> for u32 { |
| type Output = UVec3; |
| #[inline] |
| fn sub(self, rhs: UVec3) -> UVec3 { |
| UVec3 { |
| x: self.sub(rhs.x), |
| y: self.sub(rhs.y), |
| z: self.sub(rhs.z), |
| } |
| } |
| } |
| |
| impl Rem<UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn rem(self, rhs: Self) -> Self { |
| Self { |
| x: self.x.rem(rhs.x), |
| y: self.y.rem(rhs.y), |
| z: self.z.rem(rhs.z), |
| } |
| } |
| } |
| |
| impl RemAssign<UVec3> for UVec3 { |
| #[inline] |
| fn rem_assign(&mut self, rhs: Self) { |
| self.x.rem_assign(rhs.x); |
| self.y.rem_assign(rhs.y); |
| self.z.rem_assign(rhs.z); |
| } |
| } |
| |
| impl Rem<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn rem(self, rhs: u32) -> Self { |
| Self { |
| x: self.x.rem(rhs), |
| y: self.y.rem(rhs), |
| z: self.z.rem(rhs), |
| } |
| } |
| } |
| |
| impl RemAssign<u32> for UVec3 { |
| #[inline] |
| fn rem_assign(&mut self, rhs: u32) { |
| self.x.rem_assign(rhs); |
| self.y.rem_assign(rhs); |
| self.z.rem_assign(rhs); |
| } |
| } |
| |
| impl Rem<UVec3> for u32 { |
| type Output = UVec3; |
| #[inline] |
| fn rem(self, rhs: UVec3) -> UVec3 { |
| UVec3 { |
| x: self.rem(rhs.x), |
| y: self.rem(rhs.y), |
| z: self.rem(rhs.z), |
| } |
| } |
| } |
| |
| #[cfg(not(target_arch = "spirv"))] |
| impl AsRef<[u32; 3]> for UVec3 { |
| #[inline] |
| fn as_ref(&self) -> &[u32; 3] { |
| unsafe { &*(self as *const UVec3 as *const [u32; 3]) } |
| } |
| } |
| |
| #[cfg(not(target_arch = "spirv"))] |
| impl AsMut<[u32; 3]> for UVec3 { |
| #[inline] |
| fn as_mut(&mut self) -> &mut [u32; 3] { |
| unsafe { &mut *(self as *mut UVec3 as *mut [u32; 3]) } |
| } |
| } |
| |
| impl Sum for UVec3 { |
| #[inline] |
| fn sum<I>(iter: I) -> Self |
| where |
| I: Iterator<Item = Self>, |
| { |
| iter.fold(Self::ZERO, Self::add) |
| } |
| } |
| |
| impl<'a> Sum<&'a Self> for UVec3 { |
| #[inline] |
| fn sum<I>(iter: I) -> Self |
| where |
| I: Iterator<Item = &'a Self>, |
| { |
| iter.fold(Self::ZERO, |a, &b| Self::add(a, b)) |
| } |
| } |
| |
| impl Product for UVec3 { |
| #[inline] |
| fn product<I>(iter: I) -> Self |
| where |
| I: Iterator<Item = Self>, |
| { |
| iter.fold(Self::ONE, Self::mul) |
| } |
| } |
| |
| impl<'a> Product<&'a Self> for UVec3 { |
| #[inline] |
| fn product<I>(iter: I) -> Self |
| where |
| I: Iterator<Item = &'a Self>, |
| { |
| iter.fold(Self::ONE, |a, &b| Self::mul(a, b)) |
| } |
| } |
| |
| impl Not for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn not(self) -> Self::Output { |
| Self { |
| x: self.x.not(), |
| y: self.y.not(), |
| z: self.z.not(), |
| } |
| } |
| } |
| |
| impl BitAnd for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitand(self, rhs: Self) -> Self::Output { |
| Self { |
| x: self.x.bitand(rhs.x), |
| y: self.y.bitand(rhs.y), |
| z: self.z.bitand(rhs.z), |
| } |
| } |
| } |
| |
| impl BitOr for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitor(self, rhs: Self) -> Self::Output { |
| Self { |
| x: self.x.bitor(rhs.x), |
| y: self.y.bitor(rhs.y), |
| z: self.z.bitor(rhs.z), |
| } |
| } |
| } |
| |
| impl BitXor for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitxor(self, rhs: Self) -> Self::Output { |
| Self { |
| x: self.x.bitxor(rhs.x), |
| y: self.y.bitxor(rhs.y), |
| z: self.z.bitxor(rhs.z), |
| } |
| } |
| } |
| |
| impl BitAnd<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitand(self, rhs: u32) -> Self::Output { |
| Self { |
| x: self.x.bitand(rhs), |
| y: self.y.bitand(rhs), |
| z: self.z.bitand(rhs), |
| } |
| } |
| } |
| |
| impl BitOr<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitor(self, rhs: u32) -> Self::Output { |
| Self { |
| x: self.x.bitor(rhs), |
| y: self.y.bitor(rhs), |
| z: self.z.bitor(rhs), |
| } |
| } |
| } |
| |
| impl BitXor<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn bitxor(self, rhs: u32) -> Self::Output { |
| Self { |
| x: self.x.bitxor(rhs), |
| y: self.y.bitxor(rhs), |
| z: self.z.bitxor(rhs), |
| } |
| } |
| } |
| |
| impl Shl<i8> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: i8) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<i8> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: i8) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<i16> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: i16) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<i16> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: i16) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<i32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: i32) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<i32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: i32) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<u8> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: u8) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<u8> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: u8) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<u16> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: u16) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<u16> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: u16) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: u32) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs), |
| y: self.y.shl(rhs), |
| z: self.z.shl(rhs), |
| } |
| } |
| } |
| |
| impl Shr<u32> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: u32) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs), |
| y: self.y.shr(rhs), |
| z: self.z.shr(rhs), |
| } |
| } |
| } |
| |
| impl Shl<crate::IVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: crate::IVec3) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs.x), |
| y: self.y.shl(rhs.y), |
| z: self.z.shl(rhs.z), |
| } |
| } |
| } |
| |
| impl Shr<crate::IVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: crate::IVec3) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs.x), |
| y: self.y.shr(rhs.y), |
| z: self.z.shr(rhs.z), |
| } |
| } |
| } |
| |
| impl Shl<crate::UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shl(self, rhs: crate::UVec3) -> Self::Output { |
| Self { |
| x: self.x.shl(rhs.x), |
| y: self.y.shl(rhs.y), |
| z: self.z.shl(rhs.z), |
| } |
| } |
| } |
| |
| impl Shr<crate::UVec3> for UVec3 { |
| type Output = Self; |
| #[inline] |
| fn shr(self, rhs: crate::UVec3) -> Self::Output { |
| Self { |
| x: self.x.shr(rhs.x), |
| y: self.y.shr(rhs.y), |
| z: self.z.shr(rhs.z), |
| } |
| } |
| } |
| |
| impl Index<usize> for UVec3 { |
| type Output = u32; |
| #[inline] |
| fn index(&self, index: usize) -> &Self::Output { |
| match index { |
| 0 => &self.x, |
| 1 => &self.y, |
| 2 => &self.z, |
| _ => panic!("index out of bounds"), |
| } |
| } |
| } |
| |
| impl IndexMut<usize> for UVec3 { |
| #[inline] |
| fn index_mut(&mut self, index: usize) -> &mut Self::Output { |
| match index { |
| 0 => &mut self.x, |
| 1 => &mut self.y, |
| 2 => &mut self.z, |
| _ => panic!("index out of bounds"), |
| } |
| } |
| } |
| |
| #[cfg(not(target_arch = "spirv"))] |
| impl fmt::Display for UVec3 { |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| write!(f, "[{}, {}, {}]", self.x, self.y, self.z) |
| } |
| } |
| |
| #[cfg(not(target_arch = "spirv"))] |
| impl fmt::Debug for UVec3 { |
| fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { |
| fmt.debug_tuple(stringify!(UVec3)) |
| .field(&self.x) |
| .field(&self.y) |
| .field(&self.z) |
| .finish() |
| } |
| } |
| |
| impl From<[u32; 3]> for UVec3 { |
| #[inline] |
| fn from(a: [u32; 3]) -> Self { |
| Self::new(a[0], a[1], a[2]) |
| } |
| } |
| |
| impl From<UVec3> for [u32; 3] { |
| #[inline] |
| fn from(v: UVec3) -> Self { |
| [v.x, v.y, v.z] |
| } |
| } |
| |
| impl From<(u32, u32, u32)> for UVec3 { |
| #[inline] |
| fn from(t: (u32, u32, u32)) -> Self { |
| Self::new(t.0, t.1, t.2) |
| } |
| } |
| |
| impl From<UVec3> for (u32, u32, u32) { |
| #[inline] |
| fn from(v: UVec3) -> Self { |
| (v.x, v.y, v.z) |
| } |
| } |
| |
| impl From<(UVec2, u32)> for UVec3 { |
| #[inline] |
| fn from((v, z): (UVec2, u32)) -> Self { |
| Self::new(v.x, v.y, z) |
| } |
| } |