Curves: Remove option to disable selection

Remove the redundant option to disable selection in order to simplify
the tools and UI, both conceptually and internally.

It was possible to disable curves selection completely by clicking on
the active selection domain. However, that was redundant compared to
just selecting everything by pressing "A". The remaining potential use
could have been saving a selection for later, but that can be done with
more complete attribute editing tools in the future.
This commit is contained in:
Hans Goudey 2022-12-24 16:09:16 -05:00
parent 8fab53c023
commit 00b3f863b8
9 changed files with 7 additions and 72 deletions

View File

@ -5621,8 +5621,6 @@ def km_sculpt_curves(params):
{"properties": [("mode", 'SMOOTH')]}),
("curves.set_selection_domain", {"type": 'ONE', "value": 'PRESS'}, {"properties": [("domain", 'POINT')]}),
("curves.set_selection_domain", {"type": 'TWO', "value": 'PRESS'}, {"properties": [("domain", 'CURVE')]}),
("curves.disable_selection", {"type": 'ONE', "value": 'PRESS', "alt": True}, None),
("curves.disable_selection", {"type": 'TWO', "value": 'PRESS', "alt": True}, None),
*_template_paint_radial_control("curves_sculpt"),
*_template_items_select_actions(params, "sculpt_curves.select_all"),
("sculpt_curves.min_distance_edit", {"type": 'R', "value": 'PRESS', "shift": True}, {}),

View File

@ -721,18 +721,9 @@ class VIEW3D_HT_header(Header):
curves = obj.data
row = layout.row(align=True)
# Combine the "use selection" toggle with the "set domain" operators
# to allow turning selection off directly.
domain = curves.selection_domain
if domain == 'POINT':
row.prop(curves, "use_sculpt_selection", text="", icon='CURVE_BEZCIRCLE')
else:
row.operator("curves.set_selection_domain", text="", icon='CURVE_BEZCIRCLE').domain = 'POINT'
if domain == 'CURVE':
row.prop(curves, "use_sculpt_selection", text="", icon='CURVE_PATH')
else:
row.operator("curves.set_selection_domain", text="", icon='CURVE_PATH').domain = 'CURVE'
row.operator("curves.set_selection_domain", text="", icon='CURVE_BEZCIRCLE', depress=(domain == 'POINT')).domain = 'POINT'
row.operator("curves.set_selection_domain", text="", icon='CURVE_PATH', depress=(domain == 'CURVE')).domain = 'CURVE'
# Grease Pencil
if obj and obj.type == 'GPENCIL' and context.gpencil_data:

View File

@ -3846,5 +3846,9 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
*/
{
/* Keep this block, even when empty. */
const int CV_SCULPT_SELECTION_ENABLED = (1 << 1);
LISTBASE_FOREACH (Curves *, curves_id, &bmain->hair_curves) {
curves_id->flag &= ~CV_SCULPT_SELECTION_ENABLED;
}
}
}

View File

@ -31,10 +31,6 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata)
static bool everything_selected(const Curves &curves_id)
{
if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
/* When the selection is disabled, conceptually everything is selected. */
return true;
}
const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap(
curves_id.geometry);
blender::VArray<float> selection;

View File

