Curves: Add remove_selection function #104813

Merged
Falk David merged 5 commits from filedescriptor/blender:curves-remove-selection-function into blender-v3.5-release 2023-02-16 15:26:24 +01:00
7 changed files with 250 additions and 149 deletions

View File

@ -29,11 +29,11 @@
icon_modifier="#84b8ffff" icon_modifier="#84b8ffff"
icon_shading="#ea7581ff" icon_shading="#ea7581ff"
icon_folder="#e3c16eff" icon_folder="#e3c16eff"
icon_border_intensity="0.85" icon_border_intensity="1"
> >
<wcol_regular> <wcol_regular>
<ThemeWidgetColors <ThemeWidgetColors
outline="#b8b8b8" outline="#4d4d4d"
inner="#dbdbdbff" inner="#dbdbdbff"
inner_sel="#668cccff" inner_sel="#668cccff"
item="#191919ff" item="#191919ff"
@ -48,7 +48,7 @@
</wcol_regular> </wcol_regular>
<wcol_tool> <wcol_tool>
<ThemeWidgetColors <ThemeWidgetColors
outline="#b8b8b8" outline="#4d4d4d"
inner="#dbdbdbff" inner="#dbdbdbff"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#191919ff" item="#191919ff"
@ -63,7 +63,7 @@
</wcol_tool> </wcol_tool>
<wcol_toolbar_item> <wcol_toolbar_item>
<ThemeWidgetColors <ThemeWidgetColors
outline="#363636" outline="#4d4d4d"
inner="#434343ff" inner="#434343ff"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#e6e6e6cc" item="#e6e6e6cc"
@ -78,7 +78,7 @@
</wcol_toolbar_item> </wcol_toolbar_item>
<wcol_radio> <wcol_radio>
<ThemeWidgetColors <ThemeWidgetColors
outline="#434343" outline="#4d4d4d"
inner="#3b3b3bff" inner="#3b3b3bff"
inner_sel="#5680c2e6" inner_sel="#5680c2e6"
item="#ffffffff" item="#ffffffff"
@ -93,7 +93,7 @@
</wcol_radio> </wcol_radio>
<wcol_text> <wcol_text>
<ThemeWidgetColors <ThemeWidgetColors
outline="#666666" outline="#4d4d4d"
inner="#282828ff" inner="#282828ff"
inner_sel="#333333ff" inner_sel="#333333ff"
item="#5680c2ff" item="#5680c2ff"
@ -108,7 +108,7 @@
</wcol_text> </wcol_text>
<wcol_option> <wcol_option>
<ThemeWidgetColors <ThemeWidgetColors
outline="#373737" outline="#4d4d4d"
inner="#3c3c3cff" inner="#3c3c3cff"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#ffffffff" item="#ffffffff"
@ -123,8 +123,8 @@
</wcol_option> </wcol_option>
<wcol_toggle> <wcol_toggle>
<ThemeWidgetColors <ThemeWidgetColors
outline="#999999" outline="#4d4d4d"
inner="#c0c0c0ff" inner="#dbdbdbff"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#191919ff" item="#191919ff"
text="#000000" text="#000000"
@ -138,7 +138,7 @@
</wcol_toggle> </wcol_toggle>
<wcol_num> <wcol_num>
<ThemeWidgetColors <ThemeWidgetColors
outline="#b8b8b8" outline="#4d4d4d"
inner="#d3d3d3ff" inner="#d3d3d3ff"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#80b1ffff" item="#80b1ffff"
@ -153,7 +153,7 @@
</wcol_num> </wcol_num>
<wcol_numslider> <wcol_numslider>
<ThemeWidgetColors <ThemeWidgetColors
outline="#b8b8b8" outline="#4d4d4d"
inner="#999999ff" inner="#999999ff"
inner_sel="#999999ff" inner_sel="#999999ff"
item="#e6e6e6ff" item="#e6e6e6ff"
@ -168,8 +168,8 @@
</wcol_numslider> </wcol_numslider>
<wcol_box> <wcol_box>
<ThemeWidgetColors <ThemeWidgetColors
outline="#959595" outline="#4d4d4d"
inner="#cccccc80" inner="#80808080"
inner_sel="#5680c2ff" inner_sel="#5680c2ff"
item="#191919ff" item="#191919ff"
text="#333333" text="#333333"
@ -183,7 +183,7 @@
</wcol_box> </wcol_box>
<wcol_menu> <wcol_menu>
<ThemeWidgetColors <ThemeWidgetColors
outline="#3b3b3b" outline="#3d3d3d"
inner="#3b3b3bff" inner="#3b3b3bff"
inner_sel="#767676ff" inner_sel="#767676ff"
item="#808080ff" item="#808080ff"
@ -217,7 +217,7 @@
inner="#c0c0c0ff" inner="#c0c0c0ff"
inner_sel="#cdcdcdff" inner_sel="#cdcdcdff"
item="#727272ff" item="#727272ff"
text="#1a1a1a" text="#4d4d4d"
text_sel="#1a1a1a" text_sel="#1a1a1a"
show_shaded="FALSE" show_shaded="FALSE"
shadetop="25" shadetop="25"
@ -304,11 +304,11 @@
<wcol_list_item> <wcol_list_item>
<ThemeWidgetColors <ThemeWidgetColors
outline="#e6e6e6" outline="#e6e6e6"
inner="#00000000" inner="#1a1a1a00"
inner_sel="#808080ff" inner_sel="#c0c0c0ff"
item="#1a1a1aff" item="#1a1a1aff"
text="#1a1a1a" text="#1a1a1a"
text_sel="#ffffff" text_sel="#000000"
show_shaded="FALSE" show_shaded="FALSE"
shadetop="0" shadetop="0"
shadedown="0" shadedown="0"
@ -316,6 +316,21 @@
> >
</ThemeWidgetColors> </ThemeWidgetColors>
</wcol_list_item> </wcol_list_item>
<wcol_view_item>
<ThemeWidgetColors
outline="#e6e6e6"
inner="#c0c0c044"
inner_sel="#c0c0c0ff"
item="#1a1a1aff"
text="#1a1a1a"
text_sel="#000000"
show_shaded="FALSE"
shadetop="0"
shadedown="0"
roundness="0.4"
>
</ThemeWidgetColors>
</wcol_view_item>
<wcol_state> <wcol_state>
<ThemeWidgetStateColors <ThemeWidgetStateColors
inner_anim="#73be4c" inner_anim="#73be4c"
@ -334,8 +349,8 @@
</wcol_state> </wcol_state>
<wcol_tab> <wcol_tab>
<ThemeWidgetColors <ThemeWidgetColors
outline="#656565" outline="#333333"
inner="#818181ff" inner="#808080cc"
inner_sel="#b3b3b3ff" inner_sel="#b3b3b3ff"
item="#28292dff" item="#28292dff"
text="#1a1a1a" text="#1a1a1a"
@ -414,6 +429,7 @@
bone_locked_weight="#ff000080" bone_locked_weight="#ff000080"
bundle_solid="#c8c8c8" bundle_solid="#c8c8c8"
camera_path="#000000" camera_path="#000000"
camera_passepartout="#000000"
skin_root="#b44d4d" skin_root="#b44d4d"
view_overlay="#000000" view_overlay="#000000"
transform="#ffffff" transform="#ffffff"
@ -452,9 +468,9 @@
</gradients> </gradients>
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b3ff" header="#ccccccff"
back="#b3b3b3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -519,9 +535,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -552,7 +568,7 @@
header="#adadadff" header="#adadadff"
header_text="#000000" header_text="#000000"
header_text_hi="#ffffff" header_text_hi="#ffffff"
button="#999999e6" button="#b3b3b3ff"
button_title="#1a1a1a" button_title="#1a1a1a"
button_text="#000000" button_text="#000000"
button_text_hi="#000000" button_text_hi="#000000"
@ -565,9 +581,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -623,9 +639,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -698,9 +714,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -783,9 +799,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b3ff" header="#ccccccff"
back="#b3b3b3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -843,14 +859,23 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b3ff" header="#ccccccff"
back="#b3b3b3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
</ThemeSpaceGeneric> </ThemeSpaceGeneric>
</space> </space>
<space_list>
<ThemeSpaceListGeneric
list="#181818"
list_title="#ffffff"
list_text="#ffffff"
list_text_hi="#ffffff"
>
</ThemeSpaceListGeneric>
</space_list>
</ThemeSequenceEditor> </ThemeSequenceEditor>
</sequence_editor> </sequence_editor>
<properties> <properties>
@ -871,7 +896,7 @@
button_title="#000000" button_title="#000000"
button_text="#000000" button_text="#000000"
button_text_hi="#000000" button_text_hi="#000000"
navigation_bar="#656565ff" navigation_bar="#1d1d1dff"
execution_buts="#00000000" execution_buts="#00000000"
tab_active="#6697e6" tab_active="#6697e6"
tab_inactive="#535353" tab_inactive="#535353"
@ -880,9 +905,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b300" header="#ccccccff"
back="#a3a3a3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -927,9 +952,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -939,44 +964,44 @@
</text_editor> </text_editor>
<node_editor> <node_editor>
<ThemeNodeEditor <ThemeNodeEditor
grid="#1B1B1B" grid="#282828"
node_selected="#f15800" node_selected="#ed5700"
node_active="#f15800" node_active="#ffffff"
wire="#191919" wire="#1a1a1aff"
wire_inner="#999999" wire_inner="#8d8d8d"
wire_select="#ffa733" wire_select="#ffffffb3"
selected_text="#7f7070" selected_text="#7f7f7f"
node_backdrop="#e6e6e6ff" node_backdrop="#666666ff"
converter_node="#66c4ff" converter_node="#12adff"
color_node="#ffcb4d" color_node="#cccc00"
group_node="#59b36ab9" group_node="#3b660a"
group_socket_node="#dfc300" group_socket_node="#000000"
frame_node="#9b9b9b60" frame_node="#0f0f0fcc"
matte_node="#977474" matte_node="#973c3c"
distor_node="#749797" distor_node="#4c9797"
noodle_curving="4" noodle_curving="4"
grid_levels="3" grid_levels="3"
dash_alpha="0.5" dash_alpha="0.5"
input_node="#cb3d4a" input_node="#ff3371"
output_node="#cb3d4a" output_node="#4d0017"
filter_node="#6c696f" filter_node="#551a80"
vector_node="#9999ff" vector_node="#4d4dff"
texture_node="#ffc399" texture_node="#e66800"
shader_node="#ea7581" shader_node="#24b524"
script_node="#6c696f" script_node="#084d4d"
pattern_node="#6c696f" pattern_node="#6c696f"
layout_node="#6c696f" layout_node="#6c696f"
geometry_node="#00d7a4" geometry_node="#00d6a3"
attribute_node="#3f5980" attribute_node="#001566"
> >
<space> <space>
<ThemeSpaceGeneric <ThemeSpaceGeneric
back="#353535" back="#1d1d1d"
title="#000000" title="#eeeeee"
text="#000000" text="#e6e6e6"
text_hi="#ffffff" text_hi="#ffffff"
header="#b3b3b3ff" header="#b3b3b3ff"
header_text="#000000" header_text="#eeeeee"
header_text_hi="#ffffff" header_text_hi="#ffffff"
button="#99999900" button="#99999900"
button_title="#1a1a1a" button_title="#1a1a1a"
@ -991,9 +1016,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b3ff" header="#ccccccff"
back="#b3b3b3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1013,8 +1038,8 @@
<outliner> <outliner>
<ThemeOutliner <ThemeOutliner
match="#337f33" match="#337f33"
selected_highlight="#7a8e99" selected_highlight="#7a8499"
active="#92aab7" active="#929eb7"
selected_object="#ffddb3" selected_object="#ffddb3"
active_object="#ffffff" active_object="#ffffff"
edited_object="#0080624d" edited_object="#0080624d"
@ -1042,9 +1067,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1091,9 +1116,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1125,9 +1150,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#b3b3b300" header="#ccccccff"
back="#a3a3a3cc" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1137,26 +1162,26 @@
</preferences> </preferences>
<console> <console>
<ThemeConsole <ThemeConsole
line_output="#6080ff" line_output="#71a8ff"
line_input="#ffffff" line_input="#f2f2f2"
line_info="#00aa00" line_info="#95d600"
line_error="#dc6060" line_error="#ff4d84"
cursor="#dc6060" cursor="#ff0000"
select="#ffffff30" select="#ffffff30"
> >
<space> <space>
<ThemeSpaceGeneric <ThemeSpaceGeneric
back="#000000" back="#1d1d1d"
title="#000000" title="#eeeeee"
text="#000000" text="#e6e6e6"
text_hi="#ffffff" text_hi="#ffffff"
header="#b3b3b3ff" header="#b3b3b3ff"
header_text="#000000" header_text="#000000"
header_text_hi="#ffffff" header_text_hi="#ffffff"
button="#7272727f" button="#30303000"
button_title="#000000" button_title="#ffffff"
button_text="#000000" button_text="#cccccc"
button_text_hi="#000000" button_text_hi="#ffffff"
navigation_bar="#00000000" navigation_bar="#00000000"
execution_buts="#00000000" execution_buts="#00000000"
tab_active="#6697e6" tab_active="#6697e6"
@ -1166,9 +1191,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1231,9 +1256,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1274,9 +1299,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1292,7 +1317,7 @@
title="#ffffff" title="#ffffff"
text="#ffffff" text="#ffffff"
text_hi="#ffffff" text_hi="#ffffff"
header="#adadadff" header="#999999ff"
header_text="#1a1a1a" header_text="#1a1a1a"
header_text_hi="#ffffff" header_text_hi="#ffffff"
button="#2f303500" button="#2f303500"
@ -1308,9 +1333,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1331,7 +1356,7 @@
header="#adadadff" header="#adadadff"
header_text="#000000" header_text="#000000"
header_text_hi="#ffffff" header_text_hi="#ffffff"
button="#999999e6" button="#b3b3b3ff"
button_title="#1a1a1a" button_title="#1a1a1a"
button_text="#000000" button_text="#000000"
button_text_hi="#000000" button_text_hi="#000000"
@ -1344,9 +1369,9 @@
> >
<panelcolors> <panelcolors>
<ThemePanelColors <ThemePanelColors
header="#42424200" header="#ccccccff"
back="#00000028" back="#ccccccff"
sub_back="#00000024" sub_back="#0000000f"
> >
</ThemePanelColors> </ThemePanelColors>
</panelcolors> </panelcolors>
@ -1585,8 +1610,8 @@
shadow="3" shadow="3"
shadow_offset_x="0" shadow_offset_x="0"
shadow_offset_y="-1" shadow_offset_y="-1"
shadow_alpha="0.3" shadow_alpha="1"
shadow_value="0.7" shadow_value="0.8"
> >
</ThemeFontStyle> </ThemeFontStyle>
</panel_title> </panel_title>
@ -1596,8 +1621,8 @@
shadow="3" shadow="3"
shadow_offset_x="0" shadow_offset_x="0"
shadow_offset_y="-1" shadow_offset_y="-1"
shadow_alpha="0.3" shadow_alpha="0"
shadow_value="0.7" shadow_value="0.8"
> >
</ThemeFontStyle> </ThemeFontStyle>
</widget_label> </widget_label>
@ -1607,8 +1632,8 @@
shadow="1" shadow="1"
shadow_offset_x="0" shadow_offset_x="0"
shadow_offset_y="-1" shadow_offset_y="-1"
shadow_alpha="0.3" shadow_alpha="0"
shadow_value="0.7" shadow_value="0.8"
> >
</ThemeFontStyle> </ThemeFontStyle>
</widget> </widget>

