pub fn generate_chunk_topology(chunk: &mut Chunk, block_registry: &Registry<Block>,height_map :  &mut HeightMap) {
    let stone_block = block_registry.get_id_by_name(&"stone".to_owned()).unwrap() as u16;
    let grass_block = block_registry.get_id_by_name(&"grass".to_owned()).unwrap() as u16;
    let dirt_block = block_registry.get_id_by_name(&"dirt".to_owned()).unwrap() as u16;
    let dirt_grass = block_registry
        .get_id_by_name(&"dirt_grass".to_owned())
        .unwrap() as u16;
    let water_block = block_registry.get_id_by_name(&"water".to_owned()).unwrap() as u16;
    let sand_block = block_registry.get_id_by_name(&"sand".to_owned()).unwrap() as u16;

    let h = height_map.get_chunk_height_map(chunk.pos.into());

    for i in 0..CHUNK_SIZE{
        for k in 0..CHUNK_SIZE{
            for j in 0..CHUNK_SIZE{
                let y = j as i32 + (CHUNK_SIZE as i32)*(chunk.pos.py as i32);
                let hm = h[(i*CHUNK_SIZE + k) as usize];
                if y > hm {
                    if y < 0{
                      unsafe{chunk.set_block_at_unsafe((i,j, k), water_block);}
                    }else {
                        break;
                    }
                }else{
                    unsafe {
                        chunk.set_block_at_unsafe((i,j, k),
                        match hm - y {
                            0 => if hm >= 1 {grass_block} else {sand_block},
                            1 => if hm >= 1 {dirt_grass} else {sand_block},
                            2..=4 => if hm >= 1 {dirt_block} else {sand_block},
                            _ => stone_block,
                        });
                    }
                }
            }
        }
    }

}
/// Generate the topology of the chunk
Generate the topology of the chunk
Generate the topology of the chunk
pub fn generate_chunk_topology(chunk: &mut Chunk, block_registry: &Registry<Block>,height_map :  &mut HeightMap) {
    let stone_block = block_registry.get_id_by_name(&"stone".to_owned()).unwrap() as u16;
    let grass_block = block_registry.get_id_by_name(&"grass".to_owned()).unwrap() as u16;
    let dirt_block = block_registry.get_id_by_name(&"dirt".to_owned()).unwrap() as u16;
    let dirt_grass = block_registry
        .get_id_by_name(&"dirt_grass".to_owned())
        .unwrap() as u16;
    let water_block = block_registry.get_id_by_name(&"water".to_owned()).unwrap() as u16;
    let sand_block = block_registry.get_id_by_name(&"sand".to_owned()).unwrap() as u16;
    let h = height_map.get_chunk_height_map(chunk.pos.into());
    for i in 0..CHUNK_SIZE{
        for k in 0..CHUNK_SIZE{
            for j in 0..CHUNK_SIZE{
                let y = j as i32 + (CHUNK_SIZE as i32)*(chunk.pos.py as i32);
                let hm = h[(i*CHUNK_SIZE + k) as usize];
                if y > hm {
                    if y < 0{
                      unsafe{chunk.set_block_at_unsafe((i,j, k), water_block);}
                    }else {
                        break;
                    }
                }else{
                    unsafe {
                        chunk.set_block_at_unsafe((i,j, k),
                        match hm - y {
                            0 => if hm >= 1 {grass_block} else {sand_block},
                            1 => if hm >= 1 {dirt_grass} else {sand_block},
                            2..=4 => if hm >= 1 {dirt_block} else {sand_block},
                            _ => stone_block,
                        });
                    }
                }
            }
        }
    }
}
pub fn generate_chunk_topology ( chunk : & mut Chunk , block_registry : & Registry < Block > , height_map : & mut HeightMap ) { let stone_block = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let grass_block = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let dirt_block = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let dirt_grass = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let water_block = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let sand_block = block_registry . get_id_by_name ( & " " . to_owned ( ) ) . unwrap ( ) as u16 ; let h = height_map . get_chunk_height_map ( chunk . pos . into ( ) ) ; for i in 0 .. CHUNK_SIZE { for k in 0 .. CHUNK_SIZE { for j in 0 .. CHUNK_SIZE { let y = j as i32 + ( CHUNK_SIZE as i32 ) * ( chunk . pos . py as i32 ) ; let hm = h [ ( i * CHUNK_SIZE + k ) as usize ] ; if y > hm { if y < 0 { unsafe { chunk . set_block_at_unsafe ( ( i , j , k ) , water_block ) ; } } else { break ; } } else { unsafe { chunk . set_block_at_unsafe ( ( i , j , k ) , match hm - y { 0 => if hm >= 1 { grass_block } else { sand_block } , 1 => if hm >= 1 { dirt_grass } else { sand_block } , 2 ..= 4 => if hm >= 1 { dirt_block } else { sand_block } , _ => stone_block , } ) ; } } } } } }
Generate the topology of the chunk
Generate the topology of the chunk
chunk
&mut Chunk
block_registry
&Registry<Block>
height_map
&mut HeightMap
chunk
&mut Chunk
block_registry
&Registry<Block>
height_map
&mut HeightMap