diff --git a/iolite_plugins/voxel_editing_plugin/editing_tools.h b/iolite_plugins/voxel_editing_plugin/editing_tools.h index 030dca1..253946b 100644 --- a/iolite_plugins/voxel_editing_plugin/editing_tools.h +++ b/iolite_plugins/voxel_editing_plugin/editing_tools.h @@ -342,7 +342,9 @@ static void handle_tool_voxel(io_ref_t shape, const tool_parameters_t& params) params.placement_mode == placement_mode_paint || params.placement_mode == placement_mode_erase; if (solid_voxels_only) - voxels.remove_non_solid_voxels(shape); + voxels.remove_voxels(shape); + else + voxels.remove_voxels(shape); // Apply mirroring (if any) mirror(shape, params, voxels); @@ -588,7 +590,7 @@ static void handle_tool_extrude(io_ref_t shape, tool_parameters_t& params, { voxels_extruded = voxels_extruded.prepare_fill(shape, params.palette_range); - voxels_extruded.remove_non_solid_voxels(shape); + voxels_extruded.remove_voxels(shape); } if (!is_left_mouse_buttom_pressed()) @@ -939,7 +941,10 @@ static void handle_tool_box(io_ref_t shape, tool_parameters_t& params) mirror(shape, params, voxels); if (solid_voxels_only) - voxels.remove_non_solid_voxels(shape); + voxels.remove_voxels(shape); + else + voxels.remove_voxels(shape); + if (is_selection) voxels.update_from_shape(shape); diff --git a/iolite_plugins/voxel_editing_plugin/sparse_volume.h b/iolite_plugins/voxel_editing_plugin/sparse_volume.h index 8dde776..f4126f1 100644 --- a/iolite_plugins/voxel_editing_plugin/sparse_volume.h +++ b/iolite_plugins/voxel_editing_plugin/sparse_volume.h @@ -28,6 +28,14 @@ // STL #include +//----------------------------------------------------------------------------// +enum remove_mode_ +{ + remove_mode_solid, + remove_mode_non_solid, +}; +using remove_mode_t = uint8_t; + //----------------------------------------------------------------------------// template struct sparse_occupancy_mask_t { @@ -185,7 +193,7 @@ struct sparse_volume_t } } - void remove_non_solid_voxels(io_ref_t shape) + template void remove_voxels(io_ref_t shape) { const auto data = io_component_voxel_shape->get_voxel_data(shape); const auto dim = io_component_voxel_shape->get_dim(shape); @@ -203,8 +211,17 @@ struct sparse_volume_t const uint32_t index = coord.x + coord.y * dim.x + coord.z * dim.x * dim.y; - if (data[index] == 0u) - continue; + + if constexpr (Mode == remove_mode_non_solid) + { + if (data[index] == 0u) + continue; + } + else if constexpr (Mode == remove_mode_solid) + { + if (data[index] != 0u) + continue; + } updated_volume.set(coord, palette_index, dim); }