[Bf-blender-cvs] [8c0dd76757f] greasepencil-refactor: GPencil: Move duplicated sbuffer vertex color set to function

Antonio Vazquez noreply at git.blender.org
Mon Jan 20 15:35:46 CET 2020


Commit: 8c0dd76757fce0528587246ab8b1f8d89e90d006
Author: Antonio Vazquez
Date:   Mon Jan 20 15:35:28 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB8c0dd76757fce0528587246ab8b1f8d89e90d006

GPencil: Move duplicated sbuffer vertex color set to function

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

M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_gpencil.h

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index cfaeba1578d..ad30d334040 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -737,24 +737,8 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
       return GP_STROKEADD_INVALID;
     }
 
-    /* Copy fill vertex color. */
-    if (GPENCIL_USE_VERTEX_COLOR_FILL(p->scene->toolsettings, p->brush)) {
-      copy_v3_v3(gpd->runtime.vert_color_fill, p->brush->rgb);
-      gpd->runtime.vert_color_fill[3] = p->brush->gpencil_settings->vertex_factor;
-      srgb_to_linearrgb_v4(gpd->runtime.vert_color_fill, gpd->runtime.vert_color_fill);
-    }
-    else {
-      zero_v4(gpd->runtime.vert_color_fill);
-    }
-    /* Copy stroke vertex color. */
-    if (GPENCIL_USE_VERTEX_COLOR_STROKE(p->scene->toolsettings, p->brush)) {
-      copy_v3_v3(gpd->runtime.vert_color, p->brush->rgb);
-      gpd->runtime.vert_color[3] = p->brush->gpencil_settings->vertex_factor;
-      srgb_to_linearrgb_v4(gpd->runtime.vert_color, gpd->runtime.vert_color);
-    }
-    else {
-      zero_v4(gpd->runtime.vert_color);
-    }
+    /* Set vertex colors for buffer. */
+    ED_gpencil_sbuffer_vertex_color_set(p->scene->toolsettings, p->brush, gpd);
 
     /* get pointer to destination point */
     pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 1aee83ce08f..b5d42178a51 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -122,24 +122,8 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
   gpd->runtime.sbuffer_sflag = 0;
   gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
 
-  /* Copy fill vertex color. */
-  if (GPENCIL_USE_VERTEX_COLOR_FILL(p->scene->toolsettings, p->brush)) {
-    copy_v3_v3(gpd->runtime.vert_color_fill, p->brush->rgb);
-    gpd->runtime.vert_color_fill[3] = p->brush->gpencil_settings->vertex_factor;
-    srgb_to_linearrgb_v4(gpd->runtime.vert_color_fill, gpd->runtime.vert_color_fill);
-  }
-  else {
-    zero_v4(gpd->runtime.vert_color_fill);
-  }
-  /* Copy stroke vertex color. */
-  if (GPENCIL_USE_VERTEX_COLOR_STROKE(p->scene->toolsettings, p->brush)) {
-    copy_v3_v3(gpd->runtime.vert_color, p->brush->rgb);
-    gpd->runtime.vert_color[3] = p->brush->gpencil_settings->vertex_factor;
-    srgb_to_linearrgb_v4(gpd->runtime.vert_color, gpd->runtime.vert_color);
-  }
-  else {
-    zero_v4(gpd->runtime.vert_color);
-  }
+  /* Set vertex colors for buffer. */
+  ED_gpencil_sbuffer_vertex_color_set(p->scene->toolsettings, p->brush, gpd);
 
   if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE)) {
     gpd->runtime.sbuffer_sflag |= GP_STROKE_CYCLIC;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index b1a9484d5de..4f682d3ac7c 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2574,3 +2574,26 @@ void ED_gpencil_point_vertex_color_set(ToolSettings *ts, Brush *brush, bGPDspoin
     zero_v4(pt->vert_color);
   }
 }
+
+void ED_gpencil_sbuffer_vertex_color_set(ToolSettings *ts, Brush *brush, bGPdata *gpd)
+{
+  float vertex_color[4];
+  copy_v3_v3(vertex_color, brush->rgb);
+  vertex_color[3] = brush->gpencil_settings->vertex_factor;
+  srgb_to_linearrgb_v4(vertex_color, vertex_color);
+
+  /* Copy fill vertex color. */
+  if (GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush)) {
+    copy_v4_v4(gpd->runtime.vert_color_fill, vertex_color);
+  }
+  else {
+    zero_v4(gpd->runtime.vert_color_fill);
+  }
+  /* Copy stroke vertex color. */
+  if (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush)) {
+    copy_v4_v4(gpd->runtime.vert_color, vertex_color);
+  }
+  else {
+    zero_v4(gpd->runtime.vert_color);
+  }
+}
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 4e5f8f3d27a..ffb28f10db7 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -303,5 +303,8 @@ void ED_gpencil_fill_vertex_color_set(struct ToolSettings *ts,
 void ED_gpencil_point_vertex_color_set(struct ToolSettings *ts,
                                        struct Brush *brush,
                                        struct bGPDspoint *pt);
+void ED_gpencil_sbuffer_vertex_color_set(struct ToolSettings *ts,
+                                         struct Brush *brush,
+                                         struct bGPdata *gpd);
 
 #endif /*  __ED_GPENCIL_H__ */



More information about the Bf-blender-cvs mailing list