• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bitshifter / glam-rs / 42162624372

06 Nov 2026 04:27AM UTC coverage: 99.1% (-0.01%) from 99.111%
42162624372

push

github

web-flow
fix(camera): apply handedness to the frustum X and Y translation (#922)

`frustum` used the same `zx`/`zy` for both handedness, but `w` is `-z`
in RH view space and `z` in LH view space, so the X and Y translation
terms have opposite signs for LH projections. With asymmetric bounds an
LH frustum mapped the centre of the near plane to `(2, 2)` in NDC
instead of `(0, 0)`, mirroring and offsetting the image. Symmetric
bounds hid it because the terms cancel when `right + left` and `top +
bottom` are zero.

Scale `zx` by handedness, and `zy` by handedness and `YFLIP`, matching
the DirectX `XMMatrixPerspectiveOffCenterLH` convention.

Add asymmetric bound tests for the opengl, vulkan and directx frustum
projections in both handedness, and reword the existing asymmetric bound
test comment to say why the Y-up projections are covered too.

12 of 12 new or added lines in 2 files covered. (100.0%)

25 existing lines in 6 files now uncovered.

91679 of 92512 relevant lines covered (99.1%)

118944.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.71
/src/bool/bvec2.rs
1
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
2

3
use core::fmt;
4
use core::ops::*;
5

6
/// Creates a 2-dimensional `bool` vector mask.
7
#[inline(always)]
8
#[must_use]
UNCOV
9
pub const fn bvec2(x: bool, y: bool) -> BVec2 {
×
UNCOV
10
    BVec2::new(x, y)
×
UNCOV
11
}
×
12

13
/// A 2-dimensional `bool` vector mask.
14
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
15
#[repr(C, align(1))]
16
#[cfg_attr(target_arch = "spirv", rust_gpu::vector::v1)]
17
pub struct BVec2 {
18
    pub x: bool,
19
    pub y: bool,
20
}
21

22
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
23

24
impl BVec2 {
25
    /// All false.
26
    pub const FALSE: Self = Self::splat(false);
27

28
    /// All true.
29
    pub const TRUE: Self = Self::splat(true);
30

31
    /// Creates a new vector mask.
32
    #[inline(always)]
33
    #[must_use]
34
    pub const fn new(x: bool, y: bool) -> Self {
5,502 ✔
35
        Self { x, y }
5,502 ✔
36
    }
5,502 ✔
37

38
    /// Creates a vector mask with all elements set to `v`.
39
    #[inline]
40
    #[must_use]
41
    pub const fn splat(v: bool) -> Self {
8 ✔
42
        Self::new(v, v)
8 ✔
43
    }
8 ✔
44

45
    /// Creates a new vector mask from a bool array.
46
    #[inline]
47
    #[must_use]
48
    pub const fn from_array(a: [bool; 2]) -> Self {
20 ✔
49
        Self::new(a[0], a[1])
20 ✔
50
    }
20 ✔
51

52
    /// Returns a bitmask with the lowest 2 bits set from the elements of `self`.
53
    ///
54
    /// A true element results in a `1` bit and a false element in a `0` bit.  Element `x` goes
55
    /// into the first lowest bit, element `y` into the second, etc.
56
    #[inline]
57
    #[must_use]
58
    pub fn bitmask(self) -> u32 {
520 ✔
59
        (self.x as u32) | ((self.y as u32) << 1)
520 ✔
60
    }
520 ✔
61

62
    /// Returns true if any of the elements are true, false otherwise.
63
    #[inline]
64
    #[must_use]
65
    pub fn any(self) -> bool {
280 ✔
66
        self.x || self.y
280 ✔
67
    }
280 ✔
68

69
    /// Returns true if all the elements are true, false otherwise.
70
    #[inline]
71
    #[must_use]
72
    pub fn all(self) -> bool {
3,620 ✔
73
        self.x && self.y
3,620 ✔
74
    }
3,620 ✔
75

76
    /// Tests the value at `index`.
77
    ///
78
    /// Panics if `index` is greater than 1.
79
    #[inline]
80
    #[must_use]
81
    #[track_caller]
82
    pub fn test(self, index: usize) -> bool {
440 ✔
83
        match index {
440 ✔
84
            0 => self.x,
218 ✔
85
            1 => self.y,
218 ✔
86
            _ => panic!("index out of bounds"),
4 ✔
87
        }
88
    }
436 ✔
89

90
    /// Sets the element at `index`.
91
    ///
92
    /// Panics if `index` is greater than 1.
93
    #[inline]
94
    #[track_caller]
95
    pub fn set(&mut self, index: usize, value: bool) {
20 ✔
96
        match index {
20 ✔
97
            0 => self.x = value,
8 ✔
98
            1 => self.y = value,
8 ✔
99
            _ => panic!("index out of bounds"),
4 ✔
100
        }
101
    }
16 ✔
102

103
    #[inline]
104
    #[must_use]
105
    fn into_bool_array(self) -> [bool; 2] {
20 ✔
106
        [self.x, self.y]
20 ✔
107
    }
20 ✔
108

109
    #[inline]
110
    #[must_use]
111
    fn into_u32_array(self) -> [u32; 2] {
20 ✔
112
        [MASK[self.x as usize], MASK[self.y as usize]]
20 ✔
113
    }
20 ✔
114
}
115

116
impl Default for BVec2 {
117
    #[inline]
118
    fn default() -> Self {
148 ✔
119
        Self::FALSE
148 ✔
120
    }
148 ✔
121
}
122

123
impl BitAnd for BVec2 {
124
    type Output = Self;
125
    #[inline]
126
    fn bitand(self, rhs: Self) -> Self {
72 ✔
127
        Self {
72 ✔
128
            x: self.x & rhs.x,
72 ✔
129
            y: self.y & rhs.y,
72 ✔
130
        }
72 ✔
131
    }
72 ✔
132
}
133

134
impl BitAnd<&Self> for BVec2 {
135
    type Output = Self;
136
    #[inline]
137
    fn bitand(self, rhs: &Self) -> Self {
16 ✔
138
        self.bitand(*rhs)
16 ✔
139
    }
16 ✔
140
}
141

142
impl BitAnd<&BVec2> for &BVec2 {
143
    type Output = BVec2;
144
    #[inline]
145
    fn bitand(self, rhs: &BVec2) -> BVec2 {
16 ✔
146
        (*self).bitand(*rhs)
16 ✔
147
    }
16 ✔
148
}
149

150
impl BitAnd<BVec2> for &BVec2 {
151
    type Output = BVec2;
152
    #[inline]
153
    fn bitand(self, rhs: BVec2) -> BVec2 {
16 ✔
154
        (*self).bitand(rhs)
16 ✔
155
    }
16 ✔
156
}
157

158
impl BitAndAssign for BVec2 {
159
    #[inline]
160
    fn bitand_assign(&mut self, rhs: Self) {
8 ✔
161
        *self = self.bitand(rhs);
8 ✔
162
    }
8 ✔
163
}
164

165
impl BitAndAssign<&Self> for BVec2 {
166
    #[inline]
167
    fn bitand_assign(&mut self, rhs: &Self) {
4 ✔
168
        self.bitand_assign(*rhs);
4 ✔
169
    }
4 ✔
170
}
171

172
impl BitOr for BVec2 {
173
    type Output = Self;
174
    #[inline]
175
    fn bitor(self, rhs: Self) -> Self {
72 ✔
176
        Self {
72 ✔
177
            x: self.x | rhs.x,
72 ✔
178
            y: self.y | rhs.y,
72 ✔
179
        }
72 ✔
180
    }
72 ✔
181
}
182

183
impl BitOr<&Self> for BVec2 {
184
    type Output = Self;
185
    #[inline]
186
    fn bitor(self, rhs: &Self) -> Self {
16 ✔
187
        self.bitor(*rhs)
16 ✔
188
    }
16 ✔
189
}
190

191
impl BitOr<&BVec2> for &BVec2 {
192
    type Output = BVec2;
193
    #[inline]
194
    fn bitor(self, rhs: &BVec2) -> BVec2 {
16 ✔
195
        (*self).bitor(*rhs)
16 ✔
196
    }
16 ✔
197
}
198

199
impl BitOr<BVec2> for &BVec2 {
200
    type Output = BVec2;
201
    #[inline]
202
    fn bitor(self, rhs: BVec2) -> BVec2 {
16 ✔
203
        (*self).bitor(rhs)
16 ✔
204
    }
16 ✔
205
}
206

207
impl BitOrAssign for BVec2 {
208
    #[inline]
209
    fn bitor_assign(&mut self, rhs: Self) {
8 ✔
210
        *self = self.bitor(rhs);
8 ✔
211
    }
8 ✔
212
}
213

214
impl BitOrAssign<&Self> for BVec2 {
215
    #[inline]
216
    fn bitor_assign(&mut self, rhs: &Self) {
4 ✔
217
        self.bitor_assign(*rhs);
4 ✔
218
    }
4 ✔
219
}
220

221
impl BitXor for BVec2 {
222
    type Output = Self;
223
    #[inline]
224
    fn bitxor(self, rhs: Self) -> Self {
72 ✔
225
        Self {
72 ✔
226
            x: self.x ^ rhs.x,
72 ✔
227
            y: self.y ^ rhs.y,
72 ✔
228
        }
72 ✔
229
    }
72 ✔
230
}
231

232
impl BitXor<&Self> for BVec2 {
233
    type Output = Self;
234
    #[inline]
235
    fn bitxor(self, rhs: &Self) -> Self {
16 ✔
236
        self.bitxor(*rhs)
16 ✔
237
    }
16 ✔
238
}
239

240
impl BitXor<&BVec2> for &BVec2 {
241
    type Output = BVec2;
242
    #[inline]
243
    fn bitxor(self, rhs: &BVec2) -> BVec2 {
16 ✔
244
        (*self).bitxor(*rhs)
16 ✔
245
    }
16 ✔
246
}
247

248
impl BitXor<BVec2> for &BVec2 {
249
    type Output = BVec2;
250
    #[inline]
251
    fn bitxor(self, rhs: BVec2) -> BVec2 {
16 ✔
252
        (*self).bitxor(rhs)
16 ✔
253
    }
16 ✔
254
}
255

256
impl BitXorAssign for BVec2 {
257
    #[inline]
258
    fn bitxor_assign(&mut self, rhs: Self) {
8 ✔
259
        *self = self.bitxor(rhs);
8 ✔
260
    }
8 ✔
261
}
262

263
impl BitXorAssign<&Self> for BVec2 {
264
    #[inline]
265
    fn bitxor_assign(&mut self, rhs: &Self) {
4 ✔
266
        self.bitxor_assign(*rhs);
4 ✔
267
    }
4 ✔
268
}
269

270
impl Not for BVec2 {
271
    type Output = Self;
272
    #[inline]
273
    fn not(self) -> Self {
32 ✔
274
        Self {
32 ✔
275
            x: !self.x,
32 ✔
276
            y: !self.y,
32 ✔
277
        }
32 ✔
278
    }
32 ✔
279
}
280

281
impl Not for &BVec2 {
282
    type Output = BVec2;
283
    #[inline]
284
    fn not(self) -> BVec2 {
16 ✔
285
        (*self).not()
16 ✔
286
    }
16 ✔
287
}
288

289
impl fmt::Debug for BVec2 {
290
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4 ✔
291
        let arr = self.into_u32_array();
4 ✔
292
        write!(f, "{}({:#x}, {:#x})", stringify!(BVec2), arr[0], arr[1])
4 ✔
293
    }
4 ✔
294
}
295

296
impl fmt::Display for BVec2 {
297
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4 ✔
298
        let arr = self.into_bool_array();
4 ✔
299
        write!(f, "[{}, {}]", arr[0], arr[1])
4 ✔
300
    }
4 ✔
301
}
302

303
impl From<[bool; 2]> for BVec2 {
304
    #[inline]
305
    fn from(a: [bool; 2]) -> Self {
16 ✔
306
        Self::from_array(a)
16 ✔
307
    }
16 ✔
308
}
309

310
impl From<BVec2> for [bool; 2] {
311
    #[inline]
312
    fn from(mask: BVec2) -> Self {
16 ✔
313
        mask.into_bool_array()
16 ✔
314
    }
16 ✔
315
}
316

317
impl From<BVec2> for [u32; 2] {
318
    #[inline]
319
    fn from(mask: BVec2) -> Self {
16 ✔
320
        mask.into_u32_array()
16 ✔
321
    }
16 ✔
322
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc