[Bf-blender-cvs] [43622285621] soc-2021-uv-editor-improvements: GPencil: New Brush option to define Caps type

Antonio Vazquez noreply at git.blender.org
Mon Aug 9 03:24:40 CEST 2021


Commit: 43622285621b8585d9110090886e7a5faf6d2ba2
Author: Antonio Vazquez
Date:   Wed Aug 4 15:54:54 2021 +0200
Branches: soc-2021-uv-editor-improvements
https://developer.blender.org/rB43622285621b8585d9110090886e7a5faf6d2ba2

GPencil: New Brush option to define Caps type

This is used to set the default caps type for the stroke. Before always was rounded and only could be changed later in Edit mode

Two new buttons has been added to topbar.

NOTE: New icons are been designed (T90414)

The buttons are expanded to list in Properties panel.

Reviewed By: mendio, HooglyBoogly

Differential Revision: https://developer.blender.org/D11999

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/draw/intern/draw_cache_impl_gpencil.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.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 4bfd2fd32b0..97a0c5abf24 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1252,6 +1252,12 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
         if brush.gpencil_tool == 'TINT':
             row = layout.row(align=True)
             row.prop(gp_settings, "vertex_mode", text="Mode")
+        else:
+            row = layout.row(align=True)
+            if context.region.type == 'TOOL_HEADER':
+                row.prop(gp_settings, "caps_type", text="", expand=True)
+            else:
+                row.prop(gp_settings, "caps_type", text="Caps Type")
 
     # FIXME: tools must use their own UI drawing!
     if tool.idname in {
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 336ccd40d5c..2a476ab41bb 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -552,6 +552,9 @@ bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(Object *ob)
     gps->caps[0] = gps->caps[1] = GP_STROKE_CAP_ROUND;
     gps->runtime.stroke_start = 1; /* Add one for the adjacency index. */
     copy_v4_v4(gps->vert_color_fill, gpd->runtime.vert_color_fill);
+    /* Caps. */
+    gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
+
     gpd->runtime.sbuffer_gps = gps;
   }
   return gpd->runtime.sbuffer_gps;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index d6f6dbb2b10..aaea1c0ddaf 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -996,6 +996,9 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
   gps->inittime = p->inittime;
   gps->uv_scale = 1.0f;
 
+  /* Set stroke caps. */
+  gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
+
   /* allocate enough memory for a continuous array for storage points */
   const int subdivide = brush->gpencil_settings->draw_subdivide;
 
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index cf49aefe2ea..27374f21b66 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -335,6 +335,9 @@ static void gpencil_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
   gps->uv_scale = 1.0f;
   gps->inittime = 0.0f;
 
+  /* Set stroke caps. */
+  gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
+
   /* Apply the vertex color to fill. */
   ED_gpencil_fill_vertex_color_set(ts, brush, gps);
 
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 986c009ac26..634ebdff253 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -76,7 +76,9 @@ typedef struct BrushGpencilSettings {
   float fill_threshold;
   /** Number of pixel to consider the leak is too small (x 2). */
   short fill_leak;
-  char _pad2[2];
+  /* Type of caps: eGPDstroke_Caps. */
+  int8_t caps_type;
+  char _pad;
 
   int flag2;
 
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 2b09ea51a84..eb968f9ecde 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1281,6 +1281,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static EnumPropertyItem rna_enum_gpencil_brush_caps_types_items[] = {
+      {GP_STROKE_CAP_ROUND, "ROUND", ICON_HANDLETYPE_AUTO_CLAMP_VEC, "Round", ""},
+      {GP_STROKE_CAP_FLAT, "FLAT", ICON_HANDLETYPE_VECTOR_VEC, "Flat", ""},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "BrushGpencilSettings", NULL);
   RNA_def_struct_sdna(srna, "BrushGpencilSettings");
   RNA_def_struct_path_func(srna, "rna_BrushGpencilSettings_path");
@@ -1750,6 +1756,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
   RNA_def_property_update(
       prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_eraser_mode_update");
 
+  prop = RNA_def_property(srna, "caps_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "caps_type");
+  RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_caps_types_items);
+  RNA_def_property_ui_text(prop, "Caps Type", "The shape of the start and end of the stroke");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
   prop = RNA_def_property(srna, "fill_draw_mode", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "fill_draw_mode");
   RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_draw_modes_items);



More information about the Bf-blender-cvs mailing list