Abandon tree generation when outside bounds

This commit is contained in:
Joshua Barretto 2020-11-07 22:51:12 +00:00
parent 9b233708e2
commit 1036ce8c7e

View File

@ -7,7 +7,7 @@ use crate::{
}; };
use common::{ use common::{
terrain::{ terrain::{
structure::{Structure, StructureBlock}, structure::Structure,
Block, Block,
}, },
vol::ReadVol, vol::ReadVol,
@ -109,11 +109,16 @@ pub fn apply_trees_to<'a>(canvas: &mut Canvas) {
) + Vec3::unit_z() * (wpos.z - tree.pos.z); ) + Vec3::unit_z() * (wpos.z - tree.pos.z);
block_from_structure( block_from_structure(
info.index(), info.index(),
tree.model if let Some(block) = tree.model
.get(model_pos) .get(model_pos)
.ok() .ok()
.copied() .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, wpos,
tree.pos.xy(), tree.pos.xy(),
tree.seed, tree.seed,