Fixed collision bugs

This commit is contained in:
Joshua Barretto 2019-06-26 00:09:41 +01:00
parent c2c5b9f5e7
commit 0d984a5671

View File

@ -158,10 +158,14 @@ impl<'a> System<'a> for Sys {
// Basic collision with terrain // Basic collision with terrain
// Iterate through nearby blocks, prioritise closer ones // Iterate through nearby blocks, prioritise closer ones
let near_iter = [0, -1, 1, -2, 2, 3].into_iter() let near_iter = (0..5)
.map(move |k| [0, -1, 1, -2, 2].into_iter() .map(move |dist| (-dist..=dist)
.map(move |j| [0, -1, 1, -2, 2].into_iter() .map(move |x| (-dist..=dist)
.map(move |i| (*i, *j, *k)))) .map(move |y| (-dist..=dist)
.map(move |z| Vec3::new(x, y, z))
.filter(move |p| p.map(|e: i32| e.abs()).reduce_max() == dist)
.map(|p| p.into_tuple()))))
.flatten()
.flatten() .flatten()
.flatten(); .flatten();