From c8fbf198143dd0fcde4c51feabe6687687992cb2 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Sun, 28 Apr 2019 16:28:49 +0100 Subject: [PATCH] Rename get/set_voxel_iso => get/set_voxel_f --- dmc/hermite_value.h | 2 +- dmc/voxel_mesher_dmc.cpp | 16 ++++++++-------- voxel_buffer.cpp | 6 +++--- voxel_buffer.h | 9 ++++----- voxel_isosurface_tool.cpp | 6 +++--- voxel_map.cpp | 4 ++-- voxel_provider_image.cpp | 2 +- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/dmc/hermite_value.h b/dmc/hermite_value.h index a4ffd74..37e012a 100644 --- a/dmc/hermite_value.h +++ b/dmc/hermite_value.h @@ -30,7 +30,7 @@ inline HermiteValue get_hermite_value(const VoxelBuffer &voxels, unsigned int x, HermiteValue v; - v.value = voxels.get_voxel_iso(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL); + v.value = voxels.get_voxel_f(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL); Vector3 gradient; diff --git a/dmc/voxel_mesher_dmc.cpp b/dmc/voxel_mesher_dmc.cpp index 8421c5c..20aa6ed 100644 --- a/dmc/voxel_mesher_dmc.cpp +++ b/dmc/voxel_mesher_dmc.cpp @@ -58,15 +58,15 @@ bool can_split(Vector3i node_origin, int node_size, const VoxelAccess &voxels, f // Fighting with Clang-format here /**/ - float v0 = voxels.buffer.get_voxel_iso(origin.x, /* */ origin.y, /* */ origin.z, /* */ channel); // 0 - float v1 = voxels.buffer.get_voxel_iso(origin.x + step, origin.y, /* */ origin.z, /* */ channel); // 1 - float v2 = voxels.buffer.get_voxel_iso(origin.x + step, origin.y, /* */ origin.z + step, channel); // 2 - float v3 = voxels.buffer.get_voxel_iso(origin.x, /* */ origin.y, /* */ origin.z + step, channel); // 3 + float v0 = voxels.buffer.get_voxel_f(origin.x, /* */ origin.y, /* */ origin.z, /* */ channel); // 0 + float v1 = voxels.buffer.get_voxel_f(origin.x + step, origin.y, /* */ origin.z, /* */ channel); // 1 + float v2 = voxels.buffer.get_voxel_f(origin.x + step, origin.y, /* */ origin.z + step, channel); // 2 + float v3 = voxels.buffer.get_voxel_f(origin.x, /* */ origin.y, /* */ origin.z + step, channel); // 3 - float v4 = voxels.buffer.get_voxel_iso(origin.x, /* */ origin.y + step, origin.z, /* */ channel); // 4 - float v5 = voxels.buffer.get_voxel_iso(origin.x + step, origin.y + step, origin.z, /* */ channel); // 5 - float v6 = voxels.buffer.get_voxel_iso(origin.x + step, origin.y + step, origin.z + step, channel); // 6 - float v7 = voxels.buffer.get_voxel_iso(origin.x, /* */ origin.y + step, origin.z + step, channel); // 7 + float v4 = voxels.buffer.get_voxel_f(origin.x, /* */ origin.y + step, origin.z, /* */ channel); // 4 + float v5 = voxels.buffer.get_voxel_f(origin.x + step, origin.y + step, origin.z, /* */ channel); // 5 + float v6 = voxels.buffer.get_voxel_f(origin.x + step, origin.y + step, origin.z + step, channel); // 6 + float v7 = voxels.buffer.get_voxel_f(origin.x, /* */ origin.y + step, origin.z + step, channel); // 7 int hstep = step / 2; diff --git a/voxel_buffer.cpp b/voxel_buffer.cpp index adc55e9..4beec10 100644 --- a/voxel_buffer.cpp +++ b/voxel_buffer.cpp @@ -293,13 +293,13 @@ void VoxelBuffer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_size_z"), &VoxelBuffer::get_size_z); ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "channel"), &VoxelBuffer::_set_voxel_binding, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("set_voxel_iso", "value", "x", "y", "z", "channel"), &VoxelBuffer::_set_voxel_iso_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_voxel_f", "value", "x", "y", "z", "channel"), &VoxelBuffer::_set_voxel_f_binding, DEFVAL(0)); ClassDB::bind_method(D_METHOD("set_voxel_v", "value", "pos", "channel"), &VoxelBuffer::set_voxel_v, DEFVAL(0)); ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "channel"), &VoxelBuffer::_get_voxel_binding, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_voxel_iso", "x", "y", "z", "channel"), &VoxelBuffer::get_voxel_iso, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("get_voxel_f", "x", "y", "z", "channel"), &VoxelBuffer::get_voxel_f, DEFVAL(0)); ClassDB::bind_method(D_METHOD("fill", "value", "channel"), &VoxelBuffer::fill, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("fill_iso", "value", "channel"), &VoxelBuffer::fill_iso, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("fill_f", "value", "channel"), &VoxelBuffer::fill_f, DEFVAL(0)); ClassDB::bind_method(D_METHOD("fill_area", "value", "min", "max", "channel"), &VoxelBuffer::_fill_area_binding, DEFVAL(0)); ClassDB::bind_method(D_METHOD("copy_from", "other", "channel"), &VoxelBuffer::_copy_from_binding, DEFVAL(0)); ClassDB::bind_method(D_METHOD("copy_from_area", "other", "src_min", "src_max", "dst_min", "channel"), &VoxelBuffer::_copy_from_area_binding, DEFVAL(0)); diff --git a/voxel_buffer.h b/voxel_buffer.h index d179c18..df33be7 100644 --- a/voxel_buffer.h +++ b/voxel_buffer.h @@ -65,15 +65,14 @@ public: void try_set_voxel(int x, int y, int z, int value, unsigned int channel_index = 0); - // TODO Rename set_voxel_iso to set_voxel_f etc. - _FORCE_INLINE_ void set_voxel_iso(real_t value, int x, int y, int z, unsigned int channel_index = 0) { set_voxel(iso_to_byte(value), x, y, z, channel_index); } - _FORCE_INLINE_ real_t get_voxel_iso(int x, int y, int z, unsigned int channel_index = 0) const { return byte_to_iso(get_voxel(x, y, z, channel_index)); } + _FORCE_INLINE_ void set_voxel_f(real_t value, int x, int y, int z, unsigned int channel_index = 0) { set_voxel(iso_to_byte(value), x, y, z, channel_index); } + _FORCE_INLINE_ real_t get_voxel_f(int x, int y, int z, unsigned int channel_index = 0) const { return byte_to_iso(get_voxel(x, y, z, channel_index)); } _FORCE_INLINE_ int get_voxel(const Vector3i pos, unsigned int channel_index = 0) const { return get_voxel(pos.x, pos.y, pos.z, channel_index); } _FORCE_INLINE_ void set_voxel(int value, const Vector3i pos, unsigned int channel_index = 0) { set_voxel(value, pos.x, pos.y, pos.z, channel_index); } void fill(int defval, unsigned int channel_index = 0); - _FORCE_INLINE_ void fill_iso(float value, unsigned int channel = 0) { fill(iso_to_byte(value), channel); } + _FORCE_INLINE_ void fill_f(float value, unsigned int channel = 0) { fill(iso_to_byte(value), channel); } void fill_area(int defval, Vector3i min, Vector3i max, unsigned int channel_index = 0); bool is_uniform(unsigned int channel_index) const; @@ -120,7 +119,7 @@ protected: void _copy_from_binding(Ref other, unsigned int channel); void _copy_from_area_binding(Ref other, Vector3 src_min, Vector3 src_max, Vector3 dst_min, unsigned int channel); _FORCE_INLINE_ void _fill_area_binding(int defval, Vector3 min, Vector3 max, unsigned int channel_index) { fill_area(defval, Vector3i(min), Vector3i(max), channel_index); } - _FORCE_INLINE_ void _set_voxel_iso_binding(real_t value, int x, int y, int z, unsigned int channel) { set_voxel_iso(value, x, y, z, channel); } + _FORCE_INLINE_ void _set_voxel_f_binding(real_t value, int x, int y, int z, unsigned int channel) { set_voxel_f(value, x, y, z, channel); } private: struct Channel { diff --git a/voxel_isosurface_tool.cpp b/voxel_isosurface_tool.cpp index 59af720..947ba30 100644 --- a/voxel_isosurface_tool.cpp +++ b/voxel_isosurface_tool.cpp @@ -38,11 +38,11 @@ inline void do_op(VoxelBuffer &buffer, int x, int y, int z, float d1, VoxelIsoSu switch (op) { case VoxelIsoSurfaceTool::OP_ADD: - res = MIN(d1, buffer.get_voxel_iso(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL)); + res = MIN(d1, buffer.get_voxel_f(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL)); break; case VoxelIsoSurfaceTool::OP_SUBTRACT: - res = MAX(1.0 - d1, buffer.get_voxel_iso(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL)); + res = MAX(1.0 - d1, buffer.get_voxel_f(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL)); break; case VoxelIsoSurfaceTool::OP_SET: @@ -50,7 +50,7 @@ inline void do_op(VoxelBuffer &buffer, int x, int y, int z, float d1, VoxelIsoSu break; } - buffer.set_voxel_iso(res, x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL); + buffer.set_voxel_f(res, x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL); } } // namespace diff --git a/voxel_map.cpp b/voxel_map.cpp index 8d8d474..33087cf 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -75,7 +75,7 @@ float VoxelMap::get_voxel_f(int x, int y, int z, unsigned int c) { return _default_voxel[c]; } Vector3i lpos = to_local(pos); - return block->voxels->get_voxel_iso(lpos.x, lpos.y, lpos.z, c); + return block->voxels->get_voxel_f(lpos.x, lpos.y, lpos.z, c); } void VoxelMap::set_voxel_f(real_t value, int x, int y, int z, unsigned int c) { @@ -83,7 +83,7 @@ void VoxelMap::set_voxel_f(real_t value, int x, int y, int z, unsigned int c) { Vector3i pos(x, y, z); VoxelBlock *block = get_or_create_block_at_voxel_pos(pos); Vector3i lpos = to_local(pos); - block->voxels->set_voxel_iso(value, lpos.x, lpos.y, lpos.z, c); + block->voxels->set_voxel_f(value, lpos.x, lpos.y, lpos.z, c); } void VoxelMap::set_default_voxel(int value, unsigned int channel) { diff --git a/voxel_provider_image.cpp b/voxel_provider_image.cpp index 3579b3a..7871fa2 100644 --- a/voxel_provider_image.cpp +++ b/voxel_provider_image.cpp @@ -67,7 +67,7 @@ void VoxelProviderImage::emerge_block(Ref p_out_buffer, Vector3i or float h = get_height_blurred(image, ox + x, oz + z) * 200.0 - 50; for (int y = 0; y < bs; ++y) { - out_buffer.set_voxel_iso((oy + y) - h, x, y, z, _channel); + out_buffer.set_voxel_f((oy + y) - h, x, y, z, _channel); } } else {