Commit: a50976c3c75a0c2f260b726fb4075d8a12b7cf5f Author: Antonio Vazquez Date: Wed May 27 13:33:35 2020 +0200 Branches: greasepencil-object https://developer.blender.org/rBa50976c3c75a0c2f260b726fb4075d8a12b7cf5f
GPencil: Show only first frame if current frame is >= Previously, the first frame was displayed since frame 0, but now, the first frame is only displayed when the current frame is equals or greater than the keyframe number. Differential Revision: https://developer.blender.org/D7851 =================================================================== M source/blender/blenkernel/intern/gpencil.c M source/blender/editors/gpencil/gpencil_paint.c M source/blender/editors/gpencil/gpencil_primitive.c =================================================================== diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 4311e425abf..775881eb443 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1016,6 +1016,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; } @@ -1861,6 +1867,7 @@ void BKE_gpencil_visible_stroke_iter( 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); @@ -1869,6 +1876,8 @@ void BKE_gpencil_visible_stroke_iter( 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; @@ -1895,6 +1904,16 @@ void BKE_gpencil_visible_stroke_iter( } } 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; @@ -1909,6 +1928,10 @@ void BKE_gpencil_visible_stroke_iter( 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; } @@ -1928,7 +1951,9 @@ void BKE_gpencil_visible_stroke_iter( 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; @@ -1948,10 +1973,15 @@ void BKE_gpencil_visible_stroke_iter( /* 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); } @@ -1966,8 +1996,8 @@ void BKE_gpencil_visible_stroke_iter( /* 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); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 4e83c4fb11c..adc4fc1e8a2 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2127,7 +2127,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps add_frame_mode = GP_GETFRAME_ADD_NEW; } + bool need_tag = p->gpl->actframe == NULL; p->gpf = BKE_gpencil_layer_frame_get(p->gpl, CFRA, add_frame_mode); + /* Only if there wasn't an active frame, need update. */ + if (need_tag) { + DEG_id_tag_update(&p->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } if (p->gpf == NULL) { p->status = GP_STATUS_ERROR; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 875a6265497..82ae99b30be 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1308,7 +1308,12 @@ static void gpencil_primitive_interaction_end(bContext *C, add_frame_mode = GP_GETFRAME_ADD_NEW; } + bool need_tag = tgpi->gpl->actframe == NULL; gpf = BKE_gpencil_layer_frame_get(tgpi->gpl, tgpi->cframe, add_frame_mode); + /* Only if there wasn't an active frame, need update. */ + if (need_tag) { + DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } /* prepare stroke to get transferred */ gps = tgpi->gpf->strokes.first; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs