2019-05-28 00:40:09 +01:00
|
|
|
#ifndef VOXEL_STREAM_FILE_H
|
|
|
|
#define VOXEL_STREAM_FILE_H
|
|
|
|
|
2019-08-17 18:15:16 +01:00
|
|
|
#include "voxel_block_serializer.h"
|
2019-05-28 00:40:09 +01:00
|
|
|
#include "voxel_stream.h"
|
|
|
|
|
2019-08-14 20:34:06 +01:00
|
|
|
class FileAccess;
|
|
|
|
|
|
|
|
// TODO Could be worth integrating with Godot ResourceLoader
|
2019-05-28 00:40:09 +01:00
|
|
|
// Loads and saves blocks to the filesystem.
|
|
|
|
// If a block is not found, a fallback stream can be used (usually to generate the block).
|
|
|
|
// Look at subclasses of this for a specific format.
|
|
|
|
class VoxelStreamFile : public VoxelStream {
|
|
|
|
GDCLASS(VoxelStreamFile, VoxelStream)
|
|
|
|
public:
|
2019-08-14 20:34:06 +01:00
|
|
|
void set_save_fallback_output(bool enabled);
|
|
|
|
bool get_save_fallback_output() const;
|
|
|
|
|
2019-05-28 00:40:09 +01:00
|
|
|
Ref<VoxelStream> get_fallback_stream() const;
|
|
|
|
void set_fallback_stream(Ref<VoxelStream> stream);
|
|
|
|
|
2019-08-24 01:44:27 +01:00
|
|
|
// File streams are likely to impose a specific block size,
|
|
|
|
// and changing it can be very expensive so the API is usually specific too
|
|
|
|
virtual int get_block_size_po2() const;
|
|
|
|
virtual int get_lod_count() const;
|
|
|
|
|
2020-07-26 18:42:17 +01:00
|
|
|
int get_used_channels_mask() const override;
|
|
|
|
|
2020-08-14 20:33:09 +01:00
|
|
|
bool has_script() const override;
|
|
|
|
|
2019-05-28 00:40:09 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
void emerge_block_fallback(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod);
|
2020-01-26 22:34:26 +00:00
|
|
|
void emerge_blocks_fallback(Vector<VoxelBlockRequest> &requests);
|
2019-08-14 20:34:06 +01:00
|
|
|
|
2019-08-18 16:10:40 +01:00
|
|
|
FileAccess *open_file(const String &fpath, int mode_flags, Error *err);
|
|
|
|
|
2020-07-25 21:56:23 +01:00
|
|
|
VoxelBlockSerializerInternal _block_serializer;
|
2019-05-28 00:40:09 +01:00
|
|
|
|
|
|
|
private:
|
2019-08-24 01:44:27 +01:00
|
|
|
Vector3 _get_block_size() const;
|
|
|
|
|
2019-05-28 00:40:09 +01:00
|
|
|
Ref<VoxelStream> _fallback_stream;
|
2019-08-14 20:34:06 +01:00
|
|
|
bool _save_fallback_output = true;
|
2019-05-28 00:40:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_STREAM_FILE_H
|