#include <vector>
const int voxel_size = 16;
std::vector<short> get_voxels_from_chunk(short (*voxels)[voxel_size][voxel_size][voxel_size], int world_length, int chunk_size_x, int chunk_size_y, int chunk_size_z, int chunk_id) {
std::vector<short> result;
int chunk_count_x = world_length / chunk_size_x;
int chunk_count_y = world_length / chunk_size_y;
int chunk_count_z = world_length / chunk_size_z;
int chunk_index_x = chunk_id % chunk_count_x;
int chunk_index_y = (chunk_id / chunk_count_x) % chunk_count_y;
int chunk_index_z = chunk_id / (chunk_count_x * chunk_count_y);
int x_offset = chunk_index_x * chunk_size_x;
int y_offset = chunk_index_y * chunk_size_y;
int z_offset = chunk_index_z * chunk_size_z;
for (int i = x_offset; i < x_offset + chunk_size_x; i++){
for (int ii = y_offset; ii < y_offset + chunk_size_y; ii++){
for (int iii = z_offset; iii < z_offset + chunk_size_z; iii++){
result.push_back(*(*(*(voxels + i) + ii) + iii));
}
}
}
return result;
}
int main() {
short voxels[voxel_size][voxel_size][voxel_size]; // пример массива вокселей
int world_length = voxel_size;
int chunk_size_x = 4;
int chunk_size_y = 8;
int chunk_size_z = 8;
int chunk_id = 3; // пример id чанка
std::vector<short> chunk_voxels = get_voxels_from_chunk(&voxels, world_length, chunk_size_x, chunk_size_y, chunk_size_z, chunk_id);
// обработка chunk_voxels
return 0;
}