Rename get/set_voxel_iso => get/set_voxel_f

This commit is contained in:
Marc Gilleron 2019-04-28 16:28:49 +01:00
parent ce57c656d5
commit c8fbf19814
7 changed files with 22 additions and 23 deletions

View File

@ -30,7 +30,7 @@ inline HermiteValue get_hermite_value(const VoxelBuffer &voxels, unsigned int x,
HermiteValue v; 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; Vector3 gradient;

View File

@ -58,15 +58,15 @@ bool can_split(Vector3i node_origin, int node_size, const VoxelAccess &voxels, f
// Fighting with Clang-format here /**/ // Fighting with Clang-format here /**/
float v0 = voxels.buffer.get_voxel_iso(origin.x, /* */ origin.y, /* */ origin.z, /* */ channel); // 0 float v0 = voxels.buffer.get_voxel_f(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 v1 = voxels.buffer.get_voxel_f(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 v2 = voxels.buffer.get_voxel_f(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 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 v4 = voxels.buffer.get_voxel_f(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 v5 = voxels.buffer.get_voxel_f(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 v6 = voxels.buffer.get_voxel_f(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 v7 = voxels.buffer.get_voxel_f(origin.x, /* */ origin.y + step, origin.z + step, channel); // 7
int hstep = step / 2; int hstep = step / 2;

View File

@ -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("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", "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("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", "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", "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("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", "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)); ClassDB::bind_method(D_METHOD("copy_from_area", "other", "src_min", "src_max", "dst_min", "channel"), &VoxelBuffer::_copy_from_area_binding, DEFVAL(0));

View File

@ -65,15 +65,14 @@ public:
void try_set_voxel(int x, int y, int z, int value, unsigned int channel_index = 0); 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_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_ 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_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_ 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_ 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_ 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); } _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); 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); void fill_area(int defval, Vector3i min, Vector3i max, unsigned int channel_index = 0);
bool is_uniform(unsigned int channel_index) const; bool is_uniform(unsigned int channel_index) const;
@ -120,7 +119,7 @@ protected:
void _copy_from_binding(Ref<VoxelBuffer> other, unsigned int channel); void _copy_from_binding(Ref<VoxelBuffer> other, unsigned int channel);
void _copy_from_area_binding(Ref<VoxelBuffer> other, Vector3 src_min, Vector3 src_max, Vector3 dst_min, unsigned int channel); void _copy_from_area_binding(Ref<VoxelBuffer> 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 _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: private:
struct Channel { struct Channel {

View File

@ -38,11 +38,11 @@ inline void do_op(VoxelBuffer &buffer, int x, int y, int z, float d1, VoxelIsoSu
switch (op) { switch (op) {
case VoxelIsoSurfaceTool::OP_ADD: 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; break;
case VoxelIsoSurfaceTool::OP_SUBTRACT: 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; break;
case VoxelIsoSurfaceTool::OP_SET: case VoxelIsoSurfaceTool::OP_SET:
@ -50,7 +50,7 @@ inline void do_op(VoxelBuffer &buffer, int x, int y, int z, float d1, VoxelIsoSu
break; break;
} }
buffer.set_voxel_iso(res, x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL); buffer.set_voxel_f(res, x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL);
} }
} // namespace } // namespace

View File

@ -75,7 +75,7 @@ float VoxelMap::get_voxel_f(int x, int y, int z, unsigned int c) {
return _default_voxel[c]; return _default_voxel[c];
} }
Vector3i lpos = to_local(pos); 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) { 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); Vector3i pos(x, y, z);
VoxelBlock *block = get_or_create_block_at_voxel_pos(pos); VoxelBlock *block = get_or_create_block_at_voxel_pos(pos);
Vector3i lpos = to_local(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) { void VoxelMap::set_default_voxel(int value, unsigned int channel) {

View File

@ -67,7 +67,7 @@ void VoxelProviderImage::emerge_block(Ref<VoxelBuffer> p_out_buffer, Vector3i or
float h = get_height_blurred(image, ox + x, oz + z) * 200.0 - 50; float h = get_height_blurred(image, ox + x, oz + z) * 200.0 - 50;
for (int y = 0; y < bs; ++y) { 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 { } else {