Skip to content

Commit

Permalink
Implement usage of core::array::from_fn into `generate_hilbert_inde…
Browse files Browse the repository at this point in the history
…x_lut()`, per suggestion from Benjamin
  • Loading branch information
LikeLakers2 committed Jan 10, 2025
1 parent 311393e commit 4cdbca4
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions crates/bevy_pbr/src/ssao/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,19 +753,8 @@ fn prepare_ssao_bind_groups(
}

fn generate_hilbert_index_lut() -> [[u16; 64]; 64] {
let mut t = [[0; 64]; 64];

#[expect(
clippy::needless_range_loop,
reason = "Rewriting this loop to use iterators would make the code much harder to read for very little performance gain."
)]
for x in 0..64 {
for y in 0..64 {
t[x][y] = hilbert_index(x as u16, y as u16);
}
}

t
use core::array::from_fn;
from_fn(|x| from_fn(|y| hilbert_index(x as u16, y as u16)))
}

// https://www.shadertoy.com/view/3tB3z3
Expand Down

0 comments on commit 4cdbca4

Please sign in to comment.