Mask by color now auto-creates a

color attribute if one does not exist,
and no longer passes through to the
translate tool on tweak grab.
This commit is contained in:
Joseph Eagar 2022-04-15 18:49:38 -07:00
parent 8eb40d2063
commit 2b191cd2b4
Notes: blender-bot 2023-02-14 06:45:14 +01:00
Referenced by issue #102940, Regression: Blender 3.4.0 Release Candidate crash on 'Mask by Color'
3 changed files with 11 additions and 10 deletions

View File

@ -7370,7 +7370,7 @@ def km_3d_view_tool_sculpt_mask_by_color(params):
"3D View Tool: Sculpt, Mask by Color",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
("sculpt.mask_by_color", {"type": params.tool_mouse, "value": 'CLICK'}, None)
("sculpt.mask_by_color", {"type": params.tool_mouse, "value": 'PRESS'}, None)
]},
)

View File

@ -1869,6 +1869,10 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
BKE_id_attributes_active_color_set(&orig_me->id, layer);
DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
if (object->sculpt && object->sculpt->pbvh) {
BKE_pbvh_update_active_vcol(object->sculpt->pbvh, orig_me);
}
}
void BKE_sculpt_update_object_for_edit(

View File

@ -1030,14 +1030,6 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
return OPERATOR_CANCELLED;
}
if (!SCULPT_has_colors(ss)) {
return OPERATOR_CANCELLED;
}
if (SCULPT_has_loop_colors(ob)) {
BKE_pbvh_ensure_node_loops(ss->pbvh);
}
SCULPT_vertex_random_access_ensure(ss);
/* Tools that are not brushes do not have the brush gizmo to update the vertex as the mouse move,
@ -1049,12 +1041,17 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
SCULPT_undo_push_begin(ob, "Mask by color");
BKE_sculpt_color_layer_create_if_needed(ob);
const int active_vertex = SCULPT_active_vertex_get(ss);
const float threshold = RNA_float_get(op->ptr, "threshold");
const bool invert = RNA_boolean_get(op->ptr, "invert");
const bool preserve_mask = RNA_boolean_get(op->ptr, "preserve_previous_mask");
if (SCULPT_has_loop_colors(ob)) {
BKE_pbvh_ensure_node_loops(ss->pbvh);
}
if (RNA_boolean_get(op->ptr, "contiguous")) {
sculpt_mask_by_color_contiguous(ob, active_vertex, threshold, invert, preserve_mask);
}
@ -1080,7 +1077,7 @@ static void SCULPT_OT_mask_by_color(wmOperatorType *ot)
/* api callbacks */
ot->invoke = sculpt_mask_by_color_invoke;
ot->poll = SCULPT_vertex_colors_poll;
ot->poll = SCULPT_mode_poll;
ot->flag = OPTYPE_REGISTER;