mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Also renamed the channel-related methods in VoxelChunk.
This commit is contained in:
parent
1d1fdf5c56
commit
2dec05f80f
@ -51,7 +51,7 @@ void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref<VoxelChunk> chunk) {
|
|||||||
int k = key;
|
int k = key;
|
||||||
int value = _channel_map[key];
|
int value = _channel_map[key];
|
||||||
|
|
||||||
chunk->fill_channel(value, k);
|
chunk->channel_fill(value, k);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -64,7 +64,7 @@ void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref<VoxelChunk> chunk) {
|
|||||||
int k = key;
|
int k = key;
|
||||||
int value = _channel_map[key];
|
int value = _channel_map[key];
|
||||||
|
|
||||||
uint8_t *channel = chunk->get_valid_channel(k, 0);
|
uint8_t *channel = chunk->channel_get_valid(k, 0);
|
||||||
|
|
||||||
if (!channel)
|
if (!channel)
|
||||||
continue;
|
continue;
|
||||||
|
@ -46,7 +46,7 @@ void VoxelMesherBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
|||||||
|
|
||||||
float voxel_scale = get_voxel_scale();
|
float voxel_scale = get_voxel_scale();
|
||||||
|
|
||||||
uint8_t *channel_type = chunk->get_channel(_channel_index_type);
|
uint8_t *channel_type = chunk->channel_get(_channel_index_type);
|
||||||
|
|
||||||
if (!channel_type)
|
if (!channel_type)
|
||||||
return;
|
return;
|
||||||
@ -64,15 +64,15 @@ void VoxelMesherBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
|||||||
bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0;
|
bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0;
|
||||||
|
|
||||||
if (use_lighting) {
|
if (use_lighting) {
|
||||||
channel_color_r = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
||||||
channel_color_g = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
||||||
channel_color_b = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||||
|
|
||||||
if (use_ao)
|
if (use_ao)
|
||||||
channel_ao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||||
|
|
||||||
if (use_rao)
|
if (use_rao)
|
||||||
channel_rao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO);
|
channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<uint8_t> liquids;
|
Vector<uint8_t> liquids;
|
||||||
|
@ -38,7 +38,7 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
|||||||
|
|
||||||
float voxel_scale = get_voxel_scale();
|
float voxel_scale = get_voxel_scale();
|
||||||
|
|
||||||
uint8_t *channel_type = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
uint8_t *channel_type = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||||
|
|
||||||
if (!channel_type)
|
if (!channel_type)
|
||||||
return;
|
return;
|
||||||
@ -56,15 +56,15 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
|||||||
bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0;
|
bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0;
|
||||||
|
|
||||||
if (use_lighting) {
|
if (use_lighting) {
|
||||||
channel_color_r = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
||||||
channel_color_g = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
||||||
channel_color_b = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||||
|
|
||||||
if (use_ao)
|
if (use_ao)
|
||||||
channel_ao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||||
|
|
||||||
if (use_rao)
|
if (use_rao)
|
||||||
channel_rao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO);
|
channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<uint8_t> liquids;
|
Vector<uint8_t> liquids;
|
||||||
|
@ -446,7 +446,7 @@ void VoxelCubePoints::refresh_neighbours(Ref<VoxelChunk> chunk) {
|
|||||||
void VoxelCubePoints::setup(Ref<VoxelChunk> chunk, int x, int y, int z, int size) {
|
void VoxelCubePoints::setup(Ref<VoxelChunk> chunk, int x, int y, int z, int size) {
|
||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
ERR_FAIL_COND(size <= 0);
|
ERR_FAIL_COND(size <= 0);
|
||||||
ERR_FAIL_COND(!chunk->validate_channel_data_position(x + size, y + size, z + size) || !chunk->validate_channel_data_position(x, y, z));
|
ERR_FAIL_COND(!chunk->validate_data_position(x + size, y + size, z + size) || !chunk->validate_data_position(x, y, z));
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ void VoxelMesherCubic::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
|||||||
|
|
||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
|
|
||||||
if (!chunk->get_channel(_channel_index_type) || !chunk->get_channel(_channel_index_isolevel)) {
|
if (!chunk->channel_get(_channel_index_type) || !chunk->channel_get(_channel_index_isolevel)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void VoxelMesherDefault::_bake_colors(Ref<VoxelChunk> chunk) {
|
|||||||
unsigned int y = (unsigned int)(vert.y / _voxel_scale);
|
unsigned int y = (unsigned int)(vert.y / _voxel_scale);
|
||||||
unsigned int z = (unsigned int)(vert.z / _voxel_scale);
|
unsigned int z = (unsigned int)(vert.z / _voxel_scale);
|
||||||
|
|
||||||
if (chunk->validate_channel_data_position(x, y, z)) {
|
if (chunk->validate_data_position(x, y, z)) {
|
||||||
Color light = Color(
|
Color light = Color(
|
||||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||||
@ -125,7 +125,7 @@ void VoxelMesherDefault::_bake_liquid_colors(Ref<VoxelChunk> chunk) {
|
|||||||
unsigned int y = (unsigned int)(vert.y / _voxel_scale);
|
unsigned int y = (unsigned int)(vert.y / _voxel_scale);
|
||||||
unsigned int z = (unsigned int)(vert.z / _voxel_scale);
|
unsigned int z = (unsigned int)(vert.z / _voxel_scale);
|
||||||
|
|
||||||
if (chunk->validate_channel_data_position(x, y, z)) {
|
if (chunk->validate_data_position(x, y, z)) {
|
||||||
Color light = Color(
|
Color light = Color(
|
||||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||||
|
@ -40,7 +40,7 @@ typedef class RenderingServer VisualServer;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
||||||
uint8_t *channel_type = chunk->get_channel(_channel_index_type);
|
uint8_t *channel_type = chunk->channel_get(_channel_index_type);
|
||||||
|
|
||||||
if (channel_type == NULL) {
|
if (channel_type == NULL) {
|
||||||
arr[0] = 0;
|
arr[0] = 0;
|
||||||
@ -93,7 +93,7 @@ int VoxelMesherMarchingCubes::get_case_code_from_arr(const int *data) {
|
|||||||
return case_code;
|
return case_code;
|
||||||
}
|
}
|
||||||
int VoxelMesherMarchingCubes::get_case_code(Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
int VoxelMesherMarchingCubes::get_case_code(Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
||||||
uint8_t *channel_type = chunk->get_channel(_channel_index_type);
|
uint8_t *channel_type = chunk->channel_get(_channel_index_type);
|
||||||
|
|
||||||
if (channel_type == NULL) {
|
if (channel_type == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -129,7 +129,7 @@ int VoxelMesherMarchingCubes::get_case_code(Ref<VoxelChunk> chunk, const int x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int VoxelMesherMarchingCubes::get_voxel_type(Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
int VoxelMesherMarchingCubes::get_voxel_type(Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
||||||
uint8_t *channel_type = chunk->get_channel(_channel_index_type);
|
uint8_t *channel_type = chunk->channel_get(_channel_index_type);
|
||||||
|
|
||||||
if (channel_type == NULL) {
|
if (channel_type == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -31,11 +31,11 @@ VoxelChunkBlocky::~VoxelChunkBlocky() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkBlocky::_setup_channels() {
|
void VoxelChunkBlocky::_setup_channels() {
|
||||||
set_channel_count(MAX_DEFAULT_CHANNELS);
|
channel_set_count(MAX_DEFAULT_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkBlocky::_bind_methods() {
|
void VoxelChunkBlocky::_bind_methods() {
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "set_channel_compressed", "get_channel_compressed", 0);
|
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0);
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
||||||
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
||||||
|
@ -31,12 +31,12 @@ VoxelChunkCubic::~VoxelChunkCubic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkCubic::_setup_channels() {
|
void VoxelChunkCubic::_setup_channels() {
|
||||||
set_channel_count(MAX_DEFAULT_CHANNELS);
|
channel_set_count(MAX_DEFAULT_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkCubic::_bind_methods() {
|
void VoxelChunkCubic::_bind_methods() {
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "set_channel_compressed", "get_channel_compressed", 0);
|
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0);
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "set_channel_compressed", "get_channel_compressed", 1);
|
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "channel_set_compressed", "channel_get_compressed", 1);
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
||||||
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
||||||
|
@ -755,9 +755,9 @@ void VoxelChunkDefault::_bake_light(Ref<VoxelLight> light) {
|
|||||||
int64_t dsy = static_cast<int64_t>(_data_size_y);
|
int64_t dsy = static_cast<int64_t>(_data_size_y);
|
||||||
int64_t dsz = static_cast<int64_t>(_data_size_z);
|
int64_t dsz = static_cast<int64_t>(_data_size_z);
|
||||||
|
|
||||||
uint8_t *channel_color_r = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
uint8_t *channel_color_r = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
||||||
uint8_t *channel_color_g = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
uint8_t *channel_color_g = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
||||||
uint8_t *channel_color_b = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
uint8_t *channel_color_b = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||||
|
|
||||||
ERR_FAIL_COND(channel_color_r == NULL || channel_color_g == NULL || channel_color_b == NULL);
|
ERR_FAIL_COND(channel_color_r == NULL || channel_color_g == NULL || channel_color_b == NULL);
|
||||||
|
|
||||||
@ -810,9 +810,9 @@ void VoxelChunkDefault::_bake_light(Ref<VoxelLight> light) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void VoxelChunkDefault::_clear_baked_lights() {
|
void VoxelChunkDefault::_clear_baked_lights() {
|
||||||
fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
||||||
fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
||||||
fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||||
}
|
}
|
||||||
void VoxelChunkDefault::_world_light_added(const Ref<VoxelLight> &light) {
|
void VoxelChunkDefault::_world_light_added(const Ref<VoxelLight> &light) {
|
||||||
_lights.push_back(light);
|
_lights.push_back(light);
|
||||||
@ -866,8 +866,8 @@ VoxelChunkDefault::~VoxelChunkDefault() {
|
|||||||
debug_mesh_free();
|
debug_mesh_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkDefault::_setup_channels() {
|
void VoxelChunkDefault::_channel_setup() {
|
||||||
set_channel_count(MAX_DEFAULT_CHANNELS);
|
channel_set_count(MAX_DEFAULT_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkDefault::_bind_methods() {
|
void VoxelChunkDefault::_bind_methods() {
|
||||||
@ -939,7 +939,7 @@ void VoxelChunkDefault::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("emit_build_finished"), &VoxelChunkDefault::emit_build_finished);
|
ClassDB::bind_method(D_METHOD("emit_build_finished"), &VoxelChunkDefault::emit_build_finished);
|
||||||
|
|
||||||
//virtuals
|
//virtuals
|
||||||
ClassDB::bind_method(D_METHOD("_setup_channels"), &VoxelChunkDefault::_setup_channels);
|
ClassDB::bind_method(D_METHOD("_channel_setup"), &VoxelChunkDefault::_channel_setup);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_visibility_changed", "visible"), &VoxelChunkDefault::_visibility_changed);
|
ClassDB::bind_method(D_METHOD("_visibility_changed", "visible"), &VoxelChunkDefault::_visibility_changed);
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ public:
|
|||||||
~VoxelChunkDefault();
|
~VoxelChunkDefault();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _setup_channels();
|
virtual void _channel_setup();
|
||||||
|
|
||||||
virtual void _visibility_changed(bool visible);
|
virtual void _visibility_changed(bool visible);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void VoxelLightJob::phase_light() {
|
|||||||
Ref<VoxelChunkDefault> chunk = _chunk;
|
Ref<VoxelChunkDefault> chunk = _chunk;
|
||||||
|
|
||||||
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_GENERATE_AO) != 0)
|
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_GENERATE_AO) != 0)
|
||||||
if (!chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO))
|
if (!chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO))
|
||||||
generate_ao();
|
generate_ao();
|
||||||
|
|
||||||
bool gr = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0;
|
bool gr = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0;
|
||||||
|
@ -30,13 +30,13 @@ VoxelChunkMarchingCubes::VoxelChunkMarchingCubes() {
|
|||||||
VoxelChunkMarchingCubes::~VoxelChunkMarchingCubes() {
|
VoxelChunkMarchingCubes::~VoxelChunkMarchingCubes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkMarchingCubes::_setup_channels() {
|
void VoxelChunkMarchingCubes::_channel_setup() {
|
||||||
set_channel_count(MAX_DEFAULT_CHANNELS);
|
channel_set_count(MAX_DEFAULT_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunkMarchingCubes::_bind_methods() {
|
void VoxelChunkMarchingCubes::_bind_methods() {
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "set_channel_compressed", "get_channel_compressed", 0);
|
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0);
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "set_channel_compressed", "get_channel_compressed", 1);
|
ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "channel_set_compressed", "channel_get_compressed", 1);
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
||||||
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
//ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
~VoxelChunkMarchingCubes();
|
~VoxelChunkMarchingCubes();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _setup_channels();
|
virtual void _channel_setup();
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
};
|
};
|
||||||
|
@ -283,10 +283,10 @@ Ref<VoxelJob> VoxelChunk::job_get_current() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Voxel Data
|
//Voxel Data
|
||||||
void VoxelChunk::setup_channels() {
|
void VoxelChunk::channel_setup() {
|
||||||
ERR_FAIL_COND_MSG(!has_method("_setup_channels"), "VoxelChunk: _setup_channels() is missing! Please implement it!");
|
ERR_FAIL_COND_MSG(!has_method("_channel_setup"), "VoxelChunk: _setup_channels() is missing! Please implement it!");
|
||||||
|
|
||||||
call("_setup_channels");
|
call("_channel_setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) {
|
void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) {
|
||||||
@ -302,7 +302,7 @@ void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_channels();
|
channel_setup();
|
||||||
|
|
||||||
_size_x = size_x;
|
_size_x = size_x;
|
||||||
_size_y = size_y;
|
_size_y = size_y;
|
||||||
@ -316,7 +316,7 @@ void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z,
|
|||||||
_margin_end = margin_end;
|
_margin_end = margin_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelChunk::validate_channel_data_position(const int x, const int y, const int z) const {
|
bool VoxelChunk::validate_data_position(const int x, const int y, const int z) const {
|
||||||
return x < _data_size_x && y < _data_size_y && z < _data_size_z;
|
return x < _data_size_x && y < _data_size_y && z < _data_size_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ uint8_t VoxelChunk::get_voxel(const int p_x, const int p_y, const int p_z, const
|
|||||||
int z = p_z + _margin_start;
|
int z = p_z + _margin_start;
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_channel_index, _channels.size(), 0);
|
ERR_FAIL_INDEX_V(p_channel_index, _channels.size(), 0);
|
||||||
ERR_FAIL_COND_V_MSG(!validate_channel_data_position(x, y, z), 0, "Error, index out of range! " + String::num(x) + " " + String::num(y) + " " + String::num(z));
|
ERR_FAIL_COND_V_MSG(!validate_data_position(x, y, z), 0, "Error, index out of range! " + String::num(x) + " " + String::num(y) + " " + String::num(z));
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(p_channel_index);
|
uint8_t *ch = _channels.get(p_channel_index);
|
||||||
|
|
||||||
@ -341,18 +341,18 @@ void VoxelChunk::set_voxel(const uint8_t p_value, const int p_x, const int p_y,
|
|||||||
int z = p_z + _margin_start;
|
int z = p_z + _margin_start;
|
||||||
|
|
||||||
ERR_FAIL_INDEX(p_channel_index, _channels.size());
|
ERR_FAIL_INDEX(p_channel_index, _channels.size());
|
||||||
ERR_FAIL_COND_MSG(!validate_channel_data_position(x, y, z), "Error, index out of range! " + String::num(x) + " " + String::num(y) + " " + String::num(z));
|
ERR_FAIL_COND_MSG(!validate_data_position(x, y, z), "Error, index out of range! " + String::num(x) + " " + String::num(y) + " " + String::num(z));
|
||||||
|
|
||||||
uint8_t *ch = get_valid_channel(p_channel_index);
|
uint8_t *ch = channel_get_valid(p_channel_index);
|
||||||
|
|
||||||
ch[get_data_index(x, y, z)] = p_value;
|
ch[get_data_index(x, y, z)] = p_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelChunk::get_channel_count() const {
|
int VoxelChunk::channel_get_count() const {
|
||||||
return _channels.size();
|
return _channels.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunk::set_channel_count(const int count) {
|
void VoxelChunk::channel_set_count(const int count) {
|
||||||
if (count == _channels.size())
|
if (count == _channels.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -376,18 +376,18 @@ void VoxelChunk::set_channel_count(const int count) {
|
|||||||
_channels.set(i, NULL);
|
_channels.set(i, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VoxelChunk::is_channel_allocated(const int channel_index) {
|
bool VoxelChunk::channel_is_allocated(const int channel_index) {
|
||||||
ERR_FAIL_INDEX_V(channel_index, _channels.size(), false);
|
ERR_FAIL_INDEX_V(channel_index, _channels.size(), false);
|
||||||
|
|
||||||
return _channels[channel_index] != NULL;
|
return _channels[channel_index] != NULL;
|
||||||
}
|
}
|
||||||
void VoxelChunk::ensure_channel_allocated(const int channel_index, const uint8_t default_value) {
|
void VoxelChunk::channel_ensure_allocated(const int channel_index, const uint8_t default_value) {
|
||||||
ERR_FAIL_INDEX(channel_index, _channels.size());
|
ERR_FAIL_INDEX(channel_index, _channels.size());
|
||||||
|
|
||||||
if (_channels[channel_index] == NULL)
|
if (_channels[channel_index] == NULL)
|
||||||
allocate_channel(channel_index, default_value);
|
channel_allocate(channel_index, default_value);
|
||||||
}
|
}
|
||||||
void VoxelChunk::allocate_channel(const int channel_index, const uint8_t default_value) {
|
void VoxelChunk::channel_allocate(const int channel_index, const uint8_t default_value) {
|
||||||
ERR_FAIL_INDEX(channel_index, _channels.size());
|
ERR_FAIL_INDEX(channel_index, _channels.size());
|
||||||
|
|
||||||
if (_channels[channel_index] != NULL)
|
if (_channels[channel_index] != NULL)
|
||||||
@ -400,13 +400,13 @@ void VoxelChunk::allocate_channel(const int channel_index, const uint8_t default
|
|||||||
|
|
||||||
_channels.set(channel_index, ch);
|
_channels.set(channel_index, ch);
|
||||||
}
|
}
|
||||||
void VoxelChunk::fill_channel(const uint8_t value, const int channel_index) {
|
void VoxelChunk::channel_fill(const uint8_t value, const int channel_index) {
|
||||||
ERR_FAIL_INDEX(channel_index, _channels.size());
|
ERR_FAIL_INDEX(channel_index, _channels.size());
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(channel_index);
|
uint8_t *ch = _channels.get(channel_index);
|
||||||
|
|
||||||
if (ch == NULL) {
|
if (ch == NULL) {
|
||||||
allocate_channel(channel_index, value);
|
channel_allocate(channel_index, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ void VoxelChunk::fill_channel(const uint8_t value, const int channel_index) {
|
|||||||
ch[i] = value;
|
ch[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void VoxelChunk::dealloc_channel(const int channel_index) {
|
void VoxelChunk::channel_dealloc(const int channel_index) {
|
||||||
ERR_FAIL_INDEX(channel_index, _channels.size());
|
ERR_FAIL_INDEX(channel_index, _channels.size());
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(channel_index);
|
uint8_t *ch = _channels.get(channel_index);
|
||||||
@ -428,18 +428,18 @@ void VoxelChunk::dealloc_channel(const int channel_index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *VoxelChunk::get_channel(const int channel_index) {
|
uint8_t *VoxelChunk::channel_get(const int channel_index) {
|
||||||
ERR_FAIL_INDEX_V(channel_index, _channels.size(), NULL);
|
ERR_FAIL_INDEX_V(channel_index, _channels.size(), NULL);
|
||||||
|
|
||||||
return _channels.get(channel_index);
|
return _channels.get(channel_index);
|
||||||
}
|
}
|
||||||
uint8_t *VoxelChunk::get_valid_channel(const int channel_index, const uint8_t default_value) {
|
uint8_t *VoxelChunk::channel_get_valid(const int channel_index, const uint8_t default_value) {
|
||||||
ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0);
|
ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0);
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(channel_index);
|
uint8_t *ch = _channels.get(channel_index);
|
||||||
|
|
||||||
if (ch == NULL) {
|
if (ch == NULL) {
|
||||||
allocate_channel(channel_index, default_value);
|
channel_allocate(channel_index, default_value);
|
||||||
|
|
||||||
return _channels.get(channel_index);
|
return _channels.get(channel_index);
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ uint8_t *VoxelChunk::get_valid_channel(const int channel_index, const uint8_t de
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolByteArray VoxelChunk::get_channel_array(const int channel_index) const {
|
PoolByteArray VoxelChunk::channel_get_array(const int channel_index) const {
|
||||||
PoolByteArray arr;
|
PoolByteArray arr;
|
||||||
|
|
||||||
uint32_t size = _data_size_x * _data_size_y * _data_size_z;
|
uint32_t size = _data_size_x * _data_size_y * _data_size_z;
|
||||||
@ -468,12 +468,12 @@ PoolByteArray VoxelChunk::get_channel_array(const int channel_index) const {
|
|||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
void VoxelChunk::set_channel_array(const int channel_index, const PoolByteArray &array) {
|
void VoxelChunk::channel_set_array(const int channel_index, const PoolByteArray &array) {
|
||||||
if (array.size() == 0)
|
if (array.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_channels.size() <= channel_index)
|
if (_channels.size() <= channel_index)
|
||||||
set_channel_count(channel_index + 1);
|
channel_set_count(channel_index + 1);
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(channel_index);
|
uint8_t *ch = _channels.get(channel_index);
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ void VoxelChunk::set_channel_array(const int channel_index, const PoolByteArray
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolByteArray VoxelChunk::get_channel_compressed(const int channel_index) const {
|
PoolByteArray VoxelChunk::channel_get_compressed(const int channel_index) const {
|
||||||
PoolByteArray arr;
|
PoolByteArray arr;
|
||||||
|
|
||||||
int size = _data_size_x * _data_size_y * _data_size_z;
|
int size = _data_size_x * _data_size_y * _data_size_z;
|
||||||
@ -519,14 +519,14 @@ PoolByteArray VoxelChunk::get_channel_compressed(const int channel_index) const
|
|||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
void VoxelChunk::set_channel_compressed(const int channel_index, const PoolByteArray &data) {
|
void VoxelChunk::channel_set_compressed(const int channel_index, const PoolByteArray &data) {
|
||||||
if (data.size() == 0)
|
if (data.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int size = _data_size_x * _data_size_y * _data_size_z;
|
int size = _data_size_x * _data_size_y * _data_size_z;
|
||||||
|
|
||||||
if (_channels.size() <= channel_index)
|
if (_channels.size() <= channel_index)
|
||||||
set_channel_count(channel_index + 1);
|
channel_set_count(channel_index + 1);
|
||||||
|
|
||||||
uint8_t *ch = _channels.get(channel_index);
|
uint8_t *ch = _channels.get(channel_index);
|
||||||
|
|
||||||
@ -1189,7 +1189,7 @@ void VoxelChunk::_bind_methods() {
|
|||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_mesh_data_resource_added", PropertyInfo(Variant::INT, "index")));
|
BIND_VMETHOD(MethodInfo("_mesh_data_resource_added", PropertyInfo(Variant::INT, "index")));
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_setup_channels"));
|
BIND_VMETHOD(MethodInfo("_channel_setup"));
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_bake_lights"));
|
BIND_VMETHOD(MethodInfo("_bake_lights"));
|
||||||
BIND_VMETHOD(MethodInfo("_bake_light", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight")));
|
BIND_VMETHOD(MethodInfo("_bake_light", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight")));
|
||||||
@ -1333,30 +1333,30 @@ void VoxelChunk::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_world", PROPERTY_HINT_RESOURCE_TYPE, "VoxelWorld", 0), "set_voxel_world", "get_voxel_world");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_world", PROPERTY_HINT_RESOURCE_TYPE, "VoxelWorld", 0), "set_voxel_world", "get_voxel_world");
|
||||||
|
|
||||||
//Voxel Data
|
//Voxel Data
|
||||||
ClassDB::bind_method(D_METHOD("setup_channels"), &VoxelChunk::setup_channels);
|
ClassDB::bind_method(D_METHOD("channel_setup"), &VoxelChunk::channel_setup);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_size", "size_x", "size_y", "size_z", "margin_start", "margin_end"), &VoxelChunk::set_size, DEFVAL(0), DEFVAL(0));
|
ClassDB::bind_method(D_METHOD("set_size", "size_x", "size_y", "size_z", "margin_start", "margin_end"), &VoxelChunk::set_size, DEFVAL(0), DEFVAL(0));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("validate_channel_data_position", "x", "y", "z"), &VoxelChunk::validate_channel_data_position);
|
ClassDB::bind_method(D_METHOD("validate_data_position", "x", "y", "z"), &VoxelChunk::validate_data_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "channel_index"), &VoxelChunk::get_voxel);
|
ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "index"), &VoxelChunk::get_voxel);
|
||||||
ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "channel_index"), &VoxelChunk::set_voxel);
|
ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "index"), &VoxelChunk::set_voxel);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_channel_count"), &VoxelChunk::get_channel_count);
|
ClassDB::bind_method(D_METHOD("channel_get_count"), &VoxelChunk::channel_get_count);
|
||||||
ClassDB::bind_method(D_METHOD("set_channel_count", "count"), &VoxelChunk::set_channel_count);
|
ClassDB::bind_method(D_METHOD("channel_set_count", "count"), &VoxelChunk::channel_set_count);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "set_channel_count", "get_channel_count");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "channel_set_count", "channel_get_count");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_channel_allocated", "channel_index"), &VoxelChunk::is_channel_allocated);
|
ClassDB::bind_method(D_METHOD("channel_is_allocated", "index"), &VoxelChunk::channel_is_allocated);
|
||||||
ClassDB::bind_method(D_METHOD("ensure_channel_allocated", "channel_index", "default_value"), &VoxelChunk::ensure_channel_allocated);
|
ClassDB::bind_method(D_METHOD("channel_ensure_allocated", "index", "default_value"), &VoxelChunk::channel_ensure_allocated);
|
||||||
ClassDB::bind_method(D_METHOD("allocate_channel", "channel_index", "default_value"), &VoxelChunk::allocate_channel);
|
ClassDB::bind_method(D_METHOD("channel_allocate", "index", "default_value"), &VoxelChunk::channel_allocate);
|
||||||
ClassDB::bind_method(D_METHOD("fill_channel", "value", "channel_index"), &VoxelChunk::fill_channel);
|
ClassDB::bind_method(D_METHOD("channel_fill", "value", "index"), &VoxelChunk::channel_fill);
|
||||||
ClassDB::bind_method(D_METHOD("dealloc_channel", "channel_index"), &VoxelChunk::dealloc_channel);
|
ClassDB::bind_method(D_METHOD("channel_dealloc", "index"), &VoxelChunk::channel_dealloc);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_channel_array", "channel_index"), &VoxelChunk::get_channel_array);
|
ClassDB::bind_method(D_METHOD("channel_get_array", "index"), &VoxelChunk::channel_get_array);
|
||||||
ClassDB::bind_method(D_METHOD("set_channel_array", "channel_index", "array"), &VoxelChunk::set_channel_array);
|
ClassDB::bind_method(D_METHOD("channel_set_array", "index", "array"), &VoxelChunk::channel_set_array);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed);
|
ClassDB::bind_method(D_METHOD("channel_get_compressed", "index"), &VoxelChunk::channel_get_compressed);
|
||||||
ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed);
|
ClassDB::bind_method(D_METHOD("channel_set_compressed", "index", "array"), &VoxelChunk::channel_set_compressed);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_index", "x", "y", "z"), &VoxelChunk::get_index);
|
ClassDB::bind_method(D_METHOD("get_index", "x", "y", "z"), &VoxelChunk::get_index);
|
||||||
ClassDB::bind_method(D_METHOD("get_data_index", "x", "y", "z"), &VoxelChunk::get_data_index);
|
ClassDB::bind_method(D_METHOD("get_data_index", "x", "y", "z"), &VoxelChunk::get_data_index);
|
||||||
|
@ -155,32 +155,32 @@ public:
|
|||||||
Ref<VoxelJob> job_get_current();
|
Ref<VoxelJob> job_get_current();
|
||||||
|
|
||||||
//Channels
|
//Channels
|
||||||
void setup_channels();
|
void channel_setup();
|
||||||
|
|
||||||
void set_size(const int size_x, const int size_y, const int size_z, const int margin_start = 0, const int margin_end = 0);
|
void set_size(const int size_x, const int size_y, const int size_z, const int margin_start = 0, const int margin_end = 0);
|
||||||
|
|
||||||
bool validate_channel_data_position(const int x, const int y, const int z) const;
|
bool validate_data_position(const int x, const int y, const int z) const;
|
||||||
|
|
||||||
uint8_t get_voxel(const int p_x, const int p_y, const int p_z, const int p_channel_index) const;
|
uint8_t get_voxel(const int p_x, const int p_y, const int p_z, const int p_index) const;
|
||||||
void set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_channel_index);
|
void set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_index);
|
||||||
|
|
||||||
int get_channel_count() const;
|
int channel_get_count() const;
|
||||||
void set_channel_count(const int count);
|
void channel_set_count(const int count);
|
||||||
|
|
||||||
bool is_channel_allocated(const int channel_index);
|
bool channel_is_allocated(const int channel_index);
|
||||||
void ensure_channel_allocated(const int channel_index, const uint8_t default_value = 0);
|
void channel_ensure_allocated(const int channel_index, const uint8_t default_value = 0);
|
||||||
void allocate_channel(const int channel_index, const uint8_t default_value = 0);
|
void channel_allocate(const int channel_index, const uint8_t default_value = 0);
|
||||||
void fill_channel(const uint8_t value, const int channel_index);
|
void channel_fill(const uint8_t value, const int channel_index);
|
||||||
void dealloc_channel(const int channel_index);
|
void channel_dealloc(const int channel_index);
|
||||||
|
|
||||||
uint8_t *get_channel(const int channel_index);
|
uint8_t *channel_get(const int channel_index);
|
||||||
uint8_t *get_valid_channel(const int channel_index, const uint8_t default_value = 0);
|
uint8_t *channel_get_valid(const int channel_index, const uint8_t default_value = 0);
|
||||||
|
|
||||||
PoolByteArray get_channel_array(const int channel_index) const;
|
PoolByteArray channel_get_array(const int channel_index) const;
|
||||||
void set_channel_array(const int channel_index, const PoolByteArray &array);
|
void channel_set_array(const int channel_index, const PoolByteArray &array);
|
||||||
|
|
||||||
PoolByteArray get_channel_compressed(const int channel_index) const;
|
PoolByteArray channel_get_compressed(const int channel_index) const;
|
||||||
void set_channel_compressed(const int channel_index, const PoolByteArray &data);
|
void channel_set_compressed(const int channel_index, const PoolByteArray &data);
|
||||||
|
|
||||||
int get_index(const int x, const int y, const int z) const;
|
int get_index(const int x, const int y, const int z) const;
|
||||||
int get_data_index(const int x, const int y, const int z) const;
|
int get_data_index(const int x, const int y, const int z) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user