1use crate::{
4 BVec3, BVec3A, I16Vec3, I64Vec3, I8Vec3, IVec3, U16Vec3, U64Vec3, U8Vec3, USizeVec3, UVec2,
5 UVec4,
6};
7
8use core::fmt;
9use core::iter::{Product, Sum};
10use core::{f32, ops::*};
11
12#[inline(always)]
14#[must_use]
15pub const fn uvec3(x: u32, y: u32, z: u32) -> UVec3 {
16 UVec3::new(x, y, z)
17}
18
19#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
21#[derive(Clone, Copy, PartialEq, Eq)]
22#[cfg_attr(not(target_arch = "spirv"), repr(C))]
23#[cfg_attr(target_arch = "spirv", repr(simd))]
24pub struct UVec3 {
25 pub x: u32,
26 pub y: u32,
27 pub z: u32,
28}
29
30impl UVec3 {
31 pub const ZERO: Self = Self::splat(0);
33
34 pub const ONE: Self = Self::splat(1);
36
37 pub const MIN: Self = Self::splat(u32::MIN);
39
40 pub const MAX: Self = Self::splat(u32::MAX);
42
43 pub const X: Self = Self::new(1, 0, 0);
45
46 pub const Y: Self = Self::new(0, 1, 0);
48
49 pub const Z: Self = Self::new(0, 0, 1);
51
52 pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
54
55 #[inline(always)]
57 #[must_use]
58 pub const fn new(x: u32, y: u32, z: u32) -> Self {
59 Self { x, y, z }
60 }
61
62 #[inline]
64 #[must_use]
65 pub const fn splat(v: u32) -> Self {
66 Self { x: v, y: v, z: v }
67 }
68
69 #[inline]
71 #[must_use]
72 pub fn map<F>(self, f: F) -> Self
73 where
74 F: Fn(u32) -> u32,
75 {
76 Self::new(f(self.x), f(self.y), f(self.z))
77 }
78
79 #[inline]
85 #[must_use]
86 pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
87 Self {
88 x: if mask.test(0) { if_true.x } else { if_false.x },
89 y: if mask.test(1) { if_true.y } else { if_false.y },
90 z: if mask.test(2) { if_true.z } else { if_false.z },
91 }
92 }
93
94 #[inline]
96 #[must_use]
97 pub const fn from_array(a: [u32; 3]) -> Self {
98 Self::new(a[0], a[1], a[2])
99 }
100
101 #[inline]
103 #[must_use]
104 pub const fn to_array(&self) -> [u32; 3] {
105 [self.x, self.y, self.z]
106 }
107
108 #[inline]
114 #[must_use]
115 pub const fn from_slice(slice: &[u32]) -> Self {
116 assert!(slice.len() >= 3);
117 Self::new(slice[0], slice[1], slice[2])
118 }
119
120 #[inline]
126 pub fn write_to_slice(self, slice: &mut [u32]) {
127 slice[..3].copy_from_slice(&self.to_array());
128 }
129
130 #[allow(dead_code)]
132 #[inline]
133 #[must_use]
134 pub(crate) fn from_vec4(v: UVec4) -> Self {
135 Self {
136 x: v.x,
137 y: v.y,
138 z: v.z,
139 }
140 }
141
142 #[inline]
144 #[must_use]
145 pub fn extend(self, w: u32) -> UVec4 {
146 UVec4::new(self.x, self.y, self.z, w)
147 }
148
149 #[inline]
153 #[must_use]
154 pub fn truncate(self) -> UVec2 {
155 use crate::swizzles::Vec3Swizzles;
156 self.xy()
157 }
158
159 #[inline]
161 #[must_use]
162 pub fn with_x(mut self, x: u32) -> Self {
163 self.x = x;
164 self
165 }
166
167 #[inline]
169 #[must_use]
170 pub fn with_y(mut self, y: u32) -> Self {
171 self.y = y;
172 self
173 }
174
175 #[inline]
177 #[must_use]
178 pub fn with_z(mut self, z: u32) -> Self {
179 self.z = z;
180 self
181 }
182
183 #[inline]
185 #[must_use]
186 pub fn dot(self, rhs: Self) -> u32 {
187 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
188 }
189
190 #[inline]
192 #[must_use]
193 pub fn dot_into_vec(self, rhs: Self) -> Self {
194 Self::splat(self.dot(rhs))
195 }
196
197 #[inline]
199 #[must_use]
200 pub fn cross(self, rhs: Self) -> Self {
201 Self {
202 x: self.y * rhs.z - rhs.y * self.z,
203 y: self.z * rhs.x - rhs.z * self.x,
204 z: self.x * rhs.y - rhs.x * self.y,
205 }
206 }
207
208 #[inline]
212 #[must_use]
213 pub fn min(self, rhs: Self) -> Self {
214 Self {
215 x: if self.x < rhs.x { self.x } else { rhs.x },
216 y: if self.y < rhs.y { self.y } else { rhs.y },
217 z: if self.z < rhs.z { self.z } else { rhs.z },
218 }
219 }
220
221 #[inline]
225 #[must_use]
226 pub fn max(self, rhs: Self) -> Self {
227 Self {
228 x: if self.x > rhs.x { self.x } else { rhs.x },
229 y: if self.y > rhs.y { self.y } else { rhs.y },
230 z: if self.z > rhs.z { self.z } else { rhs.z },
231 }
232 }
233
234 #[inline]
242 #[must_use]
243 pub fn clamp(self, min: Self, max: Self) -> Self {
244 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
245 self.max(min).min(max)
246 }
247
248 #[inline]
252 #[must_use]
253 pub fn min_element(self) -> u32 {
254 let min = |a, b| if a < b { a } else { b };
255 min(self.x, min(self.y, self.z))
256 }
257
258 #[inline]
262 #[must_use]
263 pub fn max_element(self) -> u32 {
264 let max = |a, b| if a > b { a } else { b };
265 max(self.x, max(self.y, self.z))
266 }
267
268 #[doc(alias = "argmin")]
270 #[inline]
271 #[must_use]
272 pub fn min_position(self) -> usize {
273 let mut min = self.x;
274 let mut index = 0;
275 if self.y < min {
276 min = self.y;
277 index = 1;
278 }
279 if self.z < min {
280 index = 2;
281 }
282 index
283 }
284
285 #[doc(alias = "argmax")]
287 #[inline]
288 #[must_use]
289 pub fn max_position(self) -> usize {
290 let mut max = self.x;
291 let mut index = 0;
292 if self.y > max {
293 max = self.y;
294 index = 1;
295 }
296 if self.z > max {
297 index = 2;
298 }
299 index
300 }
301
302 #[inline]
306 #[must_use]
307 pub fn element_sum(self) -> u32 {
308 self.x + self.y + self.z
309 }
310
311 #[inline]
315 #[must_use]
316 pub fn element_product(self) -> u32 {
317 self.x * self.y * self.z
318 }
319
320 #[inline]
326 #[must_use]
327 pub fn cmpeq(self, rhs: Self) -> BVec3 {
328 BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
329 }
330
331 #[inline]
337 #[must_use]
338 pub fn cmpne(self, rhs: Self) -> BVec3 {
339 BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
340 }
341
342 #[inline]
348 #[must_use]
349 pub fn cmpge(self, rhs: Self) -> BVec3 {
350 BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
351 }
352
353 #[inline]
359 #[must_use]
360 pub fn cmpgt(self, rhs: Self) -> BVec3 {
361 BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
362 }
363
364 #[inline]
370 #[must_use]
371 pub fn cmple(self, rhs: Self) -> BVec3 {
372 BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
373 }
374
375 #[inline]
381 #[must_use]
382 pub fn cmplt(self, rhs: Self) -> BVec3 {
383 BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
384 }
385
386 #[doc(alias = "magnitude2")]
388 #[inline]
389 #[must_use]
390 pub fn length_squared(self) -> u32 {
391 self.dot(self)
392 }
393
394 #[inline]
403 #[must_use]
404 pub fn manhattan_distance(self, other: Self) -> u32 {
405 self.x.abs_diff(other.x) + self.y.abs_diff(other.y) + self.z.abs_diff(other.z)
406 }
407
408 #[inline]
414 #[must_use]
415 pub fn checked_manhattan_distance(self, other: Self) -> Option<u32> {
416 let d = self.x.abs_diff(other.x);
417 let d = d.checked_add(self.y.abs_diff(other.y))?;
418 d.checked_add(self.z.abs_diff(other.z))
419 }
420
421 #[inline]
425 #[must_use]
426 pub fn chebyshev_distance(self, other: Self) -> u32 {
427 [
429 self.x.abs_diff(other.x),
430 self.y.abs_diff(other.y),
431 self.z.abs_diff(other.z),
432 ]
433 .into_iter()
434 .max()
435 .unwrap()
436 }
437
438 #[inline]
440 #[must_use]
441 pub fn as_vec3(&self) -> crate::Vec3 {
442 crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
443 }
444
445 #[inline]
447 #[must_use]
448 pub fn as_vec3a(&self) -> crate::Vec3A {
449 crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
450 }
451
452 #[inline]
454 #[must_use]
455 pub fn as_dvec3(&self) -> crate::DVec3 {
456 crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
457 }
458
459 #[inline]
461 #[must_use]
462 pub fn as_i8vec3(&self) -> crate::I8Vec3 {
463 crate::I8Vec3::new(self.x as i8, self.y as i8, self.z as i8)
464 }
465
466 #[inline]
468 #[must_use]
469 pub fn as_u8vec3(&self) -> crate::U8Vec3 {
470 crate::U8Vec3::new(self.x as u8, self.y as u8, self.z as u8)
471 }
472
473 #[inline]
475 #[must_use]
476 pub fn as_i16vec3(&self) -> crate::I16Vec3 {
477 crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
478 }
479
480 #[inline]
482 #[must_use]
483 pub fn as_u16vec3(&self) -> crate::U16Vec3 {
484 crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
485 }
486
487 #[inline]
489 #[must_use]
490 pub fn as_ivec3(&self) -> crate::IVec3 {
491 crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
492 }
493
494 #[inline]
496 #[must_use]
497 pub fn as_i64vec3(&self) -> crate::I64Vec3 {
498 crate::I64Vec3::new(self.x as i64, self.y as i64, self.z as i64)
499 }
500
501 #[inline]
503 #[must_use]
504 pub fn as_u64vec3(&self) -> crate::U64Vec3 {
505 crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
506 }
507
508 #[inline]
510 #[must_use]
511 pub fn as_usizevec3(&self) -> crate::USizeVec3 {
512 crate::USizeVec3::new(self.x as usize, self.y as usize, self.z as usize)
513 }
514
515 #[inline]
519 #[must_use]
520 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
521 let x = match self.x.checked_add(rhs.x) {
522 Some(v) => v,
523 None => return None,
524 };
525 let y = match self.y.checked_add(rhs.y) {
526 Some(v) => v,
527 None => return None,
528 };
529 let z = match self.z.checked_add(rhs.z) {
530 Some(v) => v,
531 None => return None,
532 };
533
534 Some(Self { x, y, z })
535 }
536
537 #[inline]
541 #[must_use]
542 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
543 let x = match self.x.checked_sub(rhs.x) {
544 Some(v) => v,
545 None => return None,
546 };
547 let y = match self.y.checked_sub(rhs.y) {
548 Some(v) => v,
549 None => return None,
550 };
551 let z = match self.z.checked_sub(rhs.z) {
552 Some(v) => v,
553 None => return None,
554 };
555
556 Some(Self { x, y, z })
557 }
558
559 #[inline]
563 #[must_use]
564 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
565 let x = match self.x.checked_mul(rhs.x) {
566 Some(v) => v,
567 None => return None,
568 };
569 let y = match self.y.checked_mul(rhs.y) {
570 Some(v) => v,
571 None => return None,
572 };
573 let z = match self.z.checked_mul(rhs.z) {
574 Some(v) => v,
575 None => return None,
576 };
577
578 Some(Self { x, y, z })
579 }
580
581 #[inline]
585 #[must_use]
586 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
587 let x = match self.x.checked_div(rhs.x) {
588 Some(v) => v,
589 None => return None,
590 };
591 let y = match self.y.checked_div(rhs.y) {
592 Some(v) => v,
593 None => return None,
594 };
595 let z = match self.z.checked_div(rhs.z) {
596 Some(v) => v,
597 None => return None,
598 };
599
600 Some(Self { x, y, z })
601 }
602
603 #[inline]
607 #[must_use]
608 pub const fn wrapping_add(self, rhs: Self) -> Self {
609 Self {
610 x: self.x.wrapping_add(rhs.x),
611 y: self.y.wrapping_add(rhs.y),
612 z: self.z.wrapping_add(rhs.z),
613 }
614 }
615
616 #[inline]
620 #[must_use]
621 pub const fn wrapping_sub(self, rhs: Self) -> Self {
622 Self {
623 x: self.x.wrapping_sub(rhs.x),
624 y: self.y.wrapping_sub(rhs.y),
625 z: self.z.wrapping_sub(rhs.z),
626 }
627 }
628
629 #[inline]
633 #[must_use]
634 pub const fn wrapping_mul(self, rhs: Self) -> Self {
635 Self {
636 x: self.x.wrapping_mul(rhs.x),
637 y: self.y.wrapping_mul(rhs.y),
638 z: self.z.wrapping_mul(rhs.z),
639 }
640 }
641
642 #[inline]
646 #[must_use]
647 pub const fn wrapping_div(self, rhs: Self) -> Self {
648 Self {
649 x: self.x.wrapping_div(rhs.x),
650 y: self.y.wrapping_div(rhs.y),
651 z: self.z.wrapping_div(rhs.z),
652 }
653 }
654
655 #[inline]
659 #[must_use]
660 pub const fn saturating_add(self, rhs: Self) -> Self {
661 Self {
662 x: self.x.saturating_add(rhs.x),
663 y: self.y.saturating_add(rhs.y),
664 z: self.z.saturating_add(rhs.z),
665 }
666 }
667
668 #[inline]
672 #[must_use]
673 pub const fn saturating_sub(self, rhs: Self) -> Self {
674 Self {
675 x: self.x.saturating_sub(rhs.x),
676 y: self.y.saturating_sub(rhs.y),
677 z: self.z.saturating_sub(rhs.z),
678 }
679 }
680
681 #[inline]
685 #[must_use]
686 pub const fn saturating_mul(self, rhs: Self) -> Self {
687 Self {
688 x: self.x.saturating_mul(rhs.x),
689 y: self.y.saturating_mul(rhs.y),
690 z: self.z.saturating_mul(rhs.z),
691 }
692 }
693
694 #[inline]
698 #[must_use]
699 pub const fn saturating_div(self, rhs: Self) -> Self {
700 Self {
701 x: self.x.saturating_div(rhs.x),
702 y: self.y.saturating_div(rhs.y),
703 z: self.z.saturating_div(rhs.z),
704 }
705 }
706
707 #[inline]
711 #[must_use]
712 pub const fn checked_add_signed(self, rhs: IVec3) -> Option<Self> {
713 let x = match self.x.checked_add_signed(rhs.x) {
714 Some(v) => v,
715 None => return None,
716 };
717 let y = match self.y.checked_add_signed(rhs.y) {
718 Some(v) => v,
719 None => return None,
720 };
721 let z = match self.z.checked_add_signed(rhs.z) {
722 Some(v) => v,
723 None => return None,
724 };
725
726 Some(Self { x, y, z })
727 }
728
729 #[inline]
733 #[must_use]
734 pub const fn wrapping_add_signed(self, rhs: IVec3) -> Self {
735 Self {
736 x: self.x.wrapping_add_signed(rhs.x),
737 y: self.y.wrapping_add_signed(rhs.y),
738 z: self.z.wrapping_add_signed(rhs.z),
739 }
740 }
741
742 #[inline]
746 #[must_use]
747 pub const fn saturating_add_signed(self, rhs: IVec3) -> Self {
748 Self {
749 x: self.x.saturating_add_signed(rhs.x),
750 y: self.y.saturating_add_signed(rhs.y),
751 z: self.z.saturating_add_signed(rhs.z),
752 }
753 }
754}
755
756impl Default for UVec3 {
757 #[inline(always)]
758 fn default() -> Self {
759 Self::ZERO
760 }
761}
762
763impl Div<UVec3> for UVec3 {
764 type Output = Self;
765 #[inline]
766 fn div(self, rhs: Self) -> Self {
767 Self {
768 x: self.x.div(rhs.x),
769 y: self.y.div(rhs.y),
770 z: self.z.div(rhs.z),
771 }
772 }
773}
774
775impl Div<&UVec3> for UVec3 {
776 type Output = UVec3;
777 #[inline]
778 fn div(self, rhs: &UVec3) -> UVec3 {
779 self.div(*rhs)
780 }
781}
782
783impl Div<&UVec3> for &UVec3 {
784 type Output = UVec3;
785 #[inline]
786 fn div(self, rhs: &UVec3) -> UVec3 {
787 (*self).div(*rhs)
788 }
789}
790
791impl Div<UVec3> for &UVec3 {
792 type Output = UVec3;
793 #[inline]
794 fn div(self, rhs: UVec3) -> UVec3 {
795 (*self).div(rhs)
796 }
797}
798
799impl DivAssign<UVec3> for UVec3 {
800 #[inline]
801 fn div_assign(&mut self, rhs: Self) {
802 self.x.div_assign(rhs.x);
803 self.y.div_assign(rhs.y);
804 self.z.div_assign(rhs.z);
805 }
806}
807
808impl DivAssign<&UVec3> for UVec3 {
809 #[inline]
810 fn div_assign(&mut self, rhs: &UVec3) {
811 self.div_assign(*rhs)
812 }
813}
814
815impl Div<u32> for UVec3 {
816 type Output = Self;
817 #[inline]
818 fn div(self, rhs: u32) -> Self {
819 Self {
820 x: self.x.div(rhs),
821 y: self.y.div(rhs),
822 z: self.z.div(rhs),
823 }
824 }
825}
826
827impl Div<&u32> for UVec3 {
828 type Output = UVec3;
829 #[inline]
830 fn div(self, rhs: &u32) -> UVec3 {
831 self.div(*rhs)
832 }
833}
834
835impl Div<&u32> for &UVec3 {
836 type Output = UVec3;
837 #[inline]
838 fn div(self, rhs: &u32) -> UVec3 {
839 (*self).div(*rhs)
840 }
841}
842
843impl Div<u32> for &UVec3 {
844 type Output = UVec3;
845 #[inline]
846 fn div(self, rhs: u32) -> UVec3 {
847 (*self).div(rhs)
848 }
849}
850
851impl DivAssign<u32> for UVec3 {
852 #[inline]
853 fn div_assign(&mut self, rhs: u32) {
854 self.x.div_assign(rhs);
855 self.y.div_assign(rhs);
856 self.z.div_assign(rhs);
857 }
858}
859
860impl DivAssign<&u32> for UVec3 {
861 #[inline]
862 fn div_assign(&mut self, rhs: &u32) {
863 self.div_assign(*rhs)
864 }
865}
866
867impl Div<UVec3> for u32 {
868 type Output = UVec3;
869 #[inline]
870 fn div(self, rhs: UVec3) -> UVec3 {
871 UVec3 {
872 x: self.div(rhs.x),
873 y: self.div(rhs.y),
874 z: self.div(rhs.z),
875 }
876 }
877}
878
879impl Div<&UVec3> for u32 {
880 type Output = UVec3;
881 #[inline]
882 fn div(self, rhs: &UVec3) -> UVec3 {
883 self.div(*rhs)
884 }
885}
886
887impl Div<&UVec3> for &u32 {
888 type Output = UVec3;
889 #[inline]
890 fn div(self, rhs: &UVec3) -> UVec3 {
891 (*self).div(*rhs)
892 }
893}
894
895impl Div<UVec3> for &u32 {
896 type Output = UVec3;
897 #[inline]
898 fn div(self, rhs: UVec3) -> UVec3 {
899 (*self).div(rhs)
900 }
901}
902
903impl Mul<UVec3> for UVec3 {
904 type Output = Self;
905 #[inline]
906 fn mul(self, rhs: Self) -> Self {
907 Self {
908 x: self.x.mul(rhs.x),
909 y: self.y.mul(rhs.y),
910 z: self.z.mul(rhs.z),
911 }
912 }
913}
914
915impl Mul<&UVec3> for UVec3 {
916 type Output = UVec3;
917 #[inline]
918 fn mul(self, rhs: &UVec3) -> UVec3 {
919 self.mul(*rhs)
920 }
921}
922
923impl Mul<&UVec3> for &UVec3 {
924 type Output = UVec3;
925 #[inline]
926 fn mul(self, rhs: &UVec3) -> UVec3 {
927 (*self).mul(*rhs)
928 }
929}
930
931impl Mul<UVec3> for &UVec3 {
932 type Output = UVec3;
933 #[inline]
934 fn mul(self, rhs: UVec3) -> UVec3 {
935 (*self).mul(rhs)
936 }
937}
938
939impl MulAssign<UVec3> for UVec3 {
940 #[inline]
941 fn mul_assign(&mut self, rhs: Self) {
942 self.x.mul_assign(rhs.x);
943 self.y.mul_assign(rhs.y);
944 self.z.mul_assign(rhs.z);
945 }
946}
947
948impl MulAssign<&UVec3> for UVec3 {
949 #[inline]
950 fn mul_assign(&mut self, rhs: &UVec3) {
951 self.mul_assign(*rhs)
952 }
953}
954
955impl Mul<u32> for UVec3 {
956 type Output = Self;
957 #[inline]
958 fn mul(self, rhs: u32) -> Self {
959 Self {
960 x: self.x.mul(rhs),
961 y: self.y.mul(rhs),
962 z: self.z.mul(rhs),
963 }
964 }
965}
966
967impl Mul<&u32> for UVec3 {
968 type Output = UVec3;
969 #[inline]
970 fn mul(self, rhs: &u32) -> UVec3 {
971 self.mul(*rhs)
972 }
973}
974
975impl Mul<&u32> for &UVec3 {
976 type Output = UVec3;
977 #[inline]
978 fn mul(self, rhs: &u32) -> UVec3 {
979 (*self).mul(*rhs)
980 }
981}
982
983impl Mul<u32> for &UVec3 {
984 type Output = UVec3;
985 #[inline]
986 fn mul(self, rhs: u32) -> UVec3 {
987 (*self).mul(rhs)
988 }
989}
990
991impl MulAssign<u32> for UVec3 {
992 #[inline]
993 fn mul_assign(&mut self, rhs: u32) {
994 self.x.mul_assign(rhs);
995 self.y.mul_assign(rhs);
996 self.z.mul_assign(rhs);
997 }
998}
999
1000impl MulAssign<&u32> for UVec3 {
1001 #[inline]
1002 fn mul_assign(&mut self, rhs: &u32) {
1003 self.mul_assign(*rhs)
1004 }
1005}
1006
1007impl Mul<UVec3> for u32 {
1008 type Output = UVec3;
1009 #[inline]
1010 fn mul(self, rhs: UVec3) -> UVec3 {
1011 UVec3 {
1012 x: self.mul(rhs.x),
1013 y: self.mul(rhs.y),
1014 z: self.mul(rhs.z),
1015 }
1016 }
1017}
1018
1019impl Mul<&UVec3> for u32 {
1020 type Output = UVec3;
1021 #[inline]
1022 fn mul(self, rhs: &UVec3) -> UVec3 {
1023 self.mul(*rhs)
1024 }
1025}
1026
1027impl Mul<&UVec3> for &u32 {
1028 type Output = UVec3;
1029 #[inline]
1030 fn mul(self, rhs: &UVec3) -> UVec3 {
1031 (*self).mul(*rhs)
1032 }
1033}
1034
1035impl Mul<UVec3> for &u32 {
1036 type Output = UVec3;
1037 #[inline]
1038 fn mul(self, rhs: UVec3) -> UVec3 {
1039 (*self).mul(rhs)
1040 }
1041}
1042
1043impl Add<UVec3> for UVec3 {
1044 type Output = Self;
1045 #[inline]
1046 fn add(self, rhs: Self) -> Self {
1047 Self {
1048 x: self.x.add(rhs.x),
1049 y: self.y.add(rhs.y),
1050 z: self.z.add(rhs.z),
1051 }
1052 }
1053}
1054
1055impl Add<&UVec3> for UVec3 {
1056 type Output = UVec3;
1057 #[inline]
1058 fn add(self, rhs: &UVec3) -> UVec3 {
1059 self.add(*rhs)
1060 }
1061}
1062
1063impl Add<&UVec3> for &UVec3 {
1064 type Output = UVec3;
1065 #[inline]
1066 fn add(self, rhs: &UVec3) -> UVec3 {
1067 (*self).add(*rhs)
1068 }
1069}
1070
1071impl Add<UVec3> for &UVec3 {
1072 type Output = UVec3;
1073 #[inline]
1074 fn add(self, rhs: UVec3) -> UVec3 {
1075 (*self).add(rhs)
1076 }
1077}
1078
1079impl AddAssign<UVec3> for UVec3 {
1080 #[inline]
1081 fn add_assign(&mut self, rhs: Self) {
1082 self.x.add_assign(rhs.x);
1083 self.y.add_assign(rhs.y);
1084 self.z.add_assign(rhs.z);
1085 }
1086}
1087
1088impl AddAssign<&UVec3> for UVec3 {
1089 #[inline]
1090 fn add_assign(&mut self, rhs: &UVec3) {
1091 self.add_assign(*rhs)
1092 }
1093}
1094
1095impl Add<u32> for UVec3 {
1096 type Output = Self;
1097 #[inline]
1098 fn add(self, rhs: u32) -> Self {
1099 Self {
1100 x: self.x.add(rhs),
1101 y: self.y.add(rhs),
1102 z: self.z.add(rhs),
1103 }
1104 }
1105}
1106
1107impl Add<&u32> for UVec3 {
1108 type Output = UVec3;
1109 #[inline]
1110 fn add(self, rhs: &u32) -> UVec3 {
1111 self.add(*rhs)
1112 }
1113}
1114
1115impl Add<&u32> for &UVec3 {
1116 type Output = UVec3;
1117 #[inline]
1118 fn add(self, rhs: &u32) -> UVec3 {
1119 (*self).add(*rhs)
1120 }
1121}
1122
1123impl Add<u32> for &UVec3 {
1124 type Output = UVec3;
1125 #[inline]
1126 fn add(self, rhs: u32) -> UVec3 {
1127 (*self).add(rhs)
1128 }
1129}
1130
1131impl AddAssign<u32> for UVec3 {
1132 #[inline]
1133 fn add_assign(&mut self, rhs: u32) {
1134 self.x.add_assign(rhs);
1135 self.y.add_assign(rhs);
1136 self.z.add_assign(rhs);
1137 }
1138}
1139
1140impl AddAssign<&u32> for UVec3 {
1141 #[inline]
1142 fn add_assign(&mut self, rhs: &u32) {
1143 self.add_assign(*rhs)
1144 }
1145}
1146
1147impl Add<UVec3> for u32 {
1148 type Output = UVec3;
1149 #[inline]
1150 fn add(self, rhs: UVec3) -> UVec3 {
1151 UVec3 {
1152 x: self.add(rhs.x),
1153 y: self.add(rhs.y),
1154 z: self.add(rhs.z),
1155 }
1156 }
1157}
1158
1159impl Add<&UVec3> for u32 {
1160 type Output = UVec3;
1161 #[inline]
1162 fn add(self, rhs: &UVec3) -> UVec3 {
1163 self.add(*rhs)
1164 }
1165}
1166
1167impl Add<&UVec3> for &u32 {
1168 type Output = UVec3;
1169 #[inline]
1170 fn add(self, rhs: &UVec3) -> UVec3 {
1171 (*self).add(*rhs)
1172 }
1173}
1174
1175impl Add<UVec3> for &u32 {
1176 type Output = UVec3;
1177 #[inline]
1178 fn add(self, rhs: UVec3) -> UVec3 {
1179 (*self).add(rhs)
1180 }
1181}
1182
1183impl Sub<UVec3> for UVec3 {
1184 type Output = Self;
1185 #[inline]
1186 fn sub(self, rhs: Self) -> Self {
1187 Self {
1188 x: self.x.sub(rhs.x),
1189 y: self.y.sub(rhs.y),
1190 z: self.z.sub(rhs.z),
1191 }
1192 }
1193}
1194
1195impl Sub<&UVec3> for UVec3 {
1196 type Output = UVec3;
1197 #[inline]
1198 fn sub(self, rhs: &UVec3) -> UVec3 {
1199 self.sub(*rhs)
1200 }
1201}
1202
1203impl Sub<&UVec3> for &UVec3 {
1204 type Output = UVec3;
1205 #[inline]
1206 fn sub(self, rhs: &UVec3) -> UVec3 {
1207 (*self).sub(*rhs)
1208 }
1209}
1210
1211impl Sub<UVec3> for &UVec3 {
1212 type Output = UVec3;
1213 #[inline]
1214 fn sub(self, rhs: UVec3) -> UVec3 {
1215 (*self).sub(rhs)
1216 }
1217}
1218
1219impl SubAssign<UVec3> for UVec3 {
1220 #[inline]
1221 fn sub_assign(&mut self, rhs: UVec3) {
1222 self.x.sub_assign(rhs.x);
1223 self.y.sub_assign(rhs.y);
1224 self.z.sub_assign(rhs.z);
1225 }
1226}
1227
1228impl SubAssign<&UVec3> for UVec3 {
1229 #[inline]
1230 fn sub_assign(&mut self, rhs: &UVec3) {
1231 self.sub_assign(*rhs)
1232 }
1233}
1234
1235impl Sub<u32> for UVec3 {
1236 type Output = Self;
1237 #[inline]
1238 fn sub(self, rhs: u32) -> Self {
1239 Self {
1240 x: self.x.sub(rhs),
1241 y: self.y.sub(rhs),
1242 z: self.z.sub(rhs),
1243 }
1244 }
1245}
1246
1247impl Sub<&u32> for UVec3 {
1248 type Output = UVec3;
1249 #[inline]
1250 fn sub(self, rhs: &u32) -> UVec3 {
1251 self.sub(*rhs)
1252 }
1253}
1254
1255impl Sub<&u32> for &UVec3 {
1256 type Output = UVec3;
1257 #[inline]
1258 fn sub(self, rhs: &u32) -> UVec3 {
1259 (*self).sub(*rhs)
1260 }
1261}
1262
1263impl Sub<u32> for &UVec3 {
1264 type Output = UVec3;
1265 #[inline]
1266 fn sub(self, rhs: u32) -> UVec3 {
1267 (*self).sub(rhs)
1268 }
1269}
1270
1271impl SubAssign<u32> for UVec3 {
1272 #[inline]
1273 fn sub_assign(&mut self, rhs: u32) {
1274 self.x.sub_assign(rhs);
1275 self.y.sub_assign(rhs);
1276 self.z.sub_assign(rhs);
1277 }
1278}
1279
1280impl SubAssign<&u32> for UVec3 {
1281 #[inline]
1282 fn sub_assign(&mut self, rhs: &u32) {
1283 self.sub_assign(*rhs)
1284 }
1285}
1286
1287impl Sub<UVec3> for u32 {
1288 type Output = UVec3;
1289 #[inline]
1290 fn sub(self, rhs: UVec3) -> UVec3 {
1291 UVec3 {
1292 x: self.sub(rhs.x),
1293 y: self.sub(rhs.y),
1294 z: self.sub(rhs.z),
1295 }
1296 }
1297}
1298
1299impl Sub<&UVec3> for u32 {
1300 type Output = UVec3;
1301 #[inline]
1302 fn sub(self, rhs: &UVec3) -> UVec3 {
1303 self.sub(*rhs)
1304 }
1305}
1306
1307impl Sub<&UVec3> for &u32 {
1308 type Output = UVec3;
1309 #[inline]
1310 fn sub(self, rhs: &UVec3) -> UVec3 {
1311 (*self).sub(*rhs)
1312 }
1313}
1314
1315impl Sub<UVec3> for &u32 {
1316 type Output = UVec3;
1317 #[inline]
1318 fn sub(self, rhs: UVec3) -> UVec3 {
1319 (*self).sub(rhs)
1320 }
1321}
1322
1323impl Rem<UVec3> for UVec3 {
1324 type Output = Self;
1325 #[inline]
1326 fn rem(self, rhs: Self) -> Self {
1327 Self {
1328 x: self.x.rem(rhs.x),
1329 y: self.y.rem(rhs.y),
1330 z: self.z.rem(rhs.z),
1331 }
1332 }
1333}
1334
1335impl Rem<&UVec3> for UVec3 {
1336 type Output = UVec3;
1337 #[inline]
1338 fn rem(self, rhs: &UVec3) -> UVec3 {
1339 self.rem(*rhs)
1340 }
1341}
1342
1343impl Rem<&UVec3> for &UVec3 {
1344 type Output = UVec3;
1345 #[inline]
1346 fn rem(self, rhs: &UVec3) -> UVec3 {
1347 (*self).rem(*rhs)
1348 }
1349}
1350
1351impl Rem<UVec3> for &UVec3 {
1352 type Output = UVec3;
1353 #[inline]
1354 fn rem(self, rhs: UVec3) -> UVec3 {
1355 (*self).rem(rhs)
1356 }
1357}
1358
1359impl RemAssign<UVec3> for UVec3 {
1360 #[inline]
1361 fn rem_assign(&mut self, rhs: Self) {
1362 self.x.rem_assign(rhs.x);
1363 self.y.rem_assign(rhs.y);
1364 self.z.rem_assign(rhs.z);
1365 }
1366}
1367
1368impl RemAssign<&UVec3> for UVec3 {
1369 #[inline]
1370 fn rem_assign(&mut self, rhs: &UVec3) {
1371 self.rem_assign(*rhs)
1372 }
1373}
1374
1375impl Rem<u32> for UVec3 {
1376 type Output = Self;
1377 #[inline]
1378 fn rem(self, rhs: u32) -> Self {
1379 Self {
1380 x: self.x.rem(rhs),
1381 y: self.y.rem(rhs),
1382 z: self.z.rem(rhs),
1383 }
1384 }
1385}
1386
1387impl Rem<&u32> for UVec3 {
1388 type Output = UVec3;
1389 #[inline]
1390 fn rem(self, rhs: &u32) -> UVec3 {
1391 self.rem(*rhs)
1392 }
1393}
1394
1395impl Rem<&u32> for &UVec3 {
1396 type Output = UVec3;
1397 #[inline]
1398 fn rem(self, rhs: &u32) -> UVec3 {
1399 (*self).rem(*rhs)
1400 }
1401}
1402
1403impl Rem<u32> for &UVec3 {
1404 type Output = UVec3;
1405 #[inline]
1406 fn rem(self, rhs: u32) -> UVec3 {
1407 (*self).rem(rhs)
1408 }
1409}
1410
1411impl RemAssign<u32> for UVec3 {
1412 #[inline]
1413 fn rem_assign(&mut self, rhs: u32) {
1414 self.x.rem_assign(rhs);
1415 self.y.rem_assign(rhs);
1416 self.z.rem_assign(rhs);
1417 }
1418}
1419
1420impl RemAssign<&u32> for UVec3 {
1421 #[inline]
1422 fn rem_assign(&mut self, rhs: &u32) {
1423 self.rem_assign(*rhs)
1424 }
1425}
1426
1427impl Rem<UVec3> for u32 {
1428 type Output = UVec3;
1429 #[inline]
1430 fn rem(self, rhs: UVec3) -> UVec3 {
1431 UVec3 {
1432 x: self.rem(rhs.x),
1433 y: self.rem(rhs.y),
1434 z: self.rem(rhs.z),
1435 }
1436 }
1437}
1438
1439impl Rem<&UVec3> for u32 {
1440 type Output = UVec3;
1441 #[inline]
1442 fn rem(self, rhs: &UVec3) -> UVec3 {
1443 self.rem(*rhs)
1444 }
1445}
1446
1447impl Rem<&UVec3> for &u32 {
1448 type Output = UVec3;
1449 #[inline]
1450 fn rem(self, rhs: &UVec3) -> UVec3 {
1451 (*self).rem(*rhs)
1452 }
1453}
1454
1455impl Rem<UVec3> for &u32 {
1456 type Output = UVec3;
1457 #[inline]
1458 fn rem(self, rhs: UVec3) -> UVec3 {
1459 (*self).rem(rhs)
1460 }
1461}
1462
1463#[cfg(not(target_arch = "spirv"))]
1464impl AsRef<[u32; 3]> for UVec3 {
1465 #[inline]
1466 fn as_ref(&self) -> &[u32; 3] {
1467 unsafe { &*(self as *const UVec3 as *const [u32; 3]) }
1468 }
1469}
1470
1471#[cfg(not(target_arch = "spirv"))]
1472impl AsMut<[u32; 3]> for UVec3 {
1473 #[inline]
1474 fn as_mut(&mut self) -> &mut [u32; 3] {
1475 unsafe { &mut *(self as *mut UVec3 as *mut [u32; 3]) }
1476 }
1477}
1478
1479impl Sum for UVec3 {
1480 #[inline]
1481 fn sum<I>(iter: I) -> Self
1482 where
1483 I: Iterator<Item = Self>,
1484 {
1485 iter.fold(Self::ZERO, Self::add)
1486 }
1487}
1488
1489impl<'a> Sum<&'a Self> for UVec3 {
1490 #[inline]
1491 fn sum<I>(iter: I) -> Self
1492 where
1493 I: Iterator<Item = &'a Self>,
1494 {
1495 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1496 }
1497}
1498
1499impl Product for UVec3 {
1500 #[inline]
1501 fn product<I>(iter: I) -> Self
1502 where
1503 I: Iterator<Item = Self>,
1504 {
1505 iter.fold(Self::ONE, Self::mul)
1506 }
1507}
1508
1509impl<'a> Product<&'a Self> for UVec3 {
1510 #[inline]
1511 fn product<I>(iter: I) -> Self
1512 where
1513 I: Iterator<Item = &'a Self>,
1514 {
1515 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1516 }
1517}
1518
1519impl Not for UVec3 {
1520 type Output = Self;
1521 #[inline]
1522 fn not(self) -> Self::Output {
1523 Self {
1524 x: self.x.not(),
1525 y: self.y.not(),
1526 z: self.z.not(),
1527 }
1528 }
1529}
1530
1531impl BitAnd for UVec3 {
1532 type Output = Self;
1533 #[inline]
1534 fn bitand(self, rhs: Self) -> Self::Output {
1535 Self {
1536 x: self.x.bitand(rhs.x),
1537 y: self.y.bitand(rhs.y),
1538 z: self.z.bitand(rhs.z),
1539 }
1540 }
1541}
1542
1543impl BitOr for UVec3 {
1544 type Output = Self;
1545 #[inline]
1546 fn bitor(self, rhs: Self) -> Self::Output {
1547 Self {
1548 x: self.x.bitor(rhs.x),
1549 y: self.y.bitor(rhs.y),
1550 z: self.z.bitor(rhs.z),
1551 }
1552 }
1553}
1554
1555impl BitXor for UVec3 {
1556 type Output = Self;
1557 #[inline]
1558 fn bitxor(self, rhs: Self) -> Self::Output {
1559 Self {
1560 x: self.x.bitxor(rhs.x),
1561 y: self.y.bitxor(rhs.y),
1562 z: self.z.bitxor(rhs.z),
1563 }
1564 }
1565}
1566
1567impl BitAnd<u32> for UVec3 {
1568 type Output = Self;
1569 #[inline]
1570 fn bitand(self, rhs: u32) -> Self::Output {
1571 Self {
1572 x: self.x.bitand(rhs),
1573 y: self.y.bitand(rhs),
1574 z: self.z.bitand(rhs),
1575 }
1576 }
1577}
1578
1579impl BitOr<u32> for UVec3 {
1580 type Output = Self;
1581 #[inline]
1582 fn bitor(self, rhs: u32) -> Self::Output {
1583 Self {
1584 x: self.x.bitor(rhs),
1585 y: self.y.bitor(rhs),
1586 z: self.z.bitor(rhs),
1587 }
1588 }
1589}
1590
1591impl BitXor<u32> for UVec3 {
1592 type Output = Self;
1593 #[inline]
1594 fn bitxor(self, rhs: u32) -> Self::Output {
1595 Self {
1596 x: self.x.bitxor(rhs),
1597 y: self.y.bitxor(rhs),
1598 z: self.z.bitxor(rhs),
1599 }
1600 }
1601}
1602
1603impl Shl<i8> for UVec3 {
1604 type Output = Self;
1605 #[inline]
1606 fn shl(self, rhs: i8) -> Self::Output {
1607 Self {
1608 x: self.x.shl(rhs),
1609 y: self.y.shl(rhs),
1610 z: self.z.shl(rhs),
1611 }
1612 }
1613}
1614
1615impl Shr<i8> for UVec3 {
1616 type Output = Self;
1617 #[inline]
1618 fn shr(self, rhs: i8) -> Self::Output {
1619 Self {
1620 x: self.x.shr(rhs),
1621 y: self.y.shr(rhs),
1622 z: self.z.shr(rhs),
1623 }
1624 }
1625}
1626
1627impl Shl<i16> for UVec3 {
1628 type Output = Self;
1629 #[inline]
1630 fn shl(self, rhs: i16) -> Self::Output {
1631 Self {
1632 x: self.x.shl(rhs),
1633 y: self.y.shl(rhs),
1634 z: self.z.shl(rhs),
1635 }
1636 }
1637}
1638
1639impl Shr<i16> for UVec3 {
1640 type Output = Self;
1641 #[inline]
1642 fn shr(self, rhs: i16) -> Self::Output {
1643 Self {
1644 x: self.x.shr(rhs),
1645 y: self.y.shr(rhs),
1646 z: self.z.shr(rhs),
1647 }
1648 }
1649}
1650
1651impl Shl<i32> for UVec3 {
1652 type Output = Self;
1653 #[inline]
1654 fn shl(self, rhs: i32) -> Self::Output {
1655 Self {
1656 x: self.x.shl(rhs),
1657 y: self.y.shl(rhs),
1658 z: self.z.shl(rhs),
1659 }
1660 }
1661}
1662
1663impl Shr<i32> for UVec3 {
1664 type Output = Self;
1665 #[inline]
1666 fn shr(self, rhs: i32) -> Self::Output {
1667 Self {
1668 x: self.x.shr(rhs),
1669 y: self.y.shr(rhs),
1670 z: self.z.shr(rhs),
1671 }
1672 }
1673}
1674
1675impl Shl<i64> for UVec3 {
1676 type Output = Self;
1677 #[inline]
1678 fn shl(self, rhs: i64) -> Self::Output {
1679 Self {
1680 x: self.x.shl(rhs),
1681 y: self.y.shl(rhs),
1682 z: self.z.shl(rhs),
1683 }
1684 }
1685}
1686
1687impl Shr<i64> for UVec3 {
1688 type Output = Self;
1689 #[inline]
1690 fn shr(self, rhs: i64) -> Self::Output {
1691 Self {
1692 x: self.x.shr(rhs),
1693 y: self.y.shr(rhs),
1694 z: self.z.shr(rhs),
1695 }
1696 }
1697}
1698
1699impl Shl<u8> for UVec3 {
1700 type Output = Self;
1701 #[inline]
1702 fn shl(self, rhs: u8) -> Self::Output {
1703 Self {
1704 x: self.x.shl(rhs),
1705 y: self.y.shl(rhs),
1706 z: self.z.shl(rhs),
1707 }
1708 }
1709}
1710
1711impl Shr<u8> for UVec3 {
1712 type Output = Self;
1713 #[inline]
1714 fn shr(self, rhs: u8) -> Self::Output {
1715 Self {
1716 x: self.x.shr(rhs),
1717 y: self.y.shr(rhs),
1718 z: self.z.shr(rhs),
1719 }
1720 }
1721}
1722
1723impl Shl<u16> for UVec3 {
1724 type Output = Self;
1725 #[inline]
1726 fn shl(self, rhs: u16) -> Self::Output {
1727 Self {
1728 x: self.x.shl(rhs),
1729 y: self.y.shl(rhs),
1730 z: self.z.shl(rhs),
1731 }
1732 }
1733}
1734
1735impl Shr<u16> for UVec3 {
1736 type Output = Self;
1737 #[inline]
1738 fn shr(self, rhs: u16) -> Self::Output {
1739 Self {
1740 x: self.x.shr(rhs),
1741 y: self.y.shr(rhs),
1742 z: self.z.shr(rhs),
1743 }
1744 }
1745}
1746
1747impl Shl<u32> for UVec3 {
1748 type Output = Self;
1749 #[inline]
1750 fn shl(self, rhs: u32) -> Self::Output {
1751 Self {
1752 x: self.x.shl(rhs),
1753 y: self.y.shl(rhs),
1754 z: self.z.shl(rhs),
1755 }
1756 }
1757}
1758
1759impl Shr<u32> for UVec3 {
1760 type Output = Self;
1761 #[inline]
1762 fn shr(self, rhs: u32) -> Self::Output {
1763 Self {
1764 x: self.x.shr(rhs),
1765 y: self.y.shr(rhs),
1766 z: self.z.shr(rhs),
1767 }
1768 }
1769}
1770
1771impl Shl<u64> for UVec3 {
1772 type Output = Self;
1773 #[inline]
1774 fn shl(self, rhs: u64) -> Self::Output {
1775 Self {
1776 x: self.x.shl(rhs),
1777 y: self.y.shl(rhs),
1778 z: self.z.shl(rhs),
1779 }
1780 }
1781}
1782
1783impl Shr<u64> for UVec3 {
1784 type Output = Self;
1785 #[inline]
1786 fn shr(self, rhs: u64) -> Self::Output {
1787 Self {
1788 x: self.x.shr(rhs),
1789 y: self.y.shr(rhs),
1790 z: self.z.shr(rhs),
1791 }
1792 }
1793}
1794
1795impl Shl<crate::IVec3> for UVec3 {
1796 type Output = Self;
1797 #[inline]
1798 fn shl(self, rhs: crate::IVec3) -> Self::Output {
1799 Self {
1800 x: self.x.shl(rhs.x),
1801 y: self.y.shl(rhs.y),
1802 z: self.z.shl(rhs.z),
1803 }
1804 }
1805}
1806
1807impl Shr<crate::IVec3> for UVec3 {
1808 type Output = Self;
1809 #[inline]
1810 fn shr(self, rhs: crate::IVec3) -> Self::Output {
1811 Self {
1812 x: self.x.shr(rhs.x),
1813 y: self.y.shr(rhs.y),
1814 z: self.z.shr(rhs.z),
1815 }
1816 }
1817}
1818
1819impl Shl<crate::UVec3> for UVec3 {
1820 type Output = Self;
1821 #[inline]
1822 fn shl(self, rhs: crate::UVec3) -> Self::Output {
1823 Self {
1824 x: self.x.shl(rhs.x),
1825 y: self.y.shl(rhs.y),
1826 z: self.z.shl(rhs.z),
1827 }
1828 }
1829}
1830
1831impl Shr<crate::UVec3> for UVec3 {
1832 type Output = Self;
1833 #[inline]
1834 fn shr(self, rhs: crate::UVec3) -> Self::Output {
1835 Self {
1836 x: self.x.shr(rhs.x),
1837 y: self.y.shr(rhs.y),
1838 z: self.z.shr(rhs.z),
1839 }
1840 }
1841}
1842
1843impl Index<usize> for UVec3 {
1844 type Output = u32;
1845 #[inline]
1846 fn index(&self, index: usize) -> &Self::Output {
1847 match index {
1848 0 => &self.x,
1849 1 => &self.y,
1850 2 => &self.z,
1851 _ => panic!("index out of bounds"),
1852 }
1853 }
1854}
1855
1856impl IndexMut<usize> for UVec3 {
1857 #[inline]
1858 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1859 match index {
1860 0 => &mut self.x,
1861 1 => &mut self.y,
1862 2 => &mut self.z,
1863 _ => panic!("index out of bounds"),
1864 }
1865 }
1866}
1867
1868impl fmt::Display for UVec3 {
1869 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1870 write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1871 }
1872}
1873
1874impl fmt::Debug for UVec3 {
1875 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1876 fmt.debug_tuple(stringify!(UVec3))
1877 .field(&self.x)
1878 .field(&self.y)
1879 .field(&self.z)
1880 .finish()
1881 }
1882}
1883
1884impl From<[u32; 3]> for UVec3 {
1885 #[inline]
1886 fn from(a: [u32; 3]) -> Self {
1887 Self::new(a[0], a[1], a[2])
1888 }
1889}
1890
1891impl From<UVec3> for [u32; 3] {
1892 #[inline]
1893 fn from(v: UVec3) -> Self {
1894 [v.x, v.y, v.z]
1895 }
1896}
1897
1898impl From<(u32, u32, u32)> for UVec3 {
1899 #[inline]
1900 fn from(t: (u32, u32, u32)) -> Self {
1901 Self::new(t.0, t.1, t.2)
1902 }
1903}
1904
1905impl From<UVec3> for (u32, u32, u32) {
1906 #[inline]
1907 fn from(v: UVec3) -> Self {
1908 (v.x, v.y, v.z)
1909 }
1910}
1911
1912impl From<(UVec2, u32)> for UVec3 {
1913 #[inline]
1914 fn from((v, z): (UVec2, u32)) -> Self {
1915 Self::new(v.x, v.y, z)
1916 }
1917}
1918
1919impl From<U8Vec3> for UVec3 {
1920 #[inline]
1921 fn from(v: U8Vec3) -> Self {
1922 Self::new(u32::from(v.x), u32::from(v.y), u32::from(v.z))
1923 }
1924}
1925
1926impl From<U16Vec3> for UVec3 {
1927 #[inline]
1928 fn from(v: U16Vec3) -> Self {
1929 Self::new(u32::from(v.x), u32::from(v.y), u32::from(v.z))
1930 }
1931}
1932
1933impl TryFrom<I8Vec3> for UVec3 {
1934 type Error = core::num::TryFromIntError;
1935
1936 #[inline]
1937 fn try_from(v: I8Vec3) -> Result<Self, Self::Error> {
1938 Ok(Self::new(
1939 u32::try_from(v.x)?,
1940 u32::try_from(v.y)?,
1941 u32::try_from(v.z)?,
1942 ))
1943 }
1944}
1945
1946impl TryFrom<I16Vec3> for UVec3 {
1947 type Error = core::num::TryFromIntError;
1948
1949 #[inline]
1950 fn try_from(v: I16Vec3) -> Result<Self, Self::Error> {
1951 Ok(Self::new(
1952 u32::try_from(v.x)?,
1953 u32::try_from(v.y)?,
1954 u32::try_from(v.z)?,
1955 ))
1956 }
1957}
1958
1959impl TryFrom<IVec3> for UVec3 {
1960 type Error = core::num::TryFromIntError;
1961
1962 #[inline]
1963 fn try_from(v: IVec3) -> Result<Self, Self::Error> {
1964 Ok(Self::new(
1965 u32::try_from(v.x)?,
1966 u32::try_from(v.y)?,
1967 u32::try_from(v.z)?,
1968 ))
1969 }
1970}
1971
1972impl TryFrom<I64Vec3> for UVec3 {
1973 type Error = core::num::TryFromIntError;
1974
1975 #[inline]
1976 fn try_from(v: I64Vec3) -> Result<Self, Self::Error> {
1977 Ok(Self::new(
1978 u32::try_from(v.x)?,
1979 u32::try_from(v.y)?,
1980 u32::try_from(v.z)?,
1981 ))
1982 }
1983}
1984
1985impl TryFrom<U64Vec3> for UVec3 {
1986 type Error = core::num::TryFromIntError;
1987
1988 #[inline]
1989 fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1990 Ok(Self::new(
1991 u32::try_from(v.x)?,
1992 u32::try_from(v.y)?,
1993 u32::try_from(v.z)?,
1994 ))
1995 }
1996}
1997
1998impl TryFrom<USizeVec3> for UVec3 {
1999 type Error = core::num::TryFromIntError;
2000
2001 #[inline]
2002 fn try_from(v: USizeVec3) -> Result<Self, Self::Error> {
2003 Ok(Self::new(
2004 u32::try_from(v.x)?,
2005 u32::try_from(v.y)?,
2006 u32::try_from(v.z)?,
2007 ))
2008 }
2009}
2010
2011impl From<BVec3> for UVec3 {
2012 #[inline]
2013 fn from(v: BVec3) -> Self {
2014 Self::new(u32::from(v.x), u32::from(v.y), u32::from(v.z))
2015 }
2016}
2017
2018impl From<BVec3A> for UVec3 {
2019 #[inline]
2020 fn from(v: BVec3A) -> Self {
2021 let bool_array: [bool; 3] = v.into();
2022 Self::new(
2023 u32::from(bool_array[0]),
2024 u32::from(bool_array[1]),
2025 u32::from(bool_array[2]),
2026 )
2027 }
2028}