Made idx_for use idx_for_unchecked internally

This commit is contained in:
Joshua Barretto 2019-06-06 07:42:59 +01:00
parent eb2d1f3278
commit 1b5d2d468b
2 changed files with 2 additions and 5 deletions

View File

@ -32,10 +32,7 @@ impl<V: Vox, S: VolSize, M> Chunk<V, S, M> {
if pos.map(|e| e >= 0).reduce_and()
&& pos.map2(S::SIZE, |e, lim| e < lim as i32).reduce_and()
{
Some(
(pos.x * S::SIZE.y as i32 * S::SIZE.z as i32 + pos.y * S::SIZE.z as i32 + pos.z)
as usize,
)
Some(Self::idx_for_unchecked(pos))
} else {
None
}

View File

@ -27,7 +27,7 @@ impl<V: Vox, M> Dyna<V, M> {
#[inline(always)]
fn idx_for(sz: Vec3<u32>, pos: Vec3<i32>) -> Option<usize> {
if pos.map(|e| e >= 0).reduce_and() && pos.map2(sz, |e, lim| e < lim as i32).reduce_and() {
Some((pos.x * sz.y as i32 * sz.z as i32 + pos.y * sz.z as i32 + pos.z) as usize)
Some(Self::idx_for_unchecked(sz, pos))
} else {
None
}