mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Fix unsetting RenderLayers bit in without fn (#2409)
# Objective Fixes how the layer bit is unset in the RenderLayers bit mask when calling the `without` method. ## Solution Unsets the layer bit using `&=` and the inverse of the layer bit mask.
This commit is contained in:
parent
b911a005d9
commit
941a8fb8a3
1 changed files with 6 additions and 1 deletions
|
@ -110,7 +110,7 @@ impl RenderLayers {
|
||||||
/// Panics when called with a layer greater than `TOTAL_LAYERS - 1`.
|
/// Panics when called with a layer greater than `TOTAL_LAYERS - 1`.
|
||||||
pub fn without(mut self, layer: Layer) -> Self {
|
pub fn without(mut self, layer: Layer) -> Self {
|
||||||
assert!(usize::from(layer) < Self::TOTAL_LAYERS);
|
assert!(usize::from(layer) < Self::TOTAL_LAYERS);
|
||||||
self.0 |= 0 << layer;
|
self.0 &= !(1 << layer);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,11 @@ mod rendering_mask_tests {
|
||||||
assert_eq!(RenderLayers::layer(0).0, 1, "layer 0 is mask 1");
|
assert_eq!(RenderLayers::layer(0).0, 1, "layer 0 is mask 1");
|
||||||
assert_eq!(RenderLayers::layer(1).0, 2, "layer 1 is mask 2");
|
assert_eq!(RenderLayers::layer(1).0, 2, "layer 1 is mask 2");
|
||||||
assert_eq!(RenderLayers::layer(0).with(1).0, 3, "layer 0 + 1 is mask 3");
|
assert_eq!(RenderLayers::layer(0).with(1).0, 3, "layer 0 + 1 is mask 3");
|
||||||
|
assert_eq!(
|
||||||
|
RenderLayers::layer(0).with(1).without(0).0,
|
||||||
|
2,
|
||||||
|
"layer 0 + 1 - 0 is mask 2"
|
||||||
|
);
|
||||||
assert!(
|
assert!(
|
||||||
RenderLayers::layer(1).intersects(&RenderLayers::layer(1)),
|
RenderLayers::layer(1).intersects(&RenderLayers::layer(1)),
|
||||||
"layers match like layers"
|
"layers match like layers"
|
||||||
|
|
Loading…
Reference in a new issue