From a3e36a50ababd615da7db1b26158c7906a5def01 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 23 Feb 2020 18:13:51 +0000 Subject: [PATCH] Simpler terrain spiral rendering --- voxygen/src/scene/terrain.rs | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index e6c34934f6..f51a4b69f1 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -1399,20 +1399,12 @@ impl Terrain { (e as i32).div_euclid(sz as i32) }); - let chunks = &self.chunks; let chunk_iter = Spiral2d::new() - .scan(0, |n, rpos| { - if *n >= chunks.len() { - None - } else { - let pos = focus_chunk + rpos; - Some(chunks.get(&pos).map(|c| { - *n += 1; - (pos, c) - })) - } + .filter_map(|rpos| { + let pos = focus_chunk + rpos; + self.chunks.get(&pos).map(|c| (pos, c)) }) - .filter_map(|x| x); + .take(self.chunks.len()); // Opaque for (_, chunk) in chunk_iter.clone() { @@ -1440,20 +1432,12 @@ impl Terrain { (e as i32).div_euclid(sz as i32) }); - let chunks = &self.chunks; let chunk_iter = Spiral2d::new() - .scan(0, |n, rpos| { - if *n >= chunks.len() { - None - } else { - let pos = focus_chunk + rpos; - Some(chunks.get(&pos).map(|c| { - *n += 1; - (pos, c) - })) - } + .filter_map(|rpos| { + let pos = focus_chunk + rpos; + self.chunks.get(&pos).map(|c| (pos, c)) }) - .filter_map(|x| x); + .take(self.chunks.len()); // Terrain sprites for (pos, chunk) in chunk_iter.clone() {