2018-09-24 16:54:07 -07:00
|
|
|
#ifndef VOXEL_MESH_UPDATER_H
|
|
|
|
#define VOXEL_MESH_UPDATER_H
|
|
|
|
|
|
|
|
#include <core/os/semaphore.h>
|
|
|
|
#include <core/os/thread.h>
|
2019-04-23 17:29:47 -07:00
|
|
|
#include <core/vector.h>
|
2018-09-24 16:54:07 -07:00
|
|
|
|
2019-04-28 09:58:29 -07:00
|
|
|
#include "../meshers/blocky/voxel_mesher_blocky.h"
|
|
|
|
#include "../meshers/dmc/voxel_mesher_dmc.h"
|
|
|
|
#include "../voxel_buffer.h"
|
2018-09-24 16:54:07 -07:00
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
#include "block_thread_manager.h"
|
|
|
|
|
2018-09-24 16:54:07 -07:00
|
|
|
class VoxelMeshUpdater {
|
|
|
|
public:
|
2019-05-19 10:27:49 -07:00
|
|
|
struct InputBlockData {
|
2018-09-24 16:54:07 -07:00
|
|
|
Ref<VoxelBuffer> voxels;
|
|
|
|
};
|
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
struct OutputBlockData {
|
2019-04-28 12:48:59 -07:00
|
|
|
VoxelMesher::Output blocky_surfaces;
|
|
|
|
VoxelMesher::Output smooth_surfaces;
|
2018-09-24 16:54:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MeshingParams {
|
2019-05-19 10:27:49 -07:00
|
|
|
Ref<VoxelLibrary> library;
|
2019-05-04 08:30:39 -07:00
|
|
|
bool baked_ao = true;
|
|
|
|
float baked_ao_darkness = 0.75;
|
|
|
|
bool smooth_surface = false;
|
2018-09-24 16:54:07 -07:00
|
|
|
};
|
|
|
|
|
2019-08-16 12:56:07 -07:00
|
|
|
typedef VoxelBlockThreadManager<InputBlockData, OutputBlockData> Mgr;
|
2019-05-19 10:27:49 -07:00
|
|
|
typedef Mgr::InputBlock InputBlock;
|
|
|
|
typedef Mgr::OutputBlock OutputBlock;
|
|
|
|
typedef Mgr::Input Input;
|
|
|
|
typedef Mgr::Output Output;
|
|
|
|
typedef Mgr::Stats Stats;
|
2018-09-24 16:54:07 -07:00
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
VoxelMeshUpdater(unsigned int thread_count, MeshingParams params);
|
|
|
|
~VoxelMeshUpdater();
|
2018-09-24 16:54:07 -07:00
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
void push(const Input &input) { _mgr->push(input); }
|
|
|
|
void pop(Output &output) { _mgr->pop(output); }
|
2018-09-24 16:54:07 -07:00
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
int get_required_padding() const { return _required_padding; }
|
2018-09-24 16:54:07 -07:00
|
|
|
|
|
|
|
private:
|
2019-08-16 12:56:07 -07:00
|
|
|
void process_blocks_thread_func(const ArraySlice<InputBlock> inputs,
|
|
|
|
ArraySlice<OutputBlock> outputs,
|
|
|
|
Ref<VoxelMesher> blocky_mesher,
|
|
|
|
Ref<VoxelMesher> smooth_mesher,
|
|
|
|
int padding);
|
|
|
|
|
2019-05-19 10:27:49 -07:00
|
|
|
Mgr *_mgr = nullptr;
|
|
|
|
int _required_padding = 0;
|
2018-09-24 16:54:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_MESH_UPDATER_H
|