glium_types/vectors/
bvec3.rs1use glium::uniforms::{AsUniformValue, UniformValue};
2use super::{bvec2::*, bvec4::*};
3#[derive(Debug, Clone, Copy)]
5pub struct BVec3 { pub x: bool, pub y: bool, pub z: bool }
6impl BVec3 {
7 pub const TRUE: Self = Self::new(true, true, true);
9 pub const FALSE: Self = Self::new(false, false, false);
11 pub const X: Self = Self::new(true, false, false);
13 pub const Y: Self = Self::new(false, true, false);
15 pub const Z: Self = Self::new(false, false, true);
17
18 pub const fn new(x: bool, y: bool, z: bool) -> Self { Self { x, y, z } }
19 pub const fn truncate(self) -> BVec2 { BVec2::new(self.x, self.y) }
20 pub const fn extend(self, w: bool) -> BVec4 { BVec4::new(self.x, self.y, self.z, w) }
21}
22impl AsUniformValue for BVec3 {
23 fn as_uniform_value(&self) -> UniformValue<'_> {
24 UniformValue::BoolVec3([self.x, self.y, self.z])
25 }
26}
27pub const fn bvec3(x: bool, y: bool, z: bool) -> BVec3 { BVec3::new(x, y, z) }
29
30impl std::ops::BitOr for BVec3 {
31 fn bitor(self, rhs: Self) -> Self::Output { bvec3(self.x | rhs.x, self.y | rhs.y, self.z | rhs.z) }
32 type Output = Self;
33}
34impl std::ops::BitOrAssign for BVec3 { fn bitor_assign(&mut self, rhs: Self) { *self = *self | rhs } }
35impl std::ops::BitAnd for BVec3 {
36 fn bitand(self, rhs: Self) -> Self::Output { bvec3(self.x & rhs.x, self.y & rhs.y, self.z & rhs.z) }
37 type Output = Self;
38}
39impl std::ops::BitAndAssign for BVec3 { fn bitand_assign(&mut self, rhs: Self) { *self = *self & rhs } }
40impl std::ops::BitXor for BVec3 {
41 fn bitxor(self, rhs: Self) -> Self::Output { bvec3(self.x ^ rhs.x, self.y ^ rhs.y, self.z ^ rhs.z) }
42 type Output = Self;
43}
44impl std::ops::BitXorAssign for BVec3 { fn bitxor_assign(&mut self, rhs: Self) { *self = *self ^ rhs } }
45impl std::ops::Not for BVec3 {
46 fn not(self) -> Self::Output { bvec3(!self.x, !self.y, !self.z) }
47 type Output = Self;
48}
49
50impl From<(bool, bool, bool)> for BVec3 { fn from(f: (bool, bool, bool)) -> Self { bvec3(f.0, f.1, f.2)} }
51impl From<BVec3> for (bool, bool, bool) { fn from(f: BVec3) -> Self { (f.x, f.y, f.z) } }
52impl From<[bool; 3]> for BVec3 { fn from(f: [bool; 3]) -> Self { bvec3(f[0], f[1], f[2])} }
53impl From<BVec3> for [bool; 3] { fn from(f: BVec3) -> Self { [f.x, f.y, f.z] } }