[Bf-blender-cvs] [166bacebc9f] greasepencil-refactor: GPencil: In multiframe show only lines for non active frame

Antonio Vazquez noreply at git.blender.org
Sat Feb 1 12:45:55 CET 2020


Commit: 166bacebc9fc2692c205adfcae2a41237f77fb38
Author: Antonio Vazquez
Date:   Sat Feb 1 12:44:20 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB166bacebc9fc2692c205adfcae2a41237f77fb38

GPencil: In multiframe show only lines for non active frame

When use multiframe, it's important to see in full color only the active frame, and the other frames just with a line if the option is enabled.

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

M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/overlay/overlay_gpencil.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index b0e812a8416..c4b7fe5391a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -123,10 +123,16 @@ void GPENCIL_engine_init(void *ved)
 
     stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1;
     copy_v3_v3(stl->pd->v3d_single_color, v3d->shading.single_color);
+
+    /* For non active frame, use only lines in multiedit mode. */
+    const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
+    stl->pd->use_multiedit_lines_only = overlays_on &&
+                                        (v3d->gp_flag & V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
   }
   else if (stl->pd->is_render) {
     use_scene_lights = true;
     use_scene_world = true;
+    stl->pd->use_multiedit_lines_only = false;
   }
 
   stl->pd->use_lighting = (v3d && v3d->shading.type > OB_SOLID) || stl->pd->is_render;
@@ -385,10 +391,7 @@ static void gp_drawcall_add(
   iter->vcount = v_first + v_count - iter->vfirst;
 }
 
-static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
-                                     bGPDframe *UNUSED(gpf),
-                                     bGPDstroke *gps,
-                                     void *thunk);
+static void gp_stroke_cache_populate(bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, void *thunk);
 
 static void gp_sbuffer_cache_populate(gpIterPopulateData *iter)
 {
@@ -510,10 +513,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   }
 }
 
-static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
-                                     bGPDframe *UNUSED(gpf),
-                                     bGPDstroke *gps,
-                                     void *thunk)
+static void gp_stroke_cache_populate(bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, void *thunk)
 {
   gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
 
@@ -524,7 +524,9 @@ static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
   bool show_fill = (gps->tot_triangles > 0) && ((gp_style->flag & GP_MATERIAL_FILL_SHOW) != 0) &&
                    (!iter->pd->simplify_fill);
 
-  if (hide_material || (!show_stroke && !show_fill)) {
+  bool only_lines = gpl && gpf && gpl->actframe != gpf && iter->pd->use_multiedit_lines_only;
+
+  if (hide_material || (!show_stroke && !show_fill) || only_lines) {
     return;
   }
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index cfee730cd18..3ebefe83ce6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -327,6 +327,8 @@ typedef struct GPENCIL_PrivateData {
   /* Some blend mode needs to add negative values.
    * This is only supported if target texture is signed. */
   bool use_signed_fb;
+  /* Use only lines for multiedit and not active frame. */
+  bool use_multiedit_lines_only;
   /* Layer opacity for fading. */
   float fade_layer_opacity;
   /* Opacity for fading gpencil objects. */
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 62923c6763c..6e61698412c 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -69,8 +69,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
                                      GP_SCULPT_MASK_SELECTMODE_SEGMENT)));
 
   /* For vertex paint show only if mask mode, and only points if not stroke mode. */
-  const bool use_vertex_mask = (GPENCIL_VERTEX_MODE(gpd) &&
-                                GPENCIL_ANY_VERTEX_MASK(ts->gpencil_selectmode_vertex));
+  bool use_vertex_mask = (GPENCIL_VERTEX_MODE(gpd) &&
+                          GPENCIL_ANY_VERTEX_MASK(ts->gpencil_selectmode_vertex));
   const bool show_vertex_points = (GPENCIL_VERTEX_MODE(gpd) &&
                                    (ts->gpencil_selectmode_vertex &
                                     (GP_VERTEX_MASK_SELECTMODE_POINT |
@@ -81,13 +81,17 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
                             (GPENCIL_VERTEX_MODE(gpd) && !use_vertex_mask));
 
   const bool do_multiedit = GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
-  const bool show_multi_edit_lines = do_multiedit &&
-                                     (v3d->gp_flag & V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
+  const bool show_multi_edit_lines = (v3d->gp_flag & V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
 
-  const bool show_lines = (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES);
+  const bool show_lines = (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES) || show_multi_edit_lines;
 
   const bool hide_lines = !GPENCIL_EDIT_MODE(gpd) && !GPENCIL_WEIGHT_MODE(gpd) &&
-                          !use_sculpt_mask && !use_vertex_mask && !show_multi_edit_lines;
+                          !use_sculpt_mask && !use_vertex_mask && !show_lines;
+
+  /* Special case when vertex paint and multiedit lines. */
+  if (do_multiedit && show_multi_edit_lines && GPENCIL_VERTEX_MODE(gpd)) {
+    use_vertex_mask = true;
+  }
 
   const bool is_weight_paint = (gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE);
 
@@ -101,8 +105,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
                            (GPENCIL_EDIT_MODE(gpd) &&
                             (ts->gpencil_selectmode_edit != GP_SELECTMODE_STROKE));
 
-  if ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask ||
-      show_multi_edit_lines) {
+  if ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask) {
     DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
                      DRW_STATE_BLEND_ALPHA;
     DRW_PASS_CREATE(psl->edit_gpencil_ps, state | pd->clipping_state);



More information about the Bf-blender-cvs mailing list