godot_voxel/engine/save_block_data_task.h

45 lines
1.3 KiB
C
Raw Normal View History

#ifndef SAVE_BLOCK_DATA_TASK_H
#define SAVE_BLOCK_DATA_TASK_H
2022-02-02 15:12:59 -08:00
#include "../util/memory.h"
2022-02-02 15:12:59 -08:00
#include "../util/tasks/threaded_task.h"
#include "streaming_dependency.h"
namespace zylann::voxel {
class SaveBlockDataTask : public IThreadedTask {
2022-02-02 15:12:59 -08:00
public:
// For saving voxels only
SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
2022-02-02 15:12:59 -08:00
std::shared_ptr<VoxelBufferInternal> p_voxels, std::shared_ptr<StreamingDependency> p_stream_dependency);
// For saving instances only
SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
UniquePtr<InstanceBlockData> p_instances, std::shared_ptr<StreamingDependency> p_stream_dependency);
2022-02-02 15:12:59 -08:00
~SaveBlockDataTask();
2022-02-02 15:12:59 -08:00
void run(ThreadedTaskContext ctx) override;
TaskPriority get_priority() override;
2022-02-02 15:12:59 -08:00
bool is_cancelled() override;
void apply_result() override;
static int debug_get_running_count();
private:
std::shared_ptr<VoxelBufferInternal> _voxels;
UniquePtr<InstanceBlockData> _instances;
2022-02-02 15:12:59 -08:00
Vector3i _position; // In data blocks of the specified lod
uint32_t _volume_id;
uint8_t _lod;
uint8_t _block_size;
bool _has_run = false;
bool _save_instances = false;
bool _save_voxels = false;
std::shared_ptr<StreamingDependency> _stream_dependency;
};
} // namespace zylann::voxel
#endif // SAVE_BLOCK_DATA_TASK_H