[Bf-blender-cvs] [779f683ed00] greasepencil-object: GPencil: Fix Vertex Color one step behind

Antonio Vazquez noreply at git.blender.org
Wed Feb 12 10:33:15 CET 2020


Commit: 779f683ed00571781c43443012e9d940f3983fb6
Author: Antonio Vazquez
Date:   Wed Feb 12 10:33:05 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB779f683ed00571781c43443012e9d940f3983fb6

GPencil: Fix Vertex Color one step behind

The vertex color was always one step behind because draw engine uses evaluated data, but paint operators don't update eval data before ending to speed up the painting process and to improve the pencil feeling.

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

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 1f3d165cb21..7469279b3f7 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -738,7 +738,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
     }
 
     /* Set vertex colors for buffer. */
-    ED_gpencil_sbuffer_vertex_color_set(p->scene->toolsettings, p->brush, gpd);
+    ED_gpencil_sbuffer_vertex_color_set(p->depsgraph, 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 6f9f221a6e6..87375b856b8 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -123,7 +123,7 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
   gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
 
   /* Set vertex colors for buffer. */
-  ED_gpencil_sbuffer_vertex_color_set(p->scene->toolsettings, p->brush, gpd);
+  ED_gpencil_sbuffer_vertex_color_set(p->depsgraph, 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 ccc6765a9ce..10e14466774 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2530,7 +2530,10 @@ void ED_gpencil_point_vertex_color_set(ToolSettings *ts, Brush *brush, bGPDspoin
   }
 }
 
-void ED_gpencil_sbuffer_vertex_color_set(ToolSettings *ts, Brush *brush, bGPdata *gpd)
+void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph,
+                                         ToolSettings *ts,
+                                         Brush *brush,
+                                         bGPdata *gpd)
 {
   float vertex_color[4];
   copy_v3_v3(vertex_color, brush->rgb);
@@ -2551,6 +2554,13 @@ void ED_gpencil_sbuffer_vertex_color_set(ToolSettings *ts, Brush *brush, bGPdata
   else {
     zero_v4(gpd->runtime.vert_color);
   }
+
+  /* Copy to eval data because paint operators don't tag refresh until end for speedup painting. */
+  bGPdata *gpd_eval = (bGPdata *)DEG_get_evaluated_id(depsgraph, &gpd->id);
+  if (gpd_eval != NULL) {
+    copy_v4_v4(gpd_eval->runtime.vert_color, gpd->runtime.vert_color);
+    copy_v4_v4(gpd_eval->runtime.vert_color_fill, gpd->runtime.vert_color_fill);
+  }
 }
 
 /* Check if the stroke collides with brush. */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 937ca83899f..a04033d3a9c 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -300,7 +300,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,
+void ED_gpencil_sbuffer_vertex_color_set(struct Depsgraph *depsgraph,
+                                         struct ToolSettings *ts,
                                          struct Brush *brush,
                                          struct bGPdata *gpd);



More information about the Bf-blender-cvs mailing list