diff --git a/world/src/lib.rs b/world/src/lib.rs index 65a0283e75..5a58627c9c 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,6 +1,5 @@ #![deny(unsafe_code)] #![feature( - box_syntax, const_generics, euclidean_division, bind_by_move_pattern_guards, diff --git a/world/src/sim/util.rs b/world/src/sim/util.rs index 2c90a2e659..4e27ee20a4 100644 --- a/world/src/sim/util.rs +++ b/world/src/sim/util.rs @@ -92,7 +92,9 @@ pub fn cdf_irwin_hall(weights: &[f32; N], samples: [f32; N]) -> /// index (i.e. its position in a sorted list of value returned by the noise function applied to /// every chunk in the game). Second component is the cached value of the noise function that /// generated the index. -pub type InverseCdf = Box<[(f32, f32); WORLD_SIZE.x * WORLD_SIZE.y]>; +/// +/// NOTE: Length should always be WORLD_SIZE.x * WORLD_SIZE.y. +pub type InverseCdf = Box<[(f32, f32)]>; /// Computes the position Vec2 of a SimChunk from an index, where the index was generated by /// uniform_noise. @@ -156,7 +158,7 @@ pub fn uniform_noise(f: impl Fn(usize, Vec2) -> f32) -> InverseCdf { // NOTE: Currently there doesn't seem to be a way to create a large fixed-size // array on the heap without overflowing the stack unless you use placement box (at least on // debug mode). So I want to keep using this until a better alternative is made available. - let mut uniform_noise = box [(0.0, 0.0); WORLD_SIZE.x * WORLD_SIZE.y]; + let mut uniform_noise = vec![(0.0, 0.0); WORLD_SIZE.x * WORLD_SIZE.y].into_boxed_slice(); let total = (WORLD_SIZE.x * WORLD_SIZE.y) as f32; for (noise_idx, (chunk_idx, noise_val)) in noise.into_iter().enumerate() { uniform_noise[chunk_idx] = ((1 + noise_idx) as f32 / total, noise_val);