Merge branch 'sharp/jungle' of gitlab.com:veloren/veloren into sharp/jungle

This commit is contained in:
Joshua Barretto 2019-08-23 00:33:33 +01:00
commit 8635982173
2 changed files with 4 additions and 7 deletions

View File

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![feature(
box_syntax,
const_generics,
euclidean_division,
bind_by_move_pattern_guards,

View File

@ -89,7 +89,9 @@ pub fn cdf_irwin_hall<const N: usize>(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.
@ -149,11 +151,7 @@ pub fn uniform_noise(f: impl Fn(usize, Vec2<f64>) -> f32) -> InverseCdf {
// Construct a vector that associates each chunk position with the 1-indexed
// position of the noise in the sorted vector (divided by the vector length).
// This guarantees a uniform distribution among the samples.
//
// 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);