godot_voxel/terrain/voxel_data_loader.h

44 lines
1017 B
C
Raw Normal View History

#ifndef VOXEL_DATA_LOADER_H
#define VOXEL_DATA_LOADER_H
#include "block_thread_manager.h"
class VoxelProvider;
class VoxelBuffer;
class VoxelDataLoader {
public:
struct InputBlockData {
Ref<VoxelBuffer> voxels_to_save;
2019-04-29 13:57:39 -07:00
};
struct OutputBlockData {
Ref<VoxelBuffer> voxels_loaded;
};
struct Processor {
void process_block(const InputBlockData &input, OutputBlockData &output, Vector3i block_position, unsigned int lod);
Ref<VoxelProvider> provider;
int block_size_pow2 = 0;
};
typedef VoxelBlockThreadManager<InputBlockData, OutputBlockData, Processor> Mgr;
typedef Mgr::InputBlock InputBlock;
typedef Mgr::OutputBlock OutputBlock;
typedef Mgr::Input Input;
typedef Mgr::Output Output;
typedef Mgr::Stats Stats;
VoxelDataLoader(int thread_count, Ref<VoxelProvider> provider, int block_size_pow2);
~VoxelDataLoader();
void push(const Input &input) { _mgr->push(input); }
void pop(Output &output) { _mgr->pop(output); }
2019-05-04 17:09:12 -07:00
private:
Mgr *_mgr = nullptr;
};
#endif // VOXEL_DATA_LOADER_H