From 1352d81b174726639bbfb6f7aa32dbadf188a8dd Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Mon, 8 Feb 2021 16:28:42 +0100 Subject: GPencil: Fill tool refactor and Multiframe in Draw mode This commit is a refactor of the fill tool to solve several problems we had since the first version of the tool. Changes: * The filling speed has been improved for each step of the process with the optimization of each algorithm/function. * New `AutoFit` option to fill areas outside of the viewport. When enable, the total size of the frame is calculated to fit the filling area. * New support multiframe filling. Now it is possible to fill multiple similar frames in one go. * New `Stroke Extension` option to create temporary closing strokes. These strokes can be displayed and adjusted dynamically using wheel mouse or PageUp/Down keys. * Parameter `Resolution` now is named `Precision` and has been moved to topbar. * `Resolution` now has decimals and can be lower than 1 to allow quick filling in storyboarding workflows. Maximum value has been set as 5. * Parameter `Simplify` has been moved to Advanced panel. * Improved fill outline detection. In some cases, the outline penetrated the area to be filled with unexpected results. * Fixes some corner case bugs with infinite loops. As a result of this refactor, also these new functionalities has been added. * New support for multiframe in `Draw` mode. Any drawing in active frame is duplicated to all selected frame. * New multiframe display mode. Keyframes before or after of the active frame are displayed using onion colors. This can be disable using Onion overlay options. --- source/blender/blenkernel/intern/gpencil.c | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source/blender/blenkernel/intern/gpencil.c') diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 0c813c170ad..3d0152a6c7d 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -851,6 +851,7 @@ bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness) gps->mat_nr = mat_idx; + gps->dvert = NULL; gps->editcurve = NULL; return gps; @@ -2606,6 +2607,15 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { if (gpf == act_gpf || (gpf->flag & GP_FRAME_SELECT)) { gpf->runtime.onion_id = 0; + if (do_onion) { + if (gpf->framenum < act_gpf->framenum) { + gpf->runtime.onion_id = -1; + } + else { + gpf->runtime.onion_id = 1; + } + } + if (sta_gpf == NULL) { sta_gpf = gpf; } @@ -2939,4 +2949,26 @@ int BKE_gpencil_material_find_index_by_name_prefix(Object *ob, const char *name_ return -1; } +/* Create a hash with the list of selected frame number. */ +void BKE_gpencil_frame_selected_hash(bGPdata *gpd, struct GHash *r_list) +{ + const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); + bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); + + LISTBASE_FOREACH (bGPDlayer *, gpl_iter, &gpd->layers) { + if ((gpl != NULL) && (!is_multiedit) && (gpl != gpl_iter)) { + continue; + } + + LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_iter->frames) { + if (((gpf == gpl->actframe) && (!is_multiedit)) || + ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { + if (!BLI_ghash_lookup(r_list, POINTER_FROM_INT(gpf->framenum))) { + BLI_ghash_insert(r_list, POINTER_FROM_INT(gpf->framenum), gpf); + } + } + } + } +} + /** \} */ -- cgit v1.2.3