From 1036ce8c7eac3a8102bff324b4287a55bae9106f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 7 Nov 2020 22:51:12 +0000 Subject: [PATCH] Abandon tree generation when outside bounds --- world/src/layer/tree.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index b016dcb31e..520d2690c6 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -7,7 +7,7 @@ use crate::{ }; use common::{ terrain::{ - structure::{Structure, StructureBlock}, + structure::Structure, Block, }, vol::ReadVol, @@ -109,11 +109,16 @@ pub fn apply_trees_to<'a>(canvas: &mut Canvas) { ) + Vec3::unit_z() * (wpos.z - tree.pos.z); block_from_structure( info.index(), - tree.model + if let Some(block) = tree.model .get(model_pos) .ok() .copied() - .unwrap_or(StructureBlock::None), + { + block + } else { + // If we hit an inaccessible block, we're probably outside the model bounds. Skip this column. + break; + }, wpos, tree.pos.xy(), tree.seed,