[Bf-blender-cvs] [f8f6e0b2562] master: GPencil: New Dilate parameter for Fill brush

Antonio Vazquez noreply at git.blender.org
Tue May 4 16:46:38 CEST 2021


Commit: f8f6e0b256213b4ae6a135b5987e8a92a64e6bbf
Author: Antonio Vazquez
Date:   Tue May 4 16:38:52 2021 +0200
Branches: master
https://developer.blender.org/rBf8f6e0b256213b4ae6a135b5987e8a92a64e6bbf

GPencil: New Dilate parameter for Fill brush

Internally, when using Fill brush a dilate of the filled area was done, but this was hardcoded to 1 pixel.

In some situations, this was not enough, so now the value is accesible in the UI and can be set with different values.

Also, as this value is more used than `Leak Size`, the new Dilate is on Topbar, and Leak Size has been moved to Advanced panel.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 22ef0fe77dd..4e3e4c2d58d 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1225,7 +1225,7 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
         row = layout.row(align=True)
         row.prop(gp_settings, "fill_factor")
         row = layout.row(align=True)
-        row.prop(gp_settings, "fill_leak", text="Leak Size")
+        row.prop(gp_settings, "dilate_pixels")
         row = layout.row(align=True)
         row.prop(brush, "size", text="Thickness")
         layout.use_property_split = use_property_split_prev
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index ab012a6f2ef..08d581bfa24 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1467,6 +1467,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
                 row.prop(gp_settings, "extend_stroke_factor")
                 row.prop(gp_settings, "show_fill_extend", text="", icon='GRID')
 
+                col.separator()
+                col.prop(gp_settings, "fill_leak", text="Leak Size")
+
                 col.separator()
                 col.prop(gp_settings, "fill_simplify_level", text="Simplify")
                 if gp_settings.fill_draw_mode != 'STROKE':
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ef567044282..20c5af0efb6 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -989,6 +989,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
       brush->gpencil_settings->draw_smoothfac = 0.1f;
       brush->gpencil_settings->draw_smoothlvl = 1;
       brush->gpencil_settings->draw_subdivide = 1;
+      brush->gpencil_settings->dilate_pixels = 1;
 
       brush->gpencil_settings->flag |= GP_BRUSH_FILL_SHOW_EXTENDLINES;
 
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index ee38ad707a4..182231b5878 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -23,6 +23,7 @@
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
+#include "DNA_brush_types.h"
 #include "DNA_genfile.h"
 #include "DNA_modifier_types.h"
 #include "DNA_text_types.h"
@@ -74,6 +75,14 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+    /* Grease Pencil: Set default value for dilate pixels. */
+    if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "int", "dilate_pixels")) {
+      LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
+        if (brush->gpencil_settings) {
+          brush->gpencil_settings->dilate_pixels = 1;
+        }
+      }
+    }
   }
   /**
    * Versioning code until next subversion bump goes here.
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index bb0a2916d2d..62d64c67b08 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1247,6 +1247,7 @@ static bool dilate_shape(ImBuf *ibuf)
 static void gpencil_get_outline_points(tGPDfill *tgpf, const bool dilate)
 {
   ImBuf *ibuf;
+  Brush *brush = tgpf->brush;
   float rgba[4];
   void *lock;
   int v[2];
@@ -1279,7 +1280,9 @@ static void gpencil_get_outline_points(tGPDfill *tgpf, const bool dilate)
 
   /* Dilate. */
   if (dilate) {
-    dilate_shape(ibuf);
+    for (int i = 0; i < brush->gpencil_settings->dilate_pixels; i++) {
+      dilate_shape(ibuf);
+    }
   }
 
   for (int idx = imagesize - 1; idx != 0; idx--) {
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index a11e7d77c67..986c009ac26 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -133,7 +133,8 @@ typedef struct BrushGpencilSettings {
 
   /** Factor to extend stroke extremes using fill tool. */
   float fill_extend_fac;
-  char _pad3[4];
+  /** Number of pixels to dilate fill area. */
+  int dilate_pixels;
 
   struct CurveMapping *curve_sensitivity;
   struct CurveMapping *curve_strength;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index e7daa55af6c..044e6ca2da1 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1617,6 +1617,15 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
       prop, "Stroke Extension", "Strokes end extension for closing gaps, use zero to disable");
   RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
 
+  /* Number of pixels to dilate fill area. */
+  prop = RNA_def_property(srna, "dilate_pixels", PROP_INT, PROP_NONE);
+  RNA_def_property_int_sdna(prop, NULL, "dilate_pixels");
+  RNA_def_property_range(prop, 0, 20);
+  RNA_def_property_int_default(prop, 1);
+  RNA_def_property_ui_text(prop, "Dilate", "Number of pixels to dilate fill area");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
   /* Flags */
   prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE);



More information about the Bf-blender-cvs mailing list