View File

@ -23,6 +23,7 @@ set(INC
set(SRC set(SRC
intern/curves_add.cc intern/curves_add.cc
intern/curves_data.cc intern/curves_data.cc
intern/curves_edit.cc
intern/curves_ops.cc intern/curves_ops.cc
intern/curves_selection.cc intern/curves_selection.cc
intern/curves_undo.cc intern/curves_undo.cc

View File

@ -0,0 +1,38 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup edcurves
*/
#include "BLI_index_mask_ops.hh"
#include "BKE_curves.hh"
#include "ED_curves.h"
namespace blender::ed::curves {
bool remove_selection(bke::CurvesGeometry &curves, const eAttrDomain selection_domain)
{
const bke::AttributeAccessor attributes = curves.attributes();
const VArray<bool> selection = attributes.lookup_or_default<bool>(
".selection", selection_domain, true);
const int domain_size_orig = attributes.domain_size(selection_domain);
Vector<int64_t> indices;
const IndexMask mask = index_mask_ops::find_indices_from_virtual_array(
selection.index_range(), selection, 4096, indices);
switch (selection_domain) {
case ATTR_DOMAIN_POINT:
curves.remove_points(mask);
break;
case ATTR_DOMAIN_CURVE:
curves.remove_curves(mask);
break;
default:
BLI_assert_unreachable();
}
return attributes.domain_size(selection_domain) != domain_size_orig;
}
} // namespace blender::ed::curves

View File

@ -1097,24 +1097,7 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
{ {
for (Curves *curves_id : get_unique_editable_curves(*C)) { for (Curves *curves_id : get_unique_editable_curves(*C)) {
bke::CurvesGeometry &curves = curves_id->geometry.wrap(); bke::CurvesGeometry &curves = curves_id->geometry.wrap();
const eAttrDomain domain = eAttrDomain(curves_id->selection_domain); if (remove_selection(curves, eAttrDomain(curves_id->selection_domain))) {
filedescriptor marked this conversation as resolved
Review

Picky: might as well remove this newline here too, doesn't seem helpful anymore

Picky: might as well remove this newline here too, doesn't seem helpful anymore
const bke::AttributeAccessor attributes = curves.attributes();
const VArray<bool> selection = attributes.lookup_or_default<bool>(".selection", domain, false);
const int domain_size_orig = attributes.domain_size(domain);
Vector<int64_t> indices;
const IndexMask mask = index_mask_ops::find_indices_from_virtual_array(
selection.index_range(), selection, 4096, indices);
switch (domain) {
case ATTR_DOMAIN_POINT:
curves.remove_points(mask);
break;
case ATTR_DOMAIN_CURVE:
curves.remove_curves(mask);
break;
default:
BLI_assert_unreachable();
}
if (attributes.domain_size(domain) != domain_size_orig) {
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY); DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id); WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
} }

View File

@ -185,5 +185,17 @@ bool select_circle(const ViewContext &vc,
eSelectOp sel_op); eSelectOp sel_op);
/** \} */ /** \} */
/* -------------------------------------------------------------------- */
/** \name Editing
* \{ */
/**
filedescriptor marked this conversation as resolved
Review
/**
 * Remove (dissolve) selected curves or points based on the ".selection" attribute.
 */
``` /** * Remove (dissolve) selected curves or points based on the ".selection" attribute. */ ```
* Remove (dissolve) selected curves or points based on the ".selection" attribute.
* \returns true if any point or curve was removed.
*/
bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain);
/** \} */
} // namespace blender::ed::curves } // namespace blender::ed::curves
#endif #endif

View File

@ -832,6 +832,36 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
return nullptr; return nullptr;
} }
/** The name of the active tool is "builtin_brush." concatenated with the returned string. */
static blender::StringRefNull curves_active_tool_name_get(const eBrushCurvesSculptTool tool)
{
switch (tool) {
case CURVES_SCULPT_TOOL_COMB:
return "comb";
case CURVES_SCULPT_TOOL_DELETE:
return "delete";
case CURVES_SCULPT_TOOL_SNAKE_HOOK:
return "snake_hook";
case CURVES_SCULPT_TOOL_ADD:
return "add";
case CURVES_SCULPT_TOOL_GROW_SHRINK:
return "grow_shrink";
case CURVES_SCULPT_TOOL_SELECTION_PAINT:
return "selection_paint";
case CURVES_SCULPT_TOOL_PINCH:
return "pinch";
case CURVES_SCULPT_TOOL_SMOOTH:
return "smooth";
case CURVES_SCULPT_TOOL_PUFF:
return "puff";
case CURVES_SCULPT_TOOL_DENSITY:
return "density";
case CURVES_SCULPT_TOOL_SLIDE:
return "slide";
}
return "";
}
static bool brush_generic_tool_set(bContext *C, static bool brush_generic_tool_set(bContext *C,
Main *bmain, Main *bmain,
Paint *paint, Paint *paint,
@ -869,8 +899,14 @@ static bool brush_generic_tool_set(bContext *C,
* tool_name again. */ * tool_name again. */
int tool_result = brush_tool(brush, paint->runtime.tool_offset); int tool_result = brush_tool(brush, paint->runtime.tool_offset);
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C); ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
RNA_enum_name_from_value(items, tool_result, &tool_name); if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
}
else {
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
RNA_enum_name_from_value(items, tool_result, &tool_name);
}
char tool_id[MAX_NAME]; char tool_id[MAX_NAME];
SNPRINTF(tool_id, "builtin_brush.%s", tool_name); SNPRINTF(tool_id, "builtin_brush.%s", tool_name);
@ -921,8 +957,14 @@ static int brush_select_exec(bContext *C, wmOperator *op)
if (paint == nullptr) { if (paint == nullptr) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
RNA_enum_name_from_value(items, tool, &tool_name); if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
}
else {
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
RNA_enum_name_from_value(items, tool, &tool_name);
}
if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) { if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) {
return OPERATOR_FINISHED; return OPERATOR_FINISHED;

View File

@ -141,7 +141,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C)
km_id = "Grease Pencil Stroke Vertex Mode"; km_id = "Grease Pencil Stroke Vertex Mode";
break; break;
case CTX_MODE_SCULPT_CURVES: case CTX_MODE_SCULPT_CURVES:
km_id = "Curves Sculpt"; km_id = "Sculpt Curves";
break; break;
} }
} }