[Bf-blender-cvs] [58b7d61ebfc] greasepencil-object: GPencil: Fix problem when color is nofill in SVG

Antonioya noreply at git.blender.org
Sun Jul 14 17:20:03 CEST 2019


Commit: 58b7d61ebfca1df24d439a93fd87c12b466b22f3
Author: Antonioya
Date:   Sun Jul 14 17:19:45 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rB58b7d61ebfca1df24d439a93fd87c12b466b22f3

GPencil: Fix problem when color is nofill in SVG

If the color in the SVG converted was nofill, the stroke had fill color in grease pencil and this creates glitches because the shape was not defined to be filled.

Now, the name of the color is checked to verify if the material is for stroke, and if only there is one material with this name, the fill is disabled.

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

M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 975c567789e..70c66805dc0 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2237,15 +2237,37 @@ void BKE_gpencil_convert_curve(Main *bmain,
     color[2] = 1.0f;
     fill = false;
   }
+
+  /* Special case: If the color was created by the SVG add-on and the name contains '_stroke' and
+   * there is only one color, the stroke must not be closed, fill to false and use for
+   * stroke the fill color.
+   */
+  bool only_stroke = false;
+  if (ob_cu->totcol == 1) {
+    Material *ma_stroke = give_current_material(ob_cu, 1);
+    if ((ma_stroke) && (strstr(ma_stroke->id.name, "_stroke") != NULL)) {
+      only_stroke = true;
+    }
+  }
+
   int r_idx = gpencil_check_same_material_color(ob_gp, color, mat_gp);
   if (r_idx < 0) {
+    Material *ma_stroke = NULL;
     mat_gp = gpencil_add_from_curve_material(bmain, ob_gp, color, gpencil_lines, fill, &r_idx);
-    /* If object has more than 1 material, use second material for stroke color */
+    /* If object has more than 1 material, use second material for stroke color. */
     if (ob_cu->totcol > 1) {
-      Material *ma_stroke = give_current_material(ob_cu, 2);
+      ma_stroke = give_current_material(ob_cu, 2);
+      linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &ma_stroke->r);
+    }
+    else if (only_stroke) {
+      /* Also use the first color if the fill is none for stroke color. */
+      ma_stroke = give_current_material(ob_cu, 1);
       linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &ma_stroke->r);
+      /* set fill to off */
+      mat_gp->gp_style->flag &= ~GP_STYLE_FILL_SHOW;
     }
   }
+
   gps->mat_nr = r_idx;
 
   /* Add stroke to frame.*/
@@ -2290,7 +2312,7 @@ void BKE_gpencil_convert_curve(Main *bmain,
     }
   }
   /* Cyclic curve, close stroke. */
-  if (cyclic) {
+  if ((cyclic) && (!only_stroke)) {
     BKE_gpencil_close_stroke(gps);
   }



More information about the Bf-blender-cvs mailing list