godot_voxel/terrain/voxel_data_loader.h

50 lines
1.1 KiB
C
Raw Normal View History

#ifndef VOXEL_DATA_LOADER_H
#define VOXEL_DATA_LOADER_H
#include "block_thread_manager.h"
2019-05-25 08:07:38 -07:00
class VoxelStream;
class VoxelBuffer;
class VoxelDataLoader {
public:
struct InputBlockData {
Ref<VoxelBuffer> voxels_to_save;
2019-04-29 13:57:39 -07:00
};
enum RequestType {
TYPE_SAVE = 0,
TYPE_LOAD
};
struct OutputBlockData {
RequestType type;
Ref<VoxelBuffer> voxels_loaded;
};
struct Processor {
void process_block(const InputBlockData &input, OutputBlockData &output, Vector3i block_position, unsigned int lod);
Ref<VoxelStream> stream;
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<VoxelStream> stream, 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