[Bf-blender-cvs] [00feefba102] greasepencil-refactor: GPencil: Refactor: Enable Vertex color mode in vertex paint

Clément Foucault noreply at git.blender.org
Sat Jan 11 16:41:23 CET 2020


Commit: 00feefba1021f08a6896011d1c9a848c711ec386
Author: Clément Foucault
Date:   Sat Jan 11 16:41:16 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB00feefba1021f08a6896011d1c9a848c711ec386

GPencil: Refactor: Enable Vertex color mode in vertex paint

This is to follow the same behavior as meshes.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_data.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index bf2204c6f7a..8c88c3e64a8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -132,11 +132,12 @@ static void gpencil_shade_color(float color[3])
 /* Apply all overrides from the solid viewport mode to the GPencil material. */
 static MaterialGPencilStyle *gpencil_viewport_material_overrides(GPENCIL_PrivateData *pd,
                                                                  Object *ob,
+                                                                 int color_type,
                                                                  MaterialGPencilStyle *gp_style)
 {
   static MaterialGPencilStyle gp_style_tmp;
 
-  switch (pd->v3d_color_type) {
+  switch (color_type) {
     case V3D_SHADING_MATERIAL_COLOR:
       copy_v4_v4(gp_style_tmp.stroke_rgba, gp_style->stroke_rgba);
       copy_v4_v4(gp_style_tmp.fill_rgba, gp_style->fill_rgba);
@@ -210,6 +211,12 @@ GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Obje
     matpool = gpencil_material_pool_add(pd);
   }
 
+  /* Force vertex color in solid mode with vertex paint mode. Same behavior as meshes. */
+  bGPdata *gpd = (bGPdata *)ob->data;
+  int color_type = (pd->v3d_color_type != -1 && GPENCIL_VERTEX_MODE(gpd)) ?
+                       V3D_SHADING_VERTEX_COLOR :
+                       pd->v3d_color_type;
+
   GPENCIL_MaterialPool *pool = matpool;
   for (int i = 0; i < max_ii(1, ob->totcol); i++) {
     int mat_id = (i % GP_MATERIAL_BUFFER_LEN);
@@ -247,7 +254,7 @@ GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Obje
       mat_data->flag |= GP_STROKE_OVERLAP;
     }
 
-    gp_style = gpencil_viewport_material_overrides(pd, ob, gp_style);
+    gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style);
 
     /* Stroke Style */
     if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index d6758f1f7bd..0210b289344 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -295,14 +295,14 @@ typedef struct gpIterPopulateData {
   GPENCIL_PrivateData *pd;
   GPENCIL_MaterialPool *matpool;
   DRWShadingGroup *grp;
-  /* Offset in the material pool to the first material of this object. */
-  int mat_ofs;
   /* Last material UBO bound. Used to avoid uneeded buffer binding. */
   GPUUniformBuffer *ubo_mat;
   GPUUniformBuffer *ubo_lights;
   /* Last texture bound. */
   GPUTexture *tex_fill;
   GPUTexture *tex_stroke;
+  /* Offset in the material pool to the first material of this object. */
+  int mat_ofs;
   /* Is the sbuffer call need to be issued. */
   int do_sbuffer_call;
   /* Indices to do correct insertion of the sbuffer stroke. */
@@ -381,7 +381,8 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
                                     iter->pd->shadeless_light_pool->ubo;
 
   bool overide_vertcol = (iter->pd->v3d_color_type != -1);
-  bool is_vert_col_mode = (iter->pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR);
+  bool is_vert_col_mode = (iter->pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR) ||
+                          GPENCIL_VERTEX_MODE(gpd);
   float vert_col_opacity = (overide_vertcol) ? (is_vert_col_mode ? 1.0f : 0.0f) :
                                                gpl->vertex_paint_opacity;



More information about the Bf-blender-cvs mailing list