mirror of
https://github.com/bevyengine/bevy
synced 2024-11-28 15:40:21 +00:00
Handle 0 height in prepare_bloom_textures (#14423)
# Objective - Fix a confusing panic when the viewport width is non-zero and the height is 0, `prepare_bloom_textures` tries to create a `4294967295x1` texture. ## Solution - Avoid dividing by zero - Apps still crash after this, but now on a more reasonable error about the zero-size viewport ## Testing - I isolated and tested the math. A height of 0 sets `mip_height_ratio` to `inf`, causing the width to explode if it isn't also 0
This commit is contained in:
parent
ee4ed231da
commit
a8003b4496
1 changed files with 5 additions and 1 deletions
|
@ -338,7 +338,11 @@ fn prepare_bloom_textures(
|
|||
{
|
||||
// How many times we can halve the resolution minus one so we don't go unnecessarily low
|
||||
let mip_count = MAX_MIP_DIMENSION.ilog2().max(2) - 1;
|
||||
let mip_height_ratio = MAX_MIP_DIMENSION as f32 / height as f32;
|
||||
let mip_height_ratio = if height != 0 {
|
||||
MAX_MIP_DIMENSION as f32 / height as f32
|
||||
} else {
|
||||
0.
|
||||
};
|
||||
|
||||
let texture_descriptor = TextureDescriptor {
|
||||
label: Some("bloom_texture"),
|
||||
|
|
Loading…
Reference in a new issue