Merge branch 'capucho/scissor-panic' into 'master'

Fix scissor panics when window height is 1

See merge request veloren/veloren!2379
This commit is contained in:
Ben Wallis 2021-06-05 20:46:43 +00:00
commit 8c825305e9
2 changed files with 11 additions and 4 deletions

View File

@ -708,10 +708,17 @@ impl IcedRenderer {
}
.intersection(self.window_scissor);
if intersection.is_valid() {
if intersection.is_valid() && intersection.size().map(|s| s > 0).reduce_and() {
intersection
} else {
Aabr::new_empty(Vec2::zero())
// Create a aabr with width 1 and height 1, technically
// it would be more correct to do it with 0,0 but that's
// a validation error in wgpu so enjoy your funky pixel
// in the top left of your screen
Aabr {
min: Vec2::zero(),
max: Vec2::one(),
}
}
};
// Not expecting this case: new_scissor == current_scissor

View File

@ -283,7 +283,7 @@ impl Ui {
pub fn handle_event(&mut self, event: Event) {
match event.0 {
Input::Resize(w, h) => {
if w > 1.0 && h > 1.0 {
if w > 0.0 && h > 0.0 {
self.window_resized = Some(Vec2::new(w, h))
}
},
@ -673,7 +673,7 @@ impl Ui {
}
.intersection(window_scissor);
if intersection.is_valid() {
if intersection.is_valid() && intersection.size().map(|s| s > 0).reduce_and() {
intersection
} else {
// TODO: What should we return here