diff --git a/level_generator/voxelman_level_generator_flat.cpp b/level_generator/voxelman_level_generator_flat.cpp index a5f7d99..d473220 100644 --- a/level_generator/voxelman_level_generator_flat.cpp +++ b/level_generator/voxelman_level_generator_flat.cpp @@ -51,7 +51,7 @@ void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref chunk) { int k = key; int value = _channel_map[key]; - chunk->fill_channel(value, k); + chunk->channel_fill(value, k); } return; @@ -64,7 +64,7 @@ void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref chunk) { int k = 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) continue; diff --git a/meshers/blocky/voxel_mesher_blocky.cpp b/meshers/blocky/voxel_mesher_blocky.cpp index 89a46d0..21c8ab9 100644 --- a/meshers/blocky/voxel_mesher_blocky.cpp +++ b/meshers/blocky/voxel_mesher_blocky.cpp @@ -46,7 +46,7 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { 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) return; @@ -64,15 +64,15 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0; if (use_lighting) { - channel_color_r = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - channel_color_g = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - channel_color_b = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); if (use_ao) - channel_ao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO); + channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO); if (use_rao) - channel_rao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); + channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); } Vector liquids; diff --git a/meshers/blocky/voxel_mesher_liquid_blocky.cpp b/meshers/blocky/voxel_mesher_liquid_blocky.cpp index 0acfed9..a20857a 100644 --- a/meshers/blocky/voxel_mesher_liquid_blocky.cpp +++ b/meshers/blocky/voxel_mesher_liquid_blocky.cpp @@ -38,7 +38,7 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { 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) return; @@ -56,15 +56,15 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0; if (use_lighting) { - channel_color_r = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - channel_color_g = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - channel_color_b = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); if (use_ao) - channel_ao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO); + channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO); if (use_rao) - channel_rao = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); + channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); } Vector liquids; diff --git a/meshers/cubic/voxel_cube_points.cpp b/meshers/cubic/voxel_cube_points.cpp index 2a5f96b..e49a0ed 100644 --- a/meshers/cubic/voxel_cube_points.cpp +++ b/meshers/cubic/voxel_cube_points.cpp @@ -446,7 +446,7 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { void VoxelCubePoints::setup(Ref chunk, int x, int y, int z, int size) { ERR_FAIL_COND(!chunk.is_valid()); 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(); diff --git a/meshers/cubic/voxel_mesher_cubic.cpp b/meshers/cubic/voxel_mesher_cubic.cpp index 19e6d42..b5ff6dc 100644 --- a/meshers/cubic/voxel_mesher_cubic.cpp +++ b/meshers/cubic/voxel_mesher_cubic.cpp @@ -33,7 +33,7 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { 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; } diff --git a/meshers/default/voxel_mesher_default.cpp b/meshers/default/voxel_mesher_default.cpp index dcdf44d..b91a272 100644 --- a/meshers/default/voxel_mesher_default.cpp +++ b/meshers/default/voxel_mesher_default.cpp @@ -66,7 +66,7 @@ void VoxelMesherDefault::_bake_colors(Ref chunk) { unsigned int y = (unsigned int)(vert.y / _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( 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, @@ -125,7 +125,7 @@ void VoxelMesherDefault::_bake_liquid_colors(Ref chunk) { unsigned int y = (unsigned int)(vert.y / _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( 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, diff --git a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp index 765744a..49be401 100644 --- a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp +++ b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp @@ -40,7 +40,7 @@ typedef class RenderingServer VisualServer; #endif void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref 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) { arr[0] = 0; @@ -93,7 +93,7 @@ int VoxelMesherMarchingCubes::get_case_code_from_arr(const int *data) { return case_code; } int VoxelMesherMarchingCubes::get_case_code(Ref 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) { return 0; @@ -129,7 +129,7 @@ int VoxelMesherMarchingCubes::get_case_code(Ref chunk, const int x, } int VoxelMesherMarchingCubes::get_voxel_type(Ref 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) { return 0; diff --git a/world/blocky/voxel_chunk_blocky.cpp b/world/blocky/voxel_chunk_blocky.cpp index 62eb0b0..17826f1 100644 --- a/world/blocky/voxel_chunk_blocky.cpp +++ b/world/blocky/voxel_chunk_blocky.cpp @@ -31,11 +31,11 @@ VoxelChunkBlocky::~VoxelChunkBlocky() { } void VoxelChunkBlocky::_setup_channels() { - set_channel_count(MAX_DEFAULT_CHANNELS); + channel_set_count(MAX_DEFAULT_CHANNELS); } 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("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); diff --git a/world/cubic/voxel_chunk_cubic.cpp b/world/cubic/voxel_chunk_cubic.cpp index e7df3fd..0ff9272 100644 --- a/world/cubic/voxel_chunk_cubic.cpp +++ b/world/cubic/voxel_chunk_cubic.cpp @@ -31,12 +31,12 @@ VoxelChunkCubic::~VoxelChunkCubic() { } void VoxelChunkCubic::_setup_channels() { - set_channel_count(MAX_DEFAULT_CHANNELS); + channel_set_count(MAX_DEFAULT_CHANNELS); } 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, "isolevel_channel"), "set_channel_compressed", "get_channel_compressed", 1); + 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"), "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("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); diff --git a/world/default/voxel_chunk_default.cpp b/world/default/voxel_chunk_default.cpp index 61e9e55..5d9a699 100644 --- a/world/default/voxel_chunk_default.cpp +++ b/world/default/voxel_chunk_default.cpp @@ -755,9 +755,9 @@ void VoxelChunkDefault::_bake_light(Ref light) { int64_t dsy = static_cast(_data_size_y); int64_t dsz = static_cast(_data_size_z); - uint8_t *channel_color_r = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - uint8_t *channel_color_g = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - uint8_t *channel_color_b = get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + uint8_t *channel_color_r = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + uint8_t *channel_color_g = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + 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); @@ -810,9 +810,9 @@ void VoxelChunkDefault::_bake_light(Ref light) { } } void VoxelChunkDefault::_clear_baked_lights() { - fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_R); - fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_G); - fill_channel(0, DEFAULT_CHANNEL_LIGHT_COLOR_B); + channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_R); + channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_G); + channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_B); } void VoxelChunkDefault::_world_light_added(const Ref &light) { _lights.push_back(light); @@ -866,8 +866,8 @@ VoxelChunkDefault::~VoxelChunkDefault() { debug_mesh_free(); } -void VoxelChunkDefault::_setup_channels() { - set_channel_count(MAX_DEFAULT_CHANNELS); +void VoxelChunkDefault::_channel_setup() { + channel_set_count(MAX_DEFAULT_CHANNELS); } void VoxelChunkDefault::_bind_methods() { @@ -939,7 +939,7 @@ void VoxelChunkDefault::_bind_methods() { ClassDB::bind_method(D_METHOD("emit_build_finished"), &VoxelChunkDefault::emit_build_finished); //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); diff --git a/world/default/voxel_chunk_default.h b/world/default/voxel_chunk_default.h index 446aed8..510f2c7 100644 --- a/world/default/voxel_chunk_default.h +++ b/world/default/voxel_chunk_default.h @@ -180,7 +180,7 @@ public: ~VoxelChunkDefault(); protected: - virtual void _setup_channels(); + virtual void _channel_setup(); virtual void _visibility_changed(bool visible); diff --git a/world/jobs/voxel_light_job.cpp b/world/jobs/voxel_light_job.cpp index 7b01fbd..a0a7f01 100644 --- a/world/jobs/voxel_light_job.cpp +++ b/world/jobs/voxel_light_job.cpp @@ -34,7 +34,7 @@ void VoxelLightJob::phase_light() { Ref chunk = _chunk; 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(); bool gr = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0; diff --git a/world/marching_cubes/voxel_chunk_marching_cubes.cpp b/world/marching_cubes/voxel_chunk_marching_cubes.cpp index d4ef3f3..e418836 100644 --- a/world/marching_cubes/voxel_chunk_marching_cubes.cpp +++ b/world/marching_cubes/voxel_chunk_marching_cubes.cpp @@ -30,13 +30,13 @@ VoxelChunkMarchingCubes::VoxelChunkMarchingCubes() { VoxelChunkMarchingCubes::~VoxelChunkMarchingCubes() { } -void VoxelChunkMarchingCubes::_setup_channels() { - set_channel_count(MAX_DEFAULT_CHANNELS); +void VoxelChunkMarchingCubes::_channel_setup() { + channel_set_count(MAX_DEFAULT_CHANNELS); } 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, "isolevel_channel"), "set_channel_compressed", "get_channel_compressed", 1); + 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"), "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("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); diff --git a/world/marching_cubes/voxel_chunk_marching_cubes.h b/world/marching_cubes/voxel_chunk_marching_cubes.h index e873917..06f32e2 100644 --- a/world/marching_cubes/voxel_chunk_marching_cubes.h +++ b/world/marching_cubes/voxel_chunk_marching_cubes.h @@ -33,7 +33,7 @@ public: ~VoxelChunkMarchingCubes(); protected: - virtual void _setup_channels(); + virtual void _channel_setup(); static void _bind_methods(); }; diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index 24a8a9c..e8b9f04 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -283,10 +283,10 @@ Ref VoxelChunk::job_get_current() { } //Voxel Data -void VoxelChunk::setup_channels() { - ERR_FAIL_COND_MSG(!has_method("_setup_channels"), "VoxelChunk: _setup_channels() is missing! Please implement it!"); +void VoxelChunk::channel_setup() { + 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) { @@ -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_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; } -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; } @@ -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; 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); @@ -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; 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; } -int VoxelChunk::get_channel_count() const { +int VoxelChunk::channel_get_count() const { return _channels.size(); } -void VoxelChunk::set_channel_count(const int count) { +void VoxelChunk::channel_set_count(const int count) { if (count == _channels.size()) return; @@ -376,18 +376,18 @@ void VoxelChunk::set_channel_count(const int count) { _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); 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()); 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()); 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); } -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()); uint8_t *ch = _channels.get(channel_index); if (ch == NULL) { - allocate_channel(channel_index, value); + channel_allocate(channel_index, value); return; } @@ -416,7 +416,7 @@ void VoxelChunk::fill_channel(const uint8_t value, const int channel_index) { 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()); 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); 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); uint8_t *ch = _channels.get(channel_index); if (ch == NULL) { - allocate_channel(channel_index, default_value); + channel_allocate(channel_index, default_value); 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; } -PoolByteArray VoxelChunk::get_channel_array(const int channel_index) const { +PoolByteArray VoxelChunk::channel_get_array(const int channel_index) const { PoolByteArray arr; 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; } -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) return; if (_channels.size() <= channel_index) - set_channel_count(channel_index + 1); + channel_set_count(channel_index + 1); 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; 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; } -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) return; int size = _data_size_x * _data_size_y * _data_size_z; if (_channels.size() <= channel_index) - set_channel_count(channel_index + 1); + channel_set_count(channel_index + 1); 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("_setup_channels")); + BIND_VMETHOD(MethodInfo("_channel_setup")); BIND_VMETHOD(MethodInfo("_bake_lights")); 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"); //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("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("set_voxel", "value", "x", "y", "z", "channel_index"), &VoxelChunk::set_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", "index"), &VoxelChunk::set_voxel); - ClassDB::bind_method(D_METHOD("get_channel_count"), &VoxelChunk::get_channel_count); - ClassDB::bind_method(D_METHOD("set_channel_count", "count"), &VoxelChunk::set_channel_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "set_channel_count", "get_channel_count"); + ClassDB::bind_method(D_METHOD("channel_get_count"), &VoxelChunk::channel_get_count); + ClassDB::bind_method(D_METHOD("channel_set_count", "count"), &VoxelChunk::channel_set_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("ensure_channel_allocated", "channel_index", "default_value"), &VoxelChunk::ensure_channel_allocated); - ClassDB::bind_method(D_METHOD("allocate_channel", "channel_index", "default_value"), &VoxelChunk::allocate_channel); - ClassDB::bind_method(D_METHOD("fill_channel", "value", "channel_index"), &VoxelChunk::fill_channel); - ClassDB::bind_method(D_METHOD("dealloc_channel", "channel_index"), &VoxelChunk::dealloc_channel); + ClassDB::bind_method(D_METHOD("channel_is_allocated", "index"), &VoxelChunk::channel_is_allocated); + ClassDB::bind_method(D_METHOD("channel_ensure_allocated", "index", "default_value"), &VoxelChunk::channel_ensure_allocated); + ClassDB::bind_method(D_METHOD("channel_allocate", "index", "default_value"), &VoxelChunk::channel_allocate); + ClassDB::bind_method(D_METHOD("channel_fill", "value", "index"), &VoxelChunk::channel_fill); + 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("set_channel_array", "channel_index", "array"), &VoxelChunk::set_channel_array); + ClassDB::bind_method(D_METHOD("channel_get_array", "index"), &VoxelChunk::channel_get_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("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); + ClassDB::bind_method(D_METHOD("channel_get_compressed", "index"), &VoxelChunk::channel_get_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_data_index", "x", "y", "z"), &VoxelChunk::get_data_index); diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index c800765..2c13492 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -155,32 +155,32 @@ public: Ref job_get_current(); //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); - 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; - 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); + 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_index); - int get_channel_count() const; - void set_channel_count(const int count); + int channel_get_count() const; + void channel_set_count(const int count); - bool is_channel_allocated(const int channel_index); - void ensure_channel_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 fill_channel(const uint8_t value, const int channel_index); - void dealloc_channel(const int channel_index); + bool channel_is_allocated(const int channel_index); + void channel_ensure_allocated(const int channel_index, const uint8_t default_value = 0); + void channel_allocate(const int channel_index, const uint8_t default_value = 0); + void channel_fill(const uint8_t value, const int channel_index); + void channel_dealloc(const int channel_index); - uint8_t *get_channel(const int channel_index); - uint8_t *get_valid_channel(const int channel_index, const uint8_t default_value = 0); + uint8_t *channel_get(const int channel_index); + uint8_t *channel_get_valid(const int channel_index, const uint8_t default_value = 0); - PoolByteArray get_channel_array(const int channel_index) const; - void set_channel_array(const int channel_index, const PoolByteArray &array); + PoolByteArray channel_get_array(const int channel_index) const; + void channel_set_array(const int channel_index, const PoolByteArray &array); - PoolByteArray get_channel_compressed(const int channel_index) const; - void set_channel_compressed(const int channel_index, const PoolByteArray &data); + PoolByteArray channel_get_compressed(const int channel_index) const; + 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_data_index(const int x, const int y, const int z) const;