2022-02-06 05:45:51 -08:00
|
|
|
#ifndef SAVE_BLOCK_DATA_TASK_H
|
|
|
|
#define SAVE_BLOCK_DATA_TASK_H
|
2022-02-02 15:12:59 -08:00
|
|
|
|
2022-04-10 12:10:33 -07: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 {
|
|
|
|
|
2022-02-06 05:45:51 -08:00
|
|
|
class SaveBlockDataTask : public IThreadedTask {
|
2022-02-02 15:12:59 -08:00
|
|
|
public:
|
|
|
|
// For saving voxels only
|
2022-02-06 05:45:51 -08:00
|
|
|
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
|
2022-02-06 05:45:51 -08:00
|
|
|
SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
|
2022-04-10 12:10:33 -07:00
|
|
|
UniquePtr<InstanceBlockData> p_instances, std::shared_ptr<StreamingDependency> p_stream_dependency);
|
2022-02-02 15:12:59 -08:00
|
|
|
|
2022-02-06 05:45:51 -08:00
|
|
|
~SaveBlockDataTask();
|
2022-02-02 15:12:59 -08:00
|
|
|
|
|
|
|
void run(ThreadedTaskContext ctx) override;
|
2022-08-16 13:12:10 -07:00
|
|
|
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;
|
2022-04-10 12:10:33 -07:00
|
|
|
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
|
|
|
|
|
2022-02-06 05:45:51 -08:00
|
|
|
#endif // SAVE_BLOCK_DATA_TASK_H
|