Commit: 155c85b4318bbbe09b6041f7747dca7b95401ed5
Author: Antonio Vazquez
Date:   Tue Nov 26 20:20:51 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB155c85b4318bbbe09b6041f7747dca7b95401ed5

GPencil: Fix error in Reset All Brushes

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/editors/gpencil/gpencil_data.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index a972909c75c..7daff2c93b9 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2105,6 +2105,7 @@ class 
VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
             return False
 
         gp_settings = brush.gpencil_settings
+        ma = None
         if gp_settings.use_material_pin is False:
             if ob.active_material_index >= 0:
                 ma = ob.material_slots[ob.active_material_index].material
diff --git a/source/blender/editors/gpencil/gpencil_data.c 
b/source/blender/editors/gpencil/gpencil_data.c
index 202d96fe87d..e76c1f06311 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1642,35 +1642,23 @@ static void gp_bruh_delete_mode_brushes(Main *bmain, 
const enum eContextObjectMo
     if (brush->gpencil_settings == NULL) {
       continue;
     }
+
+    short preset = brush->gpencil_settings->preset_type;
+
     /* Verify to delete only the brushes of the current mode. */
-    if ((mode == CTX_MODE_PAINT_GPENCIL) && (!ELEM(brush->gpencil_tool,
-                                                   GPAINT_TOOL_DRAW,
-                                                   GPAINT_TOOL_FILL,
-                                                   GPAINT_TOOL_ERASE,
-                                                   GPAINT_TOOL_TINT))) {
+    if ((mode == CTX_MODE_PAINT_GPENCIL) &&
+        ((preset < GP_BRUSH_PRESET_AIRBRUSH) || (preset > 
GP_BRUSH_PRESET_TINT))) {
       continue;
     }
-    if ((mode == CTX_MODE_SCULPT_GPENCIL) && (!ELEM(brush->gpencil_tool,
-                                                    GPSCULPT_TOOL_SMOOTH,
-                                                    GPSCULPT_TOOL_STRENGTH,
-                                                    GPSCULPT_TOOL_THICKNESS,
-                                                    GPSCULPT_TOOL_GRAB,
-                                                    GPSCULPT_TOOL_PUSH,
-                                                    GPSCULPT_TOOL_TWIST,
-                                                    GPSCULPT_TOOL_PINCH,
-                                                    GPSCULPT_TOOL_RANDOMIZE,
-                                                    GPSCULPT_TOOL_CLONE))) {
+    if ((mode == CTX_MODE_SCULPT_GPENCIL) &&
+        ((preset < GP_BRUSH_PRESET_SMOOTH_STROKE) || (preset > 
GP_BRUSH_PRESET_CLONE_STROKE))) {
       continue;
     }
-    if ((mode == CTX_MODE_WEIGHT_GPENCIL) && (!ELEM(brush->gpencil_tool, 
GPWEIGHT_TOOL_DRAW))) {
+    if ((mode == CTX_MODE_WEIGHT_GPENCIL) && (preset != 
GP_BRUSH_PRESET_DRAW_WEIGHT)) {
       continue;
     }
-    if ((mode == CTX_MODE_VERTEX_GPENCIL) && (!ELEM(brush->gpencil_tool,
-                                                    GPVERTEX_TOOL_DRAW,
-                                                    GPVERTEX_TOOL_BLUR,
-                                                    GPVERTEX_TOOL_AVERAGE,
-                                                    GPVERTEX_TOOL_SMEAR,
-                                                    GPVERTEX_TOOL_REPLACE))) {
+    if ((mode == CTX_MODE_VERTEX_GPENCIL) &&
+        ((preset < GP_BRUSH_PRESET_VERTEX_DRAW) || (preset > 
GP_BRUSH_PRESET_VERTEX_REPLACE))) {
       continue;
     }
 
@@ -2559,7 +2547,8 @@ static bool gpencil_active_color_poll(bContext *C)
   return false;
 }
 
-/* **************** Lock and hide any color non used in current layer 
************************** */
+/* **************** Lock and hide any color non used in current layer 
**************************
+ */
 static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
 {
   bGPdata *gpd = ED_gpencil_data_get_active(C);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to