mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made idx_for use idx_for_unchecked internally
This commit is contained in:
@ -32,10 +32,7 @@ impl<V: Vox, S: VolSize, M> Chunk<V, S, M> {
|
|||||||
if pos.map(|e| e >= 0).reduce_and()
|
if pos.map(|e| e >= 0).reduce_and()
|
||||||
&& pos.map2(S::SIZE, |e, lim| e < lim as i32).reduce_and()
|
&& pos.map2(S::SIZE, |e, lim| e < lim as i32).reduce_and()
|
||||||
{
|
{
|
||||||
Some(
|
Some(Self::idx_for_unchecked(pos))
|
||||||
(pos.x * S::SIZE.y as i32 * S::SIZE.z as i32 + pos.y * S::SIZE.z as i32 + pos.z)
|
|
||||||
as usize,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ impl<V: Vox, M> Dyna<V, M> {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn idx_for(sz: Vec3<u32>, pos: Vec3<i32>) -> Option<usize> {
|
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() {
|
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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user