@ -744,13 +744,12 @@ static int curves_set_selection_domain_exec(bContext *C, wmOperator *op)
const eAttrDomain domain = eAttrDomain(RNA_enum_get(op->ptr, "domain"));
for (Curves *curves_id : get_unique_editable_curves(*C)) {
if (curves_id->selection_domain == domain && (curves_id->flag & CV_SCULPT_SELECTION_ENABLED)) {
if (curves_id->selection_domain == domain) {
continue;
}
const eAttrDomain old_domain = eAttrDomain(curves_id->selection_domain);
curves_id->selection_domain = domain;
curves_id->flag |= CV_SCULPT_SELECTION_ENABLED;
CurvesGeometry &curves = CurvesGeometry::wrap(curves_id->geometry);
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
@ -802,38 +801,6 @@ static void CURVES_OT_set_selection_domain(wmOperatorType *ot)
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
}
namespace disable_selection {
static int curves_disable_selection_exec(bContext *C, wmOperator * /*op*/)
{
for (Curves *curves_id : get_unique_editable_curves(*C)) {
curves_id->flag &= ~CV_SCULPT_SELECTION_ENABLED;
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
* attribute for now. */
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
}
WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, nullptr);
return OPERATOR_FINISHED;
}
} // namespace disable_selection
static void CURVES_OT_disable_selection(wmOperatorType *ot)
{
ot->name = "Disable Selection";
ot->idname = __func__;
ot->description = "Disable the drawing of influence of selection in sculpt mode";
ot->exec = disable_selection::curves_disable_selection_exec;
ot->poll = editable_curves_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static bool varray_contains_nonzero(const VArray<float> &data)
{
bool contains_nonzero = false;
@ -1035,6 +1002,5 @@ void ED_operatortypes_curves()
WM_operatortype_append(CURVES_OT_snap_curves_to_surface);
WM_operatortype_append(CURVES_OT_set_selection_domain);
WM_operatortype_append(SCULPT_CURVES_OT_select_all);
WM_operatortype_append(CURVES_OT_disable_selection);
WM_operatortype_append(CURVES_OT_surface_set);
}

View File

@ -26,9 +26,6 @@ static VArray<float> get_curves_selection(const CurvesGeometry &curves, const eA
VArray<float> get_curves_selection(const Curves &curves_id)
{
if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
return VArray<float>::ForSingle(1.0f, CurvesGeometry::wrap(curves_id.geometry).curves_num());
}
return get_curves_selection(CurvesGeometry::wrap(curves_id.geometry),
eAttrDomain(curves_id.selection_domain));
}
@ -49,9 +46,6 @@ static VArray<float> get_point_selection(const CurvesGeometry &curves, const eAt
VArray<float> get_point_selection(const Curves &curves_id)
{
if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
return VArray<float>::ForSingle(1.0f, CurvesGeometry::wrap(curves_id.geometry).points_num());
}
return get_point_selection(CurvesGeometry::wrap(curves_id.geometry),
eAttrDomain(curves_id.selection_domain));
}
@ -97,9 +91,6 @@ static IndexMask retrieve_selected_curves(const CurvesGeometry &curves,
IndexMask retrieve_selected_curves(const Curves &curves_id, Vector<int64_t> &r_indices)
{
if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
return CurvesGeometry::wrap(curves_id.geometry).curves_range();
}
return retrieve_selected_curves(CurvesGeometry::wrap(curves_id.geometry),
eAttrDomain(curves_id.selection_domain),
r_indices);
@ -142,9 +133,6 @@ static IndexMask retrieve_selected_points(const CurvesGeometry &curves,
IndexMask retrieve_selected_points(const Curves &curves_id, Vector<int64_t> &r_indices)
{
if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
return CurvesGeometry::wrap(curves_id.geometry).points_range();
}
return retrieve_selected_points(CurvesGeometry::wrap(curves_id.geometry),
eAttrDomain(curves_id.selection_domain),
r_indices);

View File

@ -81,7 +81,6 @@ struct SelectionPaintOperationExecutor {
curves_id_ = static_cast<Curves *>(object_->data);
curves_ = &CurvesGeometry::wrap(curves_id_->geometry);
curves_id_->flag |= CV_SCULPT_SELECTION_ENABLED;
if (curves_->curves_num() == 0) {
return;
}

View File

@ -180,7 +180,6 @@ typedef struct Curves {
/** #Curves.flag */
enum {
HA_DS_EXPAND = (1 << 0),
CV_SCULPT_SELECTION_ENABLED = (1 << 1),
};
/** #Curves.symmetry */

View File

@ -414,12 +414,6 @@ static void rna_def_curves(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Curves_update_data");
prop = RNA_def_property(srna, "use_sculpt_selection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CV_SCULPT_SELECTION_ENABLED);
RNA_def_property_ui_text(prop, "Use Sculpt Selection", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Curves_update_draw");
/* attributes */
rna_def_attributes_common(srna);