common: For trait ReadVol remove get_unchecked()

This commit is contained in:
haslersn 2019-08-14 22:12:01 +02:00
parent 66c58840ef
commit 57354fb062

View File

@ -79,7 +79,7 @@ impl Chonk {
} }
fn sub_chunk_idx(&self, z: i32) -> usize { fn sub_chunk_idx(&self, z: i32) -> usize {
((z - self.z_offset) as u32 / SUB_CHUNK_HEIGHT as u32) as usize ((z - self.z_offset) as u32 / SUB_CHUNK_HEIGHT) as usize
} }
} }
@ -91,10 +91,10 @@ impl BaseVol for Chonk {
impl ReadVol for Chonk { impl ReadVol for Chonk {
#[inline(always)] #[inline(always)]
fn get(&self, pos: Vec3<i32>) -> Result<&Block, ChonkError> { fn get(&self, pos: Vec3<i32>) -> Result<&Block, ChonkError> {
if pos.z < self.z_offset { if pos.z < self.get_min_z() {
// Below the terrain // Below the terrain
Ok(&self.below) Ok(&self.below)
} else if pos.z >= self.z_offset + SUB_CHUNK_HEIGHT as i32 * self.sub_chunks.len() as i32 { } else if pos.z >= self.get_max_z() {
// Above the terrain // Above the terrain
Ok(&self.above) Ok(&self.above)
} else { } else {