[Bf-blender-cvs] [dc6281d87fe] temp-gpencil-automask: GPencil: Fix bug for automasking stroke layer and material

Antonio Vazquez noreply at git.blender.org
Fri Oct 7 17:07:42 CEST 2022


Commit: dc6281d87fecee180a86a10fd5806727f5c936f2
Author: Antonio Vazquez
Date:   Fri Oct 7 17:07:31 2022 +0200
Branches: temp-gpencil-automask
https://developer.blender.org/rBdc6281d87fecee180a86a10fd5806727f5c936f2

GPencil: Fix bug for automasking stroke layer and material

If both layers modes are selected, the check was wrong.

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

M	source/blender/editors/gpencil/gpencil_sculpt_paint.c

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

diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 93a6c0bc084..780ced229c5 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1836,6 +1836,9 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
   bGPDlayer *gpl_active = BKE_gpencil_layer_active_get(gpd);
   Material *mat_active = BKE_gpencil_material(ob, ob->actcol);
 
+  /* By default use active values. */
+  bGPDlayer *gpl_active_stroke = gpl_active;
+  Material *mat_active_stroke = mat_active;
   /* Find nearest stroke to find the layer and material. */
   if (is_masking_layer_stroke || is_masking_material_stroke) {
     bGPDlayer *gpl_near = NULL;
@@ -1843,10 +1846,10 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
     get_nearest_stroke_to_brush(gso, mval_i, &gpl_near, &gps_near);
     if (gps_near != NULL) {
       if (is_masking_layer_stroke) {
-        gpl_active = gpl_near;
+        gpl_active_stroke = gpl_near;
       }
       if (is_masking_material_stroke) {
-        mat_active = BKE_object_material_get(ob, gps_near->mat_nr + 1);
+        mat_active_stroke = BKE_object_material_get(ob, gps_near->mat_nr + 1);
       }
     }
   }
@@ -1873,13 +1876,26 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
           continue;
         }
 
-        /* Layer Auto-Masking. */
-        if ((is_masking_layer_stroke || is_masking_layer_active) && (gpl == gpl_active)) {
+        /* Stroke Layer Auto-Masking. */
+        if (is_masking_layer_stroke && (gpl == gpl_active_stroke)) {
           BLI_ghash_insert(gso->automasking_strokes, gps_active, gps_active);
           continue;
         }
-        /* Material Auto-Masking. */
-        if (is_masking_material_stroke || is_masking_material_active) {
+        /* Active Layer Auto-Masking. */
+        if (is_masking_layer_active && (gpl == gpl_active)) {
+          BLI_ghash_insert(gso->automasking_strokes, gps_active, gps_active);
+          continue;
+        }
+        /* Stroke Material Auto-Masking. */
+        if (is_masking_material_stroke) {
+          Material *mat = BKE_object_material_get(ob, gps->mat_nr + 1);
+          if (mat == mat_active_stroke) {
+            BLI_ghash_insert(gso->automasking_strokes, gps_active, gps_active);
+            continue;
+          }
+        }
+        /* Active Material Auto-Masking. */
+        if (is_masking_material_active) {
           Material *mat = BKE_object_material_get(ob, gps->mat_nr + 1);
           if (mat == mat_active) {
             BLI_ghash_insert(gso->automasking_strokes, gps_active, gps_active);



More information about the Bf-blender-cvs mailing list