Rename VoxelStreamVXB => VoxelStreamBlockFiles
This commit is contained in:
parent
fbeaae6bac
commit
ece3a355af
@ -7,7 +7,7 @@
|
|||||||
#include "streams/voxel_stream_noise.h"
|
#include "streams/voxel_stream_noise.h"
|
||||||
#include "streams/voxel_stream_region.h"
|
#include "streams/voxel_stream_region.h"
|
||||||
#include "streams/voxel_stream_test.h"
|
#include "streams/voxel_stream_test.h"
|
||||||
#include "streams/voxel_stream_vxb.h"
|
#include "streams/voxel_stream_block_files.h"
|
||||||
#include "terrain/voxel_box_mover.h"
|
#include "terrain/voxel_box_mover.h"
|
||||||
#include "terrain/voxel_lod_terrain.h"
|
#include "terrain/voxel_lod_terrain.h"
|
||||||
#include "terrain/voxel_map.h"
|
#include "terrain/voxel_map.h"
|
||||||
@ -36,7 +36,7 @@ void register_voxel_types() {
|
|||||||
ClassDB::register_class<VoxelStreamImage>();
|
ClassDB::register_class<VoxelStreamImage>();
|
||||||
ClassDB::register_class<VoxelStreamNoise>();
|
ClassDB::register_class<VoxelStreamNoise>();
|
||||||
ClassDB::register_class<VoxelStreamFile>();
|
ClassDB::register_class<VoxelStreamFile>();
|
||||||
ClassDB::register_class<VoxelStreamVXB>();
|
ClassDB::register_class<VoxelStreamBlockFiles>();
|
||||||
ClassDB::register_class<VoxelStreamRegion>();
|
ClassDB::register_class<VoxelStreamRegion>();
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "voxel_stream_vxb.h"
|
#include "voxel_stream_block_files.h"
|
||||||
#include "../util/utility.h"
|
#include "../util/utility.h"
|
||||||
#include "file_utils.h"
|
#include "file_utils.h"
|
||||||
#include <core/os/dir_access.h>
|
#include <core/os/dir_access.h>
|
||||||
@ -13,7 +13,7 @@ const char *META_FILE_NAME = "meta.vxbm";
|
|||||||
const char *BLOCK_FILE_EXTENSION = ".vxb";
|
const char *BLOCK_FILE_EXTENSION = ".vxb";
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
VoxelStreamVXB::VoxelStreamVXB() {
|
VoxelStreamBlockFiles::VoxelStreamBlockFiles() {
|
||||||
// Defaults
|
// Defaults
|
||||||
_meta.block_size = DEFAULT_BLOCK_SIZE;
|
_meta.block_size = DEFAULT_BLOCK_SIZE;
|
||||||
_meta.lod_count = 1;
|
_meta.lod_count = 1;
|
||||||
@ -22,7 +22,7 @@ VoxelStreamVXB::VoxelStreamVXB() {
|
|||||||
|
|
||||||
// TODO Have configurable block size
|
// TODO Have configurable block size
|
||||||
|
|
||||||
void VoxelStreamVXB::emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) {
|
void VoxelStreamBlockFiles::emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) {
|
||||||
|
|
||||||
ERR_FAIL_COND(out_buffer.is_null());
|
ERR_FAIL_COND(out_buffer.is_null());
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ void VoxelStreamVXB::emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_i
|
|||||||
memdelete(f);
|
memdelete(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelStreamVXB::immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) {
|
void VoxelStreamBlockFiles::immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) {
|
||||||
|
|
||||||
ERR_FAIL_COND(_directory_path.empty());
|
ERR_FAIL_COND(_directory_path.empty());
|
||||||
ERR_FAIL_COND(buffer.is_null());
|
ERR_FAIL_COND(buffer.is_null());
|
||||||
@ -113,18 +113,18 @@ void VoxelStreamVXB::immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String VoxelStreamVXB::get_directory() const {
|
String VoxelStreamBlockFiles::get_directory() const {
|
||||||
return _directory_path;
|
return _directory_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelStreamVXB::set_directory(String dirpath) {
|
void VoxelStreamBlockFiles::set_directory(String dirpath) {
|
||||||
if (_directory_path != dirpath) {
|
if (_directory_path != dirpath) {
|
||||||
_directory_path = dirpath;
|
_directory_path = dirpath;
|
||||||
_meta.loaded = false;
|
_meta.loaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error VoxelStreamVXB::save_meta() {
|
Error VoxelStreamBlockFiles::save_meta() {
|
||||||
|
|
||||||
CRASH_COND(_directory_path.empty());
|
CRASH_COND(_directory_path.empty());
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ Error VoxelStreamVXB::save_meta() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error VoxelStreamVXB::load_meta() {
|
Error VoxelStreamBlockFiles::load_meta() {
|
||||||
CRASH_COND(_directory_path.empty());
|
CRASH_COND(_directory_path.empty());
|
||||||
|
|
||||||
String meta_path = _directory_path.plus_file(META_FILE_NAME);
|
String meta_path = _directory_path.plus_file(META_FILE_NAME);
|
||||||
@ -190,7 +190,7 @@ Error VoxelStreamVXB::load_meta() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
String VoxelStreamVXB::get_block_file_path(const Vector3i &block_pos, unsigned int lod) const {
|
String VoxelStreamBlockFiles::get_block_file_path(const Vector3i &block_pos, unsigned int lod) const {
|
||||||
// TODO This is probably extremely inefficient, also given the nature of Godot strings
|
// TODO This is probably extremely inefficient, also given the nature of Godot strings
|
||||||
|
|
||||||
// Save under a folder, because there could be other kinds of data to store in this terrain
|
// Save under a folder, because there could be other kinds of data to store in this terrain
|
||||||
@ -207,14 +207,14 @@ String VoxelStreamVXB::get_block_file_path(const Vector3i &block_pos, unsigned i
|
|||||||
return _directory_path.plus_file(path);
|
return _directory_path.plus_file(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3i VoxelStreamVXB::get_block_position(const Vector3i &origin_in_voxels) const {
|
Vector3i VoxelStreamBlockFiles::get_block_position(const Vector3i &origin_in_voxels) const {
|
||||||
return origin_in_voxels.udiv(_meta.block_size);
|
return origin_in_voxels.udiv(_meta.block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelStreamVXB::_bind_methods() {
|
void VoxelStreamBlockFiles::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_directory", "directory"), &VoxelStreamVXB::set_directory);
|
ClassDB::bind_method(D_METHOD("set_directory", "directory"), &VoxelStreamBlockFiles::set_directory);
|
||||||
ClassDB::bind_method(D_METHOD("get_directory"), &VoxelStreamVXB::get_directory);
|
ClassDB::bind_method(D_METHOD("get_directory"), &VoxelStreamBlockFiles::get_directory);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "directory"), "set_directory", "get_directory");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "directory"), "set_directory", "get_directory");
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef VOXEL_STREAM_VXB_H
|
#ifndef VOXEL_STREAM_BLOCK_FILES_H
|
||||||
#define VOXEL_STREAM_VXB_H
|
#define VOXEL_STREAM_BLOCK_FILES_H
|
||||||
|
|
||||||
#include "voxel_stream_file.h"
|
#include "voxel_stream_file.h"
|
||||||
|
|
||||||
@ -7,10 +7,10 @@ class FileAccess;
|
|||||||
|
|
||||||
// Loads and saves blocks to the filesystem, under a directory.
|
// Loads and saves blocks to the filesystem, under a directory.
|
||||||
// Each block gets its own file, which may produce a lot of them, but it makes it simple to implement.
|
// Each block gets its own file, which may produce a lot of them, but it makes it simple to implement.
|
||||||
class VoxelStreamVXB : public VoxelStreamFile {
|
class VoxelStreamBlockFiles : public VoxelStreamFile {
|
||||||
GDCLASS(VoxelStreamVXB, VoxelStreamFile)
|
GDCLASS(VoxelStreamBlockFiles, VoxelStreamFile)
|
||||||
public:
|
public:
|
||||||
VoxelStreamVXB();
|
VoxelStreamBlockFiles();
|
||||||
|
|
||||||
void emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) override;
|
void emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) override;
|
||||||
void immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) override;
|
void immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) override;
|
||||||
@ -42,4 +42,4 @@ private:
|
|||||||
Meta _meta;
|
Meta _meta;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VOXEL_STREAM_VXB_H
|
#endif // VOXEL_STREAM_BLOCK_FILES_H
|
Loading…
x
Reference in New Issue
Block a user