Simpler terrain spiral rendering

This commit is contained in:
Joshua Barretto 2020-02-23 18:13:51 +00:00
parent 255f450ae9
commit a3e36a50ab

View File

@ -1399,20 +1399,12 @@ impl<V: RectRasterableVol> Terrain<V> {
(e as i32).div_euclid(sz as i32) (e as i32).div_euclid(sz as i32)
}); });
let chunks = &self.chunks;
let chunk_iter = Spiral2d::new() let chunk_iter = Spiral2d::new()
.scan(0, |n, rpos| { .filter_map(|rpos| {
if *n >= chunks.len() { let pos = focus_chunk + rpos;
None self.chunks.get(&pos).map(|c| (pos, c))
} else {
let pos = focus_chunk + rpos;
Some(chunks.get(&pos).map(|c| {
*n += 1;
(pos, c)
}))
}
}) })
.filter_map(|x| x); .take(self.chunks.len());
// Opaque // Opaque
for (_, chunk) in chunk_iter.clone() { for (_, chunk) in chunk_iter.clone() {
@ -1440,20 +1432,12 @@ impl<V: RectRasterableVol> Terrain<V> {
(e as i32).div_euclid(sz as i32) (e as i32).div_euclid(sz as i32)
}); });
let chunks = &self.chunks;
let chunk_iter = Spiral2d::new() let chunk_iter = Spiral2d::new()
.scan(0, |n, rpos| { .filter_map(|rpos| {
if *n >= chunks.len() { let pos = focus_chunk + rpos;
None self.chunks.get(&pos).map(|c| (pos, c))
} else {
let pos = focus_chunk + rpos;
Some(chunks.get(&pos).map(|c| {
*n += 1;
(pos, c)
}))
}
}) })
.filter_map(|x| x); .take(self.chunks.len());
// Terrain sprites // Terrain sprites
for (pos, chunk) in chunk_iter.clone() { for (pos, chunk) in chunk_iter.clone() {