Namespaced VoxelBuffer in `gd::` because it is actually a wrapper

master
Marc Gilleron 2022-02-15 21:49:20 +00:00
parent 1c2f0fd983
commit 0137ca3036
40 changed files with 151 additions and 132 deletions

View File

@ -1,5 +1,5 @@
#include "voxel_tool.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/macros.h"
#include "../util/profiling.h"
@ -115,7 +115,7 @@ void VoxelTool::do_point(Vector3i pos) {
if (!is_area_editable(box)) {
return;
}
if (_channel == VoxelBuffer::CHANNEL_SDF) {
if (_channel == VoxelBufferInternal::CHANNEL_SDF) {
_set_voxel_f(pos, _mode == MODE_REMOVE ? 1.0 : -1.0);
} else {
_set_voxel(pos, _mode == MODE_REMOVE ? _eraser_value : _value);
@ -189,7 +189,7 @@ void VoxelTool::do_sphere(Vector3 center, float radius) {
return;
}
if (_channel == VoxelBuffer::CHANNEL_SDF) {
if (_channel == VoxelBufferInternal::CHANNEL_SDF) {
box.for_each_cell([this, center, radius](Vector3i pos) {
float d = _sdf_scale * zylann::math::sdf_sphere(pos, center, radius);
_set_voxel_f(pos, sdf_blend(d, get_voxel_f(pos), _mode));
@ -210,9 +210,10 @@ void VoxelTool::do_sphere(Vector3 center, float radius) {
}
// Erases matter in every voxel where the provided buffer has matter.
void VoxelTool::sdf_stamp_erase(Ref<VoxelBuffer> stamp, Vector3i pos) {
void VoxelTool::sdf_stamp_erase(Ref<gd::VoxelBuffer> stamp, Vector3i pos) {
VOXEL_PROFILE_SCOPE();
ERR_FAIL_COND_MSG(get_channel() != VoxelBuffer::CHANNEL_SDF, "This function only works when channel is set to SDF");
ERR_FAIL_COND_MSG(
get_channel() != VoxelBufferInternal::CHANNEL_SDF, "This function only works when channel is set to SDF");
const Box3i box(pos, stamp->get_buffer().get_size());
if (!is_area_editable(box)) {
@ -223,7 +224,7 @@ void VoxelTool::sdf_stamp_erase(Ref<VoxelBuffer> stamp, Vector3i pos) {
box.for_each_cell_zxy([this, stamp, pos](Vector3i pos_in_volume) {
const Vector3i pos_in_stamp = pos_in_volume - pos;
const float dst_sdf =
stamp->get_voxel_f(pos_in_stamp.x, pos_in_stamp.y, pos_in_stamp.z, VoxelBuffer::CHANNEL_SDF);
stamp->get_voxel_f(pos_in_stamp.x, pos_in_stamp.y, pos_in_stamp.z, VoxelBufferInternal::CHANNEL_SDF);
if (dst_sdf <= 0.f) {
_set_voxel_f(pos_in_volume, 1.f);
}
@ -242,7 +243,7 @@ void VoxelTool::do_box(Vector3i begin, Vector3i end) {
return;
}
if (_channel == VoxelBuffer::CHANNEL_SDF) {
if (_channel == VoxelBufferInternal::CHANNEL_SDF) {
// TODO Better quality
box.for_each_cell([this](Vector3i pos) { _set_voxel_f(pos, sdf_blend(-1.0, get_voxel_f(pos), _mode)); });
@ -254,13 +255,13 @@ void VoxelTool::do_box(Vector3i begin, Vector3i end) {
_post_edit(box);
}
void VoxelTool::copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channel_mask) const {
void VoxelTool::copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channel_mask) const {
ERR_FAIL_COND(dst.is_null());
ERR_PRINT("Not implemented");
}
void VoxelTool::paste(
Vector3i p_pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
Vector3i p_pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
ERR_FAIL_COND(p_voxels.is_null());
ERR_PRINT("Not implemented");
}
@ -283,11 +284,11 @@ Variant VoxelTool::get_voxel_metadata(Vector3i pos) const {
return Variant();
}
void VoxelTool::_b_copy(Vector3i pos, Ref<VoxelBuffer> voxels, int channel_mask) {
void VoxelTool::_b_copy(Vector3i pos, Ref<gd::VoxelBuffer> voxels, int channel_mask) {
copy(pos, voxels, channel_mask);
}
void VoxelTool::_b_paste(Vector3i pos, Ref<VoxelBuffer> voxels, int channels_mask, int64_t mask_value) {
void VoxelTool::_b_paste(Vector3i pos, Ref<gd::VoxelBuffer> voxels, int channels_mask, int64_t mask_value) {
// TODO May need two functions, one masked, one not masked, or add a parameter, but it breaks compat
paste(pos, voxels, channels_mask, mask_value > 0xffffffff, mask_value);
}
@ -338,7 +339,7 @@ void VoxelTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_area_editable", "box"), &VoxelTool::_b_is_area_editable);
ADD_PROPERTY(PropertyInfo(Variant::INT, "value"), "set_value", "get_value");
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, VoxelBuffer::CHANNEL_ID_HINT_STRING),
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, gd::VoxelBuffer::CHANNEL_ID_HINT_STRING),
"set_channel", "get_channel");
ADD_PROPERTY(PropertyInfo(Variant::INT, "eraser_value"), "set_eraser_value", "get_eraser_value");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Remove,Set"), "set_mode", "get_mode");

View File

@ -7,7 +7,7 @@
#include "funcs.h"
#include "voxel_raycast_result.h"
namespace zylann::voxel {
namespace zylann::voxel::gd {
class VoxelBuffer;
}
@ -140,11 +140,11 @@ public:
virtual void do_sphere(Vector3 center, float radius);
virtual void do_box(Vector3i begin, Vector3i end);
void sdf_stamp_erase(Ref<VoxelBuffer> stamp, Vector3i pos);
void sdf_stamp_erase(Ref<gd::VoxelBuffer> stamp, Vector3i pos);
virtual void copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels_mask) const;
virtual void copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const;
virtual void paste(
Vector3i pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value);
Vector3i pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value);
virtual Ref<VoxelRaycastResult> raycast(Vector3 pos, Vector3 dir, float max_distance, uint32_t collision_mask);
@ -199,8 +199,8 @@ private:
void _b_do_box(Vector3i begin, Vector3i end) {
do_box(begin, end);
}
void _b_copy(Vector3i pos, Ref<VoxelBuffer> voxels, int channel_mask);
void _b_paste(Vector3i pos, Ref<VoxelBuffer> voxels, int channels_mask, int64_t mask_value);
void _b_copy(Vector3i pos, Ref<gd::VoxelBuffer> voxels, int channel_mask);
void _b_paste(Vector3i pos, Ref<gd::VoxelBuffer> voxels, int channels_mask, int64_t mask_value);
Variant _b_get_voxel_metadata(Vector3i pos) const {
return get_voxel_metadata(pos);

View File

@ -1,11 +1,11 @@
#include "voxel_tool_buffer.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/profiling.h"
#include "funcs.h"
namespace zylann::voxel {
VoxelToolBuffer::VoxelToolBuffer(Ref<VoxelBuffer> vb) {
VoxelToolBuffer::VoxelToolBuffer(Ref<gd::VoxelBuffer> vb) {
ERR_FAIL_COND(vb.is_null());
_buffer = vb;
}
@ -73,7 +73,7 @@ Variant VoxelToolBuffer::get_voxel_metadata(Vector3i pos) const {
}
void VoxelToolBuffer::paste(
Vector3i p_pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
Vector3i p_pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
// TODO Support `use_mask` properly
if (use_mask) {
mask_value = 0xffffffffffffffff;

View File

@ -9,10 +9,10 @@ class VoxelToolBuffer : public VoxelTool {
GDCLASS(VoxelToolBuffer, VoxelTool)
public:
VoxelToolBuffer() {}
VoxelToolBuffer(Ref<VoxelBuffer> vb);
VoxelToolBuffer(Ref<gd::VoxelBuffer> vb);
bool is_area_editable(const Box3i &box) const override;
void paste(Vector3i p_pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask,
void paste(Vector3i p_pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask,
uint64_t mask_value) override;
void set_voxel_metadata(Vector3i pos, Variant meta) override;
@ -28,7 +28,7 @@ protected:
void _post_edit(const Box3i &box) override;
private:
Ref<VoxelBuffer> _buffer;
Ref<gd::VoxelBuffer> _buffer;
};
} // namespace zylann::voxel

View File

@ -1,6 +1,6 @@
#include "voxel_tool_lod_terrain.h"
#include "../constants/voxel_string_names.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../storage/voxel_data_grid.h"
#include "../terrain/voxel_lod_terrain.h"
#include "../util/funcs.h"
@ -322,7 +322,7 @@ void VoxelToolLodTerrain::do_sphere_async(Vector3 center, float radius) {
_terrain->push_async_edit(task, op.box, task->get_tracker());
}
void VoxelToolLodTerrain::copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels_mask) const {
void VoxelToolLodTerrain::copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const {
ERR_FAIL_COND(_terrain == nullptr);
ERR_FAIL_COND(dst.is_null());
if (channels_mask == 0) {
@ -404,7 +404,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
static const int main_channel = VoxelBufferInternal::CHANNEL_SDF;
// TODO We should be able to use `VoxelBufferInternal`, just needs some things exposed
Ref<VoxelBuffer> source_copy_buffer_ref;
Ref<gd::VoxelBuffer> source_copy_buffer_ref;
{
VOXEL_PROFILE_SCOPE_NAMED("Copy");
source_copy_buffer_ref.instantiate();
@ -512,7 +512,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
// Create voxel buffer for each group
struct InstanceInfo {
Ref<VoxelBuffer> voxels;
Ref<gd::VoxelBuffer> voxels;
Vector3i world_pos;
unsigned int label;
};
@ -537,7 +537,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
local_bounds.max_pos - local_bounds.min_pos + Vector3iUtil::create(1 + max_padding + min_padding);
// TODO We should be able to use `VoxelBufferInternal`, just needs some things exposed
Ref<VoxelBuffer> buffer_ref;
Ref<gd::VoxelBuffer> buffer_ref;
buffer_ref.instantiate();
buffer_ref->create(size.x, size.y, size.z);

View File

@ -25,7 +25,7 @@ public:
void do_sphere(Vector3 center, float radius) override;
void do_sphere_async(Vector3 center, float radius);
void copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels_mask) const override;
void copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const override;
// Specialized API

View File

@ -1,7 +1,7 @@
#include "voxel_tool_terrain.h"
#include "../meshers/blocky/voxel_mesher_blocky.h"
#include "../meshers/cubes/voxel_mesher_cubes.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../terrain/voxel_terrain.h"
#include "../util/godot/funcs.h"
#include "../util/voxel_raycast.h"
@ -136,7 +136,7 @@ Ref<VoxelRaycastResult> VoxelToolTerrain::raycast(
return res;
}
void VoxelToolTerrain::copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels_mask) const {
void VoxelToolTerrain::copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const {
ERR_FAIL_COND(_terrain == nullptr);
ERR_FAIL_COND(dst.is_null());
if (channels_mask == 0) {
@ -146,7 +146,7 @@ void VoxelToolTerrain::copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels
}
void VoxelToolTerrain::paste(
Vector3i pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
Vector3i pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask, uint64_t mask_value) {
ERR_FAIL_COND(_terrain == nullptr);
ERR_FAIL_COND(p_voxels.is_null());
if (channels_mask == 0) {

View File

@ -22,8 +22,8 @@ public:
void set_voxel_metadata(Vector3i pos, Variant meta) override;
Variant get_voxel_metadata(Vector3i pos) const override;
void copy(Vector3i pos, Ref<VoxelBuffer> dst, uint8_t channels_mask) const override;
void paste(Vector3i pos, Ref<VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask,
void copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const override;
void paste(Vector3i pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask,
uint64_t mask_value) override;
void do_sphere(Vector3 center, float radius) override;

View File

@ -1,7 +1,7 @@
#include "vox_scene_importer.h"
#include "../../constants/voxel_string_names.h"
#include "../../meshers/cubes/voxel_mesher_cubes.h"
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_gd.h"
#include "../../streams/vox_data.h"
#include "../../util/godot/funcs.h"
#include "../../util/profiling.h"
@ -285,10 +285,10 @@ Error VoxelVoxSceneImporter::import(const String &p_source_file, const String &p
VoxelBufferInternal voxels;
voxels.create(model.size + Vector3iUtil::create(VoxelMesherCubes::PADDING * 2));
voxels.decompress_channel(VoxelBuffer::CHANNEL_COLOR);
voxels.decompress_channel(VoxelBufferInternal::CHANNEL_COLOR);
Span<uint8_t> dst_color_indices;
ERR_FAIL_COND_V(!voxels.get_channel_raw(VoxelBuffer::CHANNEL_COLOR, dst_color_indices), ERR_BUG);
ERR_FAIL_COND_V(!voxels.get_channel_raw(VoxelBufferInternal::CHANNEL_COLOR, dst_color_indices), ERR_BUG);
Span<const uint8_t> src_color_indices = to_span_const(model.color_indexes);
copy_3d_region_zxy(dst_color_indices, voxels.get_size(), Vector3iUtil::create(VoxelMesherCubes::PADDING),
src_color_indices, model.size, Vector3i(), model.size);

View File

@ -64,7 +64,7 @@ VoxelGenerator::Result VoxelGeneratorFlat::generate_block(VoxelGenerator::VoxelQ
const Vector3i origin = input.origin_in_voxels;
const int channel = params.channel;
const Vector3i bs = out_buffer.get_size();
const bool use_sdf = channel == VoxelBuffer::CHANNEL_SDF;
const bool use_sdf = channel == VoxelBufferInternal::CHANNEL_SDF;
const float margin = 1 << input.lod;
const int lod = input.lod;
@ -119,12 +119,12 @@ VoxelGenerator::Result VoxelGeneratorFlat::generate_block(VoxelGenerator::VoxelQ
return result;
}
void VoxelGeneratorFlat::_b_set_channel(VoxelBuffer::ChannelId p_channel) {
void VoxelGeneratorFlat::_b_set_channel(gd::VoxelBuffer::ChannelId p_channel) {
set_channel(VoxelBufferInternal::ChannelId(p_channel));
}
VoxelBuffer::ChannelId VoxelGeneratorFlat::_b_get_channel() const {
return VoxelBuffer::ChannelId(get_channel());
gd::VoxelBuffer::ChannelId VoxelGeneratorFlat::_b_get_channel() const {
return gd::VoxelBuffer::ChannelId(get_channel());
}
void VoxelGeneratorFlat::_bind_methods() {
@ -137,7 +137,7 @@ void VoxelGeneratorFlat::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_height", "h"), &VoxelGeneratorFlat::set_height);
ClassDB::bind_method(D_METHOD("get_height"), &VoxelGeneratorFlat::get_height);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, VoxelBuffer::CHANNEL_ID_HINT_STRING),
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, gd::VoxelBuffer::CHANNEL_ID_HINT_STRING),
"set_channel", "get_channel");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "voxel_type", PROPERTY_HINT_RANGE, "0,65536,1"), "set_voxel_type",

View File

@ -1,7 +1,7 @@
#ifndef VOXEL_GENERATOR_FLAT_H
#define VOXEL_GENERATOR_FLAT_H
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_gd.h"
#include "../voxel_generator.h"
namespace zylann::voxel {
@ -29,8 +29,8 @@ protected:
static void _bind_methods();
private:
void _b_set_channel(VoxelBuffer::ChannelId p_channel);
VoxelBuffer::ChannelId _b_get_channel() const;
void _b_set_channel(gd::VoxelBuffer::ChannelId p_channel);
gd::VoxelBuffer::ChannelId _b_get_channel() const;
struct Parameters {
VoxelBufferInternal::ChannelId channel = VoxelBufferInternal::CHANNEL_SDF;

View File

@ -63,12 +63,12 @@ float VoxelGeneratorHeightmap::get_iso_scale() const {
return _parameters.iso_scale;
}
void VoxelGeneratorHeightmap::_b_set_channel(VoxelBuffer::ChannelId p_channel) {
void VoxelGeneratorHeightmap::_b_set_channel(gd::VoxelBuffer::ChannelId p_channel) {
set_channel(VoxelBufferInternal::ChannelId(p_channel));
}
VoxelBuffer::ChannelId VoxelGeneratorHeightmap::_b_get_channel() const {
return VoxelBuffer::ChannelId(get_channel());
gd::VoxelBuffer::ChannelId VoxelGeneratorHeightmap::_b_get_channel() const {
return gd::VoxelBuffer::ChannelId(get_channel());
}
void VoxelGeneratorHeightmap::_bind_methods() {
@ -84,7 +84,7 @@ void VoxelGeneratorHeightmap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_iso_scale", "scale"), &VoxelGeneratorHeightmap::set_iso_scale);
ClassDB::bind_method(D_METHOD("get_iso_scale"), &VoxelGeneratorHeightmap::get_iso_scale);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, VoxelBuffer::CHANNEL_ID_HINT_STRING),
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, gd::VoxelBuffer::CHANNEL_ID_HINT_STRING),
"set_channel", "get_channel");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height_start"), "set_height_start", "get_height_start");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height_range"), "set_height_range", "get_height_range");

View File

@ -1,7 +1,7 @@
#ifndef VOXEL_GENERATOR_HEIGHTMAP_H
#define VOXEL_GENERATOR_HEIGHTMAP_H
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_gd.h"
#include "../voxel_generator.h"
#include <core/io/image.h>
@ -29,8 +29,8 @@ public:
float get_iso_scale() const;
protected:
void _b_set_channel(VoxelBuffer::ChannelId p_channel);
VoxelBuffer::ChannelId _b_get_channel() const;
void _b_set_channel(gd::VoxelBuffer::ChannelId p_channel);
gd::VoxelBuffer::ChannelId _b_get_channel() const;
template <typename Height_F>
Result generate(VoxelBufferInternal &out_buffer, Height_F height_func, Vector3i origin, int lod) {

View File

@ -227,12 +227,12 @@ VoxelGenerator::Result VoxelGeneratorNoise::generate_block(VoxelGenerator::Voxel
return result;
}
void VoxelGeneratorNoise::_b_set_channel(VoxelBuffer::ChannelId p_channel) {
void VoxelGeneratorNoise::_b_set_channel(gd::VoxelBuffer::ChannelId p_channel) {
set_channel(VoxelBufferInternal::ChannelId(p_channel));
}
VoxelBuffer::ChannelId VoxelGeneratorNoise::_b_get_channel() const {
return VoxelBuffer::ChannelId(get_channel());
gd::VoxelBuffer::ChannelId VoxelGeneratorNoise::_b_get_channel() const {
return gd::VoxelBuffer::ChannelId(get_channel());
}
void VoxelGeneratorNoise::_bind_methods() {
@ -250,7 +250,7 @@ void VoxelGeneratorNoise::_bind_methods() {
ClassDB::bind_method(D_METHOD("_on_noise_changed"), &VoxelGeneratorNoise::_on_noise_changed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, VoxelBuffer::CHANNEL_ID_HINT_STRING),
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel", PROPERTY_HINT_ENUM, gd::VoxelBuffer::CHANNEL_ID_HINT_STRING),
"set_channel", "get_channel");
ADD_PROPERTY(
PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, OpenSimplexNoise::get_class_static(),

View File

@ -1,7 +1,7 @@
#ifndef VOXEL_GENERATOR_NOISE_H
#define VOXEL_GENERATOR_NOISE_H
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_gd.h"
#include "../voxel_generator.h"
#include <modules/opensimplex/open_simplex_noise.h>
@ -33,8 +33,8 @@ public:
private:
void _on_noise_changed();
void _b_set_channel(VoxelBuffer::ChannelId p_channel);
VoxelBuffer::ChannelId _b_get_channel() const;
void _b_set_channel(gd::VoxelBuffer::ChannelId p_channel);
gd::VoxelBuffer::ChannelId _b_get_channel() const;
static void _bind_methods();

View File

@ -1,6 +1,6 @@
#include "voxel_generator.h"
#include "../constants/voxel_string_names.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
namespace zylann::voxel {
@ -29,7 +29,7 @@ VoxelSingleValue VoxelGenerator::generate_single(Vector3i pos, unsigned int chan
return v;
}
void VoxelGenerator::_b_generate_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod) {
void VoxelGenerator::_b_generate_block(Ref<gd::VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod) {
ERR_FAIL_COND(lod < 0);
ERR_FAIL_COND(lod >= int(constants::MAX_LOD));
ERR_FAIL_COND(out_buffer.is_null());

View File

@ -6,9 +6,12 @@
namespace zylann::voxel {
class VoxelBuffer;
class VoxelBufferInternal;
namespace gd {
class VoxelBuffer;
}
union VoxelSingleValue {
uint64_t i;
float f;
@ -56,7 +59,7 @@ public:
protected:
static void _bind_methods();
void _b_generate_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod);
void _b_generate_block(Ref<gd::VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod);
};
} // namespace zylann::voxel

View File

@ -1,6 +1,6 @@
#include "voxel_generator_script.h"
#include "../constants/voxel_string_names.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/godot/funcs.h"
namespace zylann::voxel {
@ -11,7 +11,7 @@ VoxelGenerator::Result VoxelGeneratorScript::generate_block(VoxelGenerator::Voxe
Result result;
// Create a temporary wrapper so Godot can pass it to scripts
Ref<VoxelBuffer> buffer_wrapper;
Ref<gd::VoxelBuffer> buffer_wrapper;
buffer_wrapper.instantiate();
buffer_wrapper->get_buffer().copy_format(input.voxel_buffer);
buffer_wrapper->get_buffer().create(input.voxel_buffer.get_size());

View File

@ -18,7 +18,7 @@ public:
int get_used_channels_mask() const override;
protected:
GDVIRTUAL3(_generate_block, Ref<VoxelBuffer>, Vector3i, int)
GDVIRTUAL3(_generate_block, Ref<gd::VoxelBuffer>, Vector3i, int)
GDVIRTUAL0RC(int, _get_used_channels_mask) // I think `C` means `const`?
private:

View File

@ -1,6 +1,6 @@
#include "voxel_mesher_blocky.h"
#include "../../constants/cube_tables.h"
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_internal.h"
#include "../../util/funcs.h"
#include "../../util/godot/funcs.h"
#include "../../util/span.h"
@ -372,7 +372,7 @@ bool VoxelMesherBlocky::get_occlusion_enabled() const {
}
void VoxelMesherBlocky::build(VoxelMesher::Output &output, const VoxelMesher::Input &input) {
const int channel = VoxelBuffer::CHANNEL_TYPE;
const int channel = VoxelBufferInternal::CHANNEL_TYPE;
Parameters params;
{
RWLockRead rlock(_parameters_lock);
@ -532,7 +532,7 @@ Ref<Resource> VoxelMesherBlocky::duplicate(bool p_subresources) const {
}
int VoxelMesherBlocky::get_used_channels_mask() const {
return (1 << VoxelBuffer::CHANNEL_TYPE);
return (1 << VoxelBufferInternal::CHANNEL_TYPE);
}
void VoxelMesherBlocky::_bind_methods() {

View File

@ -1,5 +1,5 @@
#include "voxel_mesher_cubes.h"
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_internal.h"
#include "../../util/funcs.h"
#include "../../util/godot/funcs.h"
#include "../../util/profiling.h"
@ -757,7 +757,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
switch (params.color_mode) {
case COLOR_RAW:
switch (channel_depth) {
case VoxelBuffer::DEPTH_8_BIT:
case VoxelBufferInternal::DEPTH_8_BIT:
if (params.greedy_meshing) {
build_voxel_mesh_as_greedy_cubes(cache.arrays_per_material, raw_channel, block_size,
cache.mask_memory_pool, Color8::from_u8);
@ -767,7 +767,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
}
break;
case VoxelBuffer::DEPTH_16_BIT:
case VoxelBufferInternal::DEPTH_16_BIT:
if (params.greedy_meshing) {
build_voxel_mesh_as_greedy_cubes(cache.arrays_per_material,
raw_channel.reinterpret_cast_to<uint16_t>(), block_size, cache.mask_memory_pool,
@ -799,7 +799,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
const GetColorFromPalette get_color_from_palette{ **params.palette };
switch (channel_depth) {
case VoxelBuffer::DEPTH_8_BIT:
case VoxelBufferInternal::DEPTH_8_BIT:
if (params.greedy_meshing) {
if (params.store_colors_in_texture) {
build_voxel_mesh_as_greedy_cubes_atlased(cache.arrays_per_material, cache.greedy_atlas_data,
@ -816,7 +816,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
}
break;
case VoxelBuffer::DEPTH_16_BIT:
case VoxelBufferInternal::DEPTH_16_BIT:
if (params.greedy_meshing) {
build_voxel_mesh_as_greedy_cubes(cache.arrays_per_material,
raw_channel.reinterpret_cast_to<uint16_t>(), block_size, cache.mask_memory_pool,
@ -846,7 +846,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
const GetIndexFromPalette get_index_from_palette{ **params.palette };
switch (channel_depth) {
case VoxelBuffer::DEPTH_8_BIT:
case VoxelBufferInternal::DEPTH_8_BIT:
if (params.greedy_meshing) {
build_voxel_mesh_as_greedy_cubes(cache.arrays_per_material, raw_channel, block_size,
cache.mask_memory_pool, get_index_from_palette);
@ -856,7 +856,7 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
}
break;
case VoxelBuffer::DEPTH_16_BIT:
case VoxelBufferInternal::DEPTH_16_BIT:
if (params.greedy_meshing) {
build_voxel_mesh_as_greedy_cubes(cache.arrays_per_material,
raw_channel.reinterpret_cast_to<uint16_t>(), block_size, cache.mask_memory_pool,
@ -1000,7 +1000,7 @@ Ref<Resource> VoxelMesherCubes::duplicate(bool p_subresources) const {
}
int VoxelMesherCubes::get_used_channels_mask() const {
return (1 << VoxelBuffer::CHANNEL_COLOR);
return (1 << VoxelBufferInternal::CHANNEL_COLOR);
}
void VoxelMesherCubes::_bind_methods() {

View File

@ -1,5 +1,5 @@
#include "voxel_mesher_transvoxel.h"
#include "../../storage/voxel_buffer.h"
#include "../../storage/voxel_buffer_gd.h"
#include "../../thirdparty/meshoptimizer/meshoptimizer.h"
#include "../../util/funcs.h"
#include "../../util/godot/funcs.h"
@ -199,7 +199,7 @@ void VoxelMesherTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher
}
// TODO For testing at the moment
Ref<ArrayMesh> VoxelMesherTransvoxel::build_transition_mesh(Ref<VoxelBuffer> voxels, int direction) {
Ref<ArrayMesh> VoxelMesherTransvoxel::build_transition_mesh(Ref<gd::VoxelBuffer> voxels, int direction) {
static thread_local transvoxel::Cache s_cache;
static thread_local transvoxel::MeshArrays s_mesh_arrays;

View File

@ -8,6 +8,10 @@ class ArrayMesh;
namespace zylann::voxel {
namespace gd {
class VoxelBuffer;
}
class VoxelMesherTransvoxel : public VoxelMesher {
GDCLASS(VoxelMesherTransvoxel, VoxelMesher)
@ -21,7 +25,7 @@ public:
~VoxelMesherTransvoxel();
void build(VoxelMesher::Output &output, const VoxelMesher::Input &input) override;
Ref<ArrayMesh> build_transition_mesh(Ref<VoxelBuffer> voxels, int direction);
Ref<ArrayMesh> build_transition_mesh(Ref<gd::VoxelBuffer> voxels, int direction);
Ref<Resource> duplicate(bool p_subresources = false) const override;
int get_used_channels_mask() const override;

View File

@ -1,10 +1,10 @@
#include "voxel_mesher.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/godot/funcs.h"
namespace zylann::voxel {
Ref<Mesh> VoxelMesher::build_mesh(Ref<VoxelBuffer> voxels, TypedArray<Material> materials) {
Ref<Mesh> VoxelMesher::build_mesh(Ref<gd::VoxelBuffer> voxels, TypedArray<Material> materials) {
ERR_FAIL_COND_V(voxels.is_null(), Ref<ArrayMesh>());
Output output;

View File

@ -7,7 +7,9 @@
namespace zylann::voxel {
namespace gd {
class VoxelBuffer;
}
class VoxelBufferInternal;
class VoxelMesher : public Resource {
@ -31,7 +33,7 @@ public:
virtual void build(Output &output, const Input &voxels);
// Builds a mesh from the given voxels. This function is simplified to be used by the script API.
Ref<Mesh> build_mesh(Ref<VoxelBuffer> voxels, TypedArray<Material> materials);
Ref<Mesh> build_mesh(Ref<gd::VoxelBuffer> voxels, TypedArray<Material> materials);
// Gets how many neighbor voxels need to be accessed around the meshed area, toward negative axes.
// If this is not respected, the mesher might produce seams at the edges, or an error

View File

@ -19,7 +19,7 @@
#include "meshers/dmc/voxel_mesher_dmc.h"
#include "meshers/transvoxel/voxel_mesher_transvoxel.h"
#include "server/voxel_server_gd.h"
#include "storage/voxel_buffer.h"
#include "storage/voxel_buffer_gd.h"
#include "storage/voxel_memory_pool.h"
#include "streams/region/voxel_stream_region_files.h"
#include "streams/sqlite/voxel_stream_sqlite.h"
@ -89,7 +89,7 @@ void register_voxel_types() {
ClassDB::register_class<VoxelDataBlockEnterInfo>();
// Storage
ClassDB::register_class<VoxelBuffer>();
ClassDB::register_class<gd::VoxelBuffer>();
// Nodes
ClassDB::register_virtual_class<VoxelNode>();
@ -146,11 +146,13 @@ void register_voxel_types() {
// Reminder: how to create a singleton accessible from scripts:
// Engine::get_singleton()->add_singleton(Engine::Singleton("SingletonName",singleton_instance));
// Reminders
PRINT_VERBOSE(String("Size of Variant: {0}").format(varray((int)sizeof(Variant))));
PRINT_VERBOSE(String("Size of Object: {0}").format(varray((int)sizeof(Object))));
PRINT_VERBOSE(String("Size of RefCounted: {0}").format(varray((int)sizeof(RefCounted))));
PRINT_VERBOSE(String("Size of Node: {0}").format(varray((int)sizeof(Node))));
PRINT_VERBOSE(String("Size of Node3D: {0}").format(varray((int)sizeof(Node3D))));
PRINT_VERBOSE(String("Size of VoxelBuffer: {0}").format(varray((int)sizeof(VoxelBuffer))));
PRINT_VERBOSE(String("Size of gd::VoxelBuffer: {0}").format(varray((int)sizeof(gd::VoxelBuffer))));
PRINT_VERBOSE(String("Size of VoxelMeshBlock: {0}").format(varray((int)sizeof(VoxelMeshBlock))));
PRINT_VERBOSE(String("Size of VoxelTerrain: {0}").format(varray((int)sizeof(VoxelTerrain))));
PRINT_VERBOSE(String("Size of VoxelLodTerrain: {0}").format(varray((int)sizeof(VoxelLodTerrain))));

View File

@ -1,10 +1,10 @@
#include "voxel_buffer.h"
#include "voxel_buffer_gd.h"
#include "../edition/voxel_tool_buffer.h"
#include "../util/godot/funcs.h"
#include <core/io/image.h>
namespace zylann::voxel {
namespace zylann::voxel::gd {
const char *VoxelBuffer::CHANNEL_ID_HINT_STRING = "Type,Sdf,Color,Indices,Weights,Data5,Data6,Data7";
static thread_local bool s_create_shared = false;
@ -213,4 +213,4 @@ void VoxelBuffer::_bind_methods() {
BIND_CONSTANT(MAX_SIZE);
}
} // namespace zylann::voxel
} //namespace zylann::voxel::gd

View File

@ -1,5 +1,5 @@
#ifndef VOXEL_BUFFER_H
#define VOXEL_BUFFER_H
#ifndef VOXEL_BUFFER_GD_H
#define VOXEL_BUFFER_GD_H
#include "voxel_buffer_internal.h"
#include <memory>
@ -10,8 +10,7 @@ namespace zylann::voxel {
class VoxelTool;
// TODO I wish I could call the original class `VoxelBuffer` and expose this other one with that name.
// Godot doesn't seem to allow doing that. So the original class had to be named `VoxelBufferInternal`...
namespace gd {
// Scripts-facing wrapper around VoxelBufferInternal.
// It is separate because being a Godot object requires to carry more baggage, and because this data type can
@ -180,10 +179,11 @@ private:
std::shared_ptr<VoxelBufferInternal> _buffer;
};
} // namespace gd
} // namespace zylann::voxel
VARIANT_ENUM_CAST(zylann::voxel::VoxelBuffer::ChannelId)
VARIANT_ENUM_CAST(zylann::voxel::VoxelBuffer::Depth)
VARIANT_ENUM_CAST(zylann::voxel::VoxelBuffer::Compression)
VARIANT_ENUM_CAST(zylann::voxel::gd::VoxelBuffer::ChannelId)
VARIANT_ENUM_CAST(zylann::voxel::gd::VoxelBuffer::Depth)
VARIANT_ENUM_CAST(zylann::voxel::gd::VoxelBuffer::Compression)
#endif // VOXEL_BUFFER_H
#endif // VOXEL_BUFFER_GD_H

View File

@ -1,11 +1,11 @@
#include "vox_loader.h"
#include "../meshers/cubes/voxel_color_palette.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "vox_data.h"
namespace zylann::voxel {
Error VoxelVoxLoader::load_from_file(String fpath, Ref<VoxelBuffer> p_voxels, Ref<VoxelColorPalette> palette) {
Error VoxelVoxLoader::load_from_file(String fpath, Ref<gd::VoxelBuffer> p_voxels, Ref<VoxelColorPalette> palette) {
ERR_FAIL_COND_V(p_voxels.is_null(), ERR_INVALID_PARAMETER);
VoxelBufferInternal &voxels = p_voxels->get_buffer();

View File

@ -5,15 +5,18 @@
namespace zylann::voxel {
class VoxelBuffer;
class VoxelColorPalette;
namespace gd {
class VoxelBuffer;
}
// Simple loader for MagicaVoxel
class VoxelVoxLoader : public RefCounted {
GDCLASS(VoxelVoxLoader, RefCounted);
public:
Error load_from_file(String fpath, Ref<VoxelBuffer> p_voxels, Ref<VoxelColorPalette> palette);
Error load_from_file(String fpath, Ref<gd::VoxelBuffer> p_voxels, Ref<VoxelColorPalette> palette);
// TODO Have chunked loading for better memory usage
// TODO Saving

View File

@ -1,5 +1,5 @@
#include "voxel_block_serializer.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_internal.h"
#include "../storage/voxel_memory_pool.h"
#include "../util/macros.h"
#include "../util/math/vector3i.h"

View File

@ -1,16 +1,14 @@
#ifndef VOXEL_BLOCK_SERIALIZER_GD_H
#define VOXEL_BLOCK_SERIALIZER_GD_H
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "voxel_block_serializer.h"
#include <core/io/stream_peer.h>
namespace zylann::voxel {
namespace zylann::voxel::gd {
class VoxelBuffer;
namespace gd {
// Godot-facing API for BlockSerializer
// TODO Could be a singleton? Or methods on VoxelBuffer? This object has no state.
class VoxelBlockSerializer : public RefCounted {
@ -38,7 +36,6 @@ private:
}
};
} // namespace gd
} // namespace zylann::voxel
} // namespace zylann::voxel::gd
#endif // VOXEL_BLOCK_SERIALIZER_GD_H

View File

@ -1,5 +1,5 @@
#include "voxel_stream.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include <core/object/script_language.h>
using namespace zylann::voxel;
@ -75,7 +75,7 @@ int VoxelStream::get_lod_count() const {
// Binding land
VoxelStream::ResultCode VoxelStream::_b_load_voxel_block(
Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) {
Ref<gd::VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod) {
ERR_FAIL_COND_V(lod < 0, RESULT_ERROR);
ERR_FAIL_COND_V(out_buffer.is_null(), RESULT_ERROR);
VoxelQueryData q{ out_buffer->get_buffer(), origin_in_voxels, lod, RESULT_ERROR };
@ -83,19 +83,20 @@ VoxelStream::ResultCode VoxelStream::_b_load_voxel_block(
return q.result;
}
void VoxelStream::_b_save_voxel_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) {
void VoxelStream::_b_save_voxel_block(Ref<gd::VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod) {
ERR_FAIL_COND(lod < 0);
ERR_FAIL_COND(buffer.is_null());
VoxelQueryData q{ buffer->get_buffer(), origin_in_voxels, lod, RESULT_ERROR };
save_voxel_block(q);
}
VoxelStream::ResultCode VoxelStream::_b_emerge_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod) {
VoxelStream::ResultCode VoxelStream::_b_emerge_block(
Ref<gd::VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod) {
ERR_PRINT("VoxelStream.emerge_block is deprecated. Use `load_voxel_block` instead.");
return _b_load_voxel_block(out_buffer, origin_in_voxels, lod);
}
void VoxelStream::_b_immerge_block(Ref<VoxelBuffer> buffer, Vector3 origin_in_voxels, int lod) {
void VoxelStream::_b_immerge_block(Ref<gd::VoxelBuffer> buffer, Vector3 origin_in_voxels, int lod) {
ERR_PRINT("VoxelStream.immerge_block is deprecated. Use `save_voxel_block` instead.");
return _b_save_voxel_block(buffer, origin_in_voxels, lod);
}

View File

@ -6,9 +6,12 @@
namespace zylann::voxel {
class VoxelBuffer;
class VoxelBufferInternal;
namespace gd {
class VoxelBuffer;
}
// Provides access to a source of paged voxel data, which may load and save.
// This is intented for files, so it may run in a single background thread and gets requests in batches.
// Must be implemented in a thread-safe way.
@ -110,13 +113,13 @@ public:
private:
static void _bind_methods();
ResultCode _b_load_voxel_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod);
void _b_save_voxel_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod);
ResultCode _b_load_voxel_block(Ref<gd::VoxelBuffer> out_buffer, Vector3i origin_in_voxels, int lod);
void _b_save_voxel_block(Ref<gd::VoxelBuffer> buffer, Vector3i origin_in_voxels, int lod);
int _b_get_used_channels_mask() const;
Vector3 _b_get_block_size() const;
// Deprecated
ResultCode _b_emerge_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod);
void _b_immerge_block(Ref<VoxelBuffer> buffer, Vector3 origin_in_voxels, int lod);
ResultCode _b_emerge_block(Ref<gd::VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod);
void _b_immerge_block(Ref<gd::VoxelBuffer> buffer, Vector3 origin_in_voxels, int lod);
struct Parameters {
bool save_generator_output = false;

View File

@ -1,6 +1,6 @@
#include "voxel_stream_script.h"
#include "../constants/voxel_string_names.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/godot/funcs.h"
namespace zylann::voxel {
@ -8,7 +8,7 @@ namespace zylann::voxel {
void VoxelStreamScript::load_voxel_block(VoxelStream::VoxelQueryData &query_data) {
Variant output;
// Create a temporary wrapper so Godot can pass it to scripts
Ref<VoxelBuffer> buffer_wrapper;
Ref<gd::VoxelBuffer> buffer_wrapper;
buffer_wrapper.instantiate();
buffer_wrapper->get_buffer().copy_format(query_data.voxel_buffer);
buffer_wrapper->get_buffer().create(query_data.voxel_buffer.get_size());
@ -31,7 +31,7 @@ void VoxelStreamScript::load_voxel_block(VoxelStream::VoxelQueryData &query_data
}
void VoxelStreamScript::save_voxel_block(VoxelStream::VoxelQueryData &query_data) {
Ref<VoxelBuffer> buffer_wrapper;
Ref<gd::VoxelBuffer> buffer_wrapper;
buffer_wrapper.instantiate();
query_data.voxel_buffer.duplicate_to(buffer_wrapper->get_buffer(), true);
if (!GDVIRTUAL_CALL(_save_voxel_block, buffer_wrapper, query_data.origin_in_voxels, query_data.lod)) {

View File

@ -21,8 +21,8 @@ public:
protected:
// TODO Why is it unable to convert `Result` into `Variant` even though a cast is defined in voxel_stream.h???
//GDVIRTUAL3R(VoxelStream::Result, _emerge_block, Ref<VoxelBuffer>, Vector3i, int)
GDVIRTUAL3R(int, _load_voxel_block, Ref<VoxelBuffer>, Vector3i, int)
GDVIRTUAL3(_save_voxel_block, Ref<VoxelBuffer>, Vector3i, int)
GDVIRTUAL3R(int, _load_voxel_block, Ref<gd::VoxelBuffer>, Vector3i, int)
GDVIRTUAL3(_save_voxel_block, Ref<gd::VoxelBuffer>, Vector3i, int)
GDVIRTUAL0RC(int, _get_used_channels_mask) // I think `C` means `const`?
static void _bind_methods();

View File

@ -1,5 +1,5 @@
#include "voxel_data_block_enter_info.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../storage/voxel_data_block.h"
namespace zylann::voxel {
@ -8,10 +8,10 @@ int VoxelDataBlockEnterInfo::_b_get_network_peer_id() const {
return network_peer_id;
}
Ref<VoxelBuffer> VoxelDataBlockEnterInfo::_b_get_voxels() const {
ERR_FAIL_COND_V(voxel_block == nullptr, Ref<VoxelBuffer>());
Ref<gd::VoxelBuffer> VoxelDataBlockEnterInfo::_b_get_voxels() const {
ERR_FAIL_COND_V(voxel_block == nullptr, Ref<gd::VoxelBuffer>());
std::shared_ptr<VoxelBufferInternal> vbi = voxel_block->get_voxels_shared();
Ref<VoxelBuffer> vb = VoxelBuffer::create_shared(vbi);
Ref<gd::VoxelBuffer> vb = gd::VoxelBuffer::create_shared(vbi);
return vb;
}

View File

@ -6,7 +6,10 @@
namespace zylann::voxel {
class VoxelDataBlock;
namespace gd {
class VoxelBuffer;
}
// Information sent with data block entering notifications.
// It is a class for script API convenience.
@ -19,7 +22,7 @@ public:
private:
int _b_get_network_peer_id() const;
Ref<VoxelBuffer> _b_get_voxels() const;
Ref<gd::VoxelBuffer> _b_get_voxels() const;
Vector3i _b_get_position() const;
int _b_get_lod_index() const;
bool _b_are_voxels_edited() const;

View File

@ -4,7 +4,7 @@
#include "../edition/voxel_tool_terrain.h"
#include "../server/voxel_server.h"
#include "../server/voxel_server_updater.h"
#include "../storage/voxel_buffer.h"
#include "../storage/voxel_buffer_gd.h"
#include "../util/funcs.h"
#include "../util/macros.h"
#include "../util/profiling.h"
@ -1546,7 +1546,7 @@ AABB VoxelTerrain::_b_get_bounds() const {
return AABB(b.pos, b.size);
}
bool VoxelTerrain::_b_try_set_block_data(Vector3i position, Ref<VoxelBuffer> voxel_data) {
bool VoxelTerrain::_b_try_set_block_data(Vector3i position, Ref<gd::VoxelBuffer> voxel_data) {
ERR_FAIL_COND_V(voxel_data.is_null(), false);
std::shared_ptr<VoxelBufferInternal> buffer = voxel_data->get_buffer_shared();
return try_set_block_data(position, buffer);

View File

@ -195,7 +195,7 @@ private:
void _b_save_block(Vector3i p_block_pos);
void _b_set_bounds(AABB aabb);
AABB _b_get_bounds() const;
bool _b_try_set_block_data(Vector3i position, Ref<VoxelBuffer> voxel_data);
bool _b_try_set_block_data(Vector3i position, Ref<gd::VoxelBuffer> voxel_data);
Dictionary _b_get_statistics() const;
PackedInt32Array _b_get_viewer_network_peer_ids_in_area(Vector3i area_origin, Vector3i area_size) const;