From 0e1b844f960f5c6521bf1e2c01990893f7d2c1ca Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Tue, 27 Jun 2023 20:24:26 +0100 Subject: [PATCH] CPU Brickmap now requests the correct chunk --- src/voxel/brickmap.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/voxel/brickmap.rs b/src/voxel/brickmap.rs index d7e1b4d..8b45eca 100644 --- a/src/voxel/brickmap.rs +++ b/src/voxel/brickmap.rs @@ -159,8 +159,14 @@ impl BrickmapManager { let chunk_y = data[i * 4 + 1]; let chunk_z = data[i * 4 + 2]; - let chunk_pos = glam::ivec3(0, 0, 0); - let block_pos = glam::uvec3(chunk_x, chunk_y, chunk_z); + let chunk_dims = world.get_chunk_dims(); + let global_block_pos = glam::uvec3(chunk_x, chunk_y, chunk_z); + let chunk_pos = glam::ivec3( + (global_block_pos.x / chunk_dims.x) as i32, + (global_block_pos.y / chunk_dims.y) as i32, + (global_block_pos.z / chunk_dims.z) as i32, + ); + let block_pos = global_block_pos % chunk_dims; let block = world.get_block(chunk_pos, block_pos); assert_eq!(block.len(), 512);