[Bf-blender-cvs] [2b191cd2b41] master: 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.

Joseph Eagar noreply at git.blender.org
Sat Apr 16 03:51:55 CEST 2022


Commit: 2b191cd2b41b7eaa794ef8d7f702482ab3d1b6eb
Author: Joseph Eagar
Date:   Fri Apr 15 18:49:38 2022 -0700
Branches: master
https://developer.blender.org/rB2b191cd2b41b7eaa794ef8d7f702482ab3d1b6eb

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.

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/blenkernel/intern/paint.c
M	source/blender/editors/sculpt_paint/sculpt_ops.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index fc86d02b83e..6408873f13e 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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)
         ]},
     )
 
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index c0195e5abc8..5fd7984ea90 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -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(
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index f84852d1d0e..9581bf2071c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -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;



More information about the Bf-blender-cvs mailing list