[Bf-blender-cvs] [1aeb21e56b2] greasepencil-refactor: GPencil: Refactor: Fix onion skining next frame drawing on top of active

Clément Foucault noreply at git.blender.org
Tue Dec 31 19:31:26 CET 2019


Commit: 1aeb21e56b2a0b083ec83721d770d0899ca76ef5
Author: Clément Foucault
Date:   Tue Dec 31 19:28:01 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB1aeb21e56b2a0b083ec83721d770d0899ca76ef5

GPencil: Refactor: Fix onion skining next frame drawing on top of active

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

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

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index d109e1b6cf2..85d8e828c46 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -153,19 +153,17 @@ void gpencil_object_visible_stroke_iter(Object *ob,
       }
     }
     else {
-      sta_gpf = &ob->runtime.gpencil_evaluated_frames[idx_eval];
-      if (sta_gpf) {
-        end_gpf = sta_gpf->next;
-        sta_gpf->runtime.onion_id = 0;
-      }
+      act_gpf = &ob->runtime.gpencil_evaluated_frames[idx_eval];
+      end_gpf = sta_gpf = NULL;
     }
 
-    if (sta_gpf == NULL) {
+    if (sta_gpf == NULL && act_gpf == NULL) {
       continue;
     }
 
+    /* Draw multiedit/onion skinning first */
     for (bGPDframe *gpf = sta_gpf; gpf && gpf != end_gpf; gpf = gpf->next) {
-      if (gpf->runtime.onion_id == INT_MAX) {
+      if (gpf->runtime.onion_id == INT_MAX || gpf == act_gpf) {
         continue;
       }
 
@@ -177,6 +175,16 @@ void gpencil_object_visible_stroke_iter(Object *ob,
         stroke_cb(gpl, gpf, gps, thunk);
       }
     }
+    /* Draw Active frame on top. */
+    if (act_gpf) {
+      if (layer_cb) {
+        layer_cb(gpl, act_gpf, NULL, thunk);
+      }
+
+      LISTBASE_FOREACH (bGPDstroke *, gps, &act_gpf->strokes) {
+        stroke_cb(gpl, act_gpf, gps, thunk);
+      }
+    }
 
     idx_eval++;
   }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 0eeaf5b9b35..900216751c8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -918,7 +918,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
     float onion_col[4] = {UNPACK3(onion_col_custom), 1.0f};
     float onion_alpha = use_onion_fade ? (1.0f / abs(gpf->runtime.onion_id)) : 0.5f;
     onion_alpha += (gpd->onion_factor * 2.0f - 1.0f);
-    onion_alpha = max_ff(onion_alpha, 0.01f);
+    onion_alpha = clamp_f(onion_alpha, 0.01f, 1.0f);
 
     DRW_shgroup_uniform_vec4_copy(iter->grp, "layerTint", onion_col);
     DRW_shgroup_uniform_float_copy(iter->grp, "layerOpacity", onion_alpha);



More information about the Bf-blender-cvs mailing list