2020-01-26 22:34:26 +00:00
|
|
|
#include "voxel_generator.h"
|
2021-02-21 23:58:00 +00:00
|
|
|
#include "../constants/voxel_string_names.h"
|
2020-01-26 22:34:26 +00:00
|
|
|
|
2022-01-08 22:49:48 +00:00
|
|
|
using namespace zylann::voxel;
|
|
|
|
|
2021-12-13 21:38:10 +00:00
|
|
|
VoxelGenerator::VoxelGenerator() {}
|
2020-01-26 22:34:26 +00:00
|
|
|
|
2021-09-16 20:33:45 +01:00
|
|
|
VoxelGenerator::Result VoxelGenerator::generate_block(VoxelBlockRequest &input) {
|
|
|
|
return Result();
|
2020-01-26 22:34:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-17 17:18:05 +00:00
|
|
|
int VoxelGenerator::get_used_channels_mask() const {
|
|
|
|
return 0;
|
2020-01-26 22:34:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 01:48:07 +01:00
|
|
|
VoxelSingleValue VoxelGenerator::generate_single(Vector3i pos, unsigned int channel) {
|
|
|
|
// Default slow implementation
|
|
|
|
VoxelBufferInternal buffer;
|
|
|
|
buffer.create(1, 1, 1);
|
|
|
|
VoxelBlockRequest r{ buffer, pos, 0 };
|
|
|
|
generate_block(r);
|
|
|
|
VoxelSingleValue v;
|
|
|
|
if (channel == VoxelBufferInternal::CHANNEL_SDF) {
|
|
|
|
v.f = buffer.get_voxel_f(0, 0, 0, channel);
|
|
|
|
} else {
|
|
|
|
v.i = buffer.get_voxel(0, 0, 0, channel);
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2020-01-26 22:34:26 +00:00
|
|
|
void VoxelGenerator::_b_generate_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels, int lod) {
|
|
|
|
ERR_FAIL_COND(lod < 0);
|
2021-09-26 04:14:50 +01:00
|
|
|
ERR_FAIL_COND(out_buffer.is_null());
|
2021-12-13 21:38:10 +00:00
|
|
|
VoxelBlockRequest r = { out_buffer->get_buffer(), Vector3iUtil::from_floored(origin_in_voxels), lod };
|
2020-01-26 22:34:26 +00:00
|
|
|
generate_block(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelGenerator::_bind_methods() {
|
2021-12-13 21:38:10 +00:00
|
|
|
ClassDB::bind_method(
|
|
|
|
D_METHOD("generate_block", "out_buffer", "origin_in_voxels", "lod"), &VoxelGenerator::_b_generate_block);
|
2020-01-26 22:34:26 +00:00
|
|
|
}
|