diff options
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 1e24d61380c..284aa57f43a 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1011,6 +1011,12 @@ bGPDframe *BKE_gpencil_layer_frame_get(bGPDlayer *gpl, int cframe, eGP_GetFrame_ } } + /* Don't select first frame if greater than current frame. */ + if ((gpl->actframe != NULL) && (gpl->actframe == gpl->frames.first) && + (gpl->actframe->framenum > cframe)) { + gpl->actframe = NULL; + } + /* return */ return gpl->actframe; } @@ -1878,6 +1884,7 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, bGPdata *gpd = (bGPdata *)ob->data; const bool is_multiedit = GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); const bool is_onion = do_onion && ((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0); + const bool is_drawing = (gpd->runtime.sbuffer_used > 0); /* Onion skinning. */ const bool onion_mode_abs = (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE); @@ -1886,6 +1893,8 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, const short onion_keytype = gpd->onion_keytype; LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + /* Reset by layer. */ + bool is_before_first = false; bGPDframe *act_gpf = gpl->actframe; bGPDframe *sta_gpf = act_gpf; @@ -1924,6 +1933,16 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, } } else if (is_onion && (gpl->onion_flag & GP_LAYER_ONIONSKIN)) { + /* Special cases when cframe is before first frame. */ + bGPDframe *gpf_first = gpl->frames.first; + if ((gpf_first != NULL) && (act_gpf != NULL) && (gpf_first->framenum > act_gpf->framenum)) { + is_before_first = true; + } + if ((gpf_first != NULL) && (act_gpf == NULL)) { + act_gpf = gpf_first; + is_before_first = true; + } + if (act_gpf) { bGPDframe *last_gpf = gpl->frames.last; @@ -1938,6 +1957,10 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, int delta = (onion_mode_abs) ? (gpf->framenum - cfra) : (gpf->runtime.frameid - act_gpf->runtime.frameid); + if (is_before_first) { + delta++; + } + if (onion_mode_sel) { is_in_range = (gpf->flag & GP_FRAME_SELECT) != 0; } @@ -1957,7 +1980,9 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, gpf->runtime.onion_id = (is_wrong_keytype || !is_in_range) ? INT_MAX : delta; } /* Active frame is always shown. */ - act_gpf->runtime.onion_id = 0; + if (!is_before_first || is_drawing) { + act_gpf->runtime.onion_id = 0; + } } sta_gpf = gpl->frames.first; @@ -1977,10 +2002,15 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, /* Draw multiedit/onion skinning first */ for (bGPDframe *gpf = sta_gpf; gpf && gpf != end_gpf; gpf = gpf->next) { - if (gpf->runtime.onion_id == INT_MAX || gpf == act_gpf) { + if ((gpf->runtime.onion_id == INT_MAX || gpf == act_gpf) && (!is_before_first)) { continue; } + /* Only do once for frame before first. */ + if (is_before_first && gpf == act_gpf) { + is_before_first = false; + } + if (layer_cb) { layer_cb(gpl, gpf, NULL, thunk); } @@ -1995,8 +2025,8 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, /* Draw Active frame on top. */ /* Use evaluated frame (with modifiers for active stroke)/ */ act_gpf = gpl->actframe; - act_gpf->runtime.onion_id = 0; if (act_gpf) { + act_gpf->runtime.onion_id = 0; if (layer_cb) { layer_cb(gpl, act_gpf, NULL, thunk); } |