world/layer: return boxed BlockInfoArray from top_layer()

Avoid copying around large structures, and allow creating
arrays of BlockInfoArrays without overflowing the stack.
This commit is contained in:
Matthias Schiffer 2023-02-26 13:29:04 +01:00
parent fd0c9fbf1b
commit f47b38b2ca
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -92,11 +92,11 @@ pub type BlockInfoArray = LayerBlockArray<Option<BlockInfo>>;
/// determined as the block that should be visible on the rendered
/// map. For water blocks, the height of the first non-water block
/// is additionally filled in as the water depth.
pub fn top_layer(chunk: &Chunk, block_types: &BlockTypeMap) -> Result<BlockInfoArray> {
pub fn top_layer(chunk: &Chunk, block_types: &BlockTypeMap) -> Result<Box<BlockInfoArray>> {
use BLOCKS_PER_CHUNK as N;
let mut done = 0;
let mut ret = BlockInfoArray::default();
let mut ret = Box::<BlockInfoArray>::default();
for ((section_y, section), y, xz) in iproduct!(
chunk.sections().rev(),