CPU Brickmap now requests the correct chunk

This commit is contained in:
Jarrod Doyle 2023-06-27 20:24:26 +01:00
parent 64ddcf7e10
commit 0e1b844f96
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 8 additions and 2 deletions

View File

@ -159,8 +159,14 @@ impl BrickmapManager {
let chunk_y = data[i * 4 + 1]; let chunk_y = data[i * 4 + 1];
let chunk_z = data[i * 4 + 2]; let chunk_z = data[i * 4 + 2];
let chunk_pos = glam::ivec3(0, 0, 0); let chunk_dims = world.get_chunk_dims();
let block_pos = glam::uvec3(chunk_x, chunk_y, chunk_z); 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); let block = world.get_block(chunk_pos, block_pos);
assert_eq!(block.len(), 512); assert_eq!(block.len(), 512);