glam/i32/
ivec3.rs

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