[Bf-blender-cvs] [bae76da11bc] temp-gpencil-fill: GPencil: Use all selected frames in any layer for fill
Antonio Vazquez
noreply at git.blender.org
Fri Jan 29 16:01:37 CET 2021
Commit: bae76da11bc234fa5cc8cde19146f152cc862a0b
Author: Antonio Vazquez
Date: Fri Jan 29 15:38:05 2021 +0100
Branches: temp-gpencil-fill
https://developer.blender.org/rBbae76da11bc234fa5cc8cde19146f152cc862a0b
GPencil: Use all selected frames in any layer for fill
Instead to use only current layer, any selected frame in any layer is used.
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/editors/gpencil/gpencil_fill.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index b7fad9c891a..b915d9eba88 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -115,6 +115,8 @@ struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src,
const bool dup_frames,
const bool dup_strokes);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
+void BKE_gpencil_frame_selected_hash(const struct bGPdata *gpd, struct GHash *r_list);
+
struct bGPDcurve *BKE_gpencil_stroke_curve_duplicate(struct bGPDcurve *gpc_src);
struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src,
const bool dup_points,
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 0c813c170ad..037853f9c23 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2939,4 +2939,20 @@ 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(const struct bGPdata *gpd, struct GHash *r_list)
+{
+ const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ if ((gpf == gpl->actframe) || ((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);
+ }
+ }
+ }
+ }
+}
+
/** \} */
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 142cc59a1c2..5c0cf014f97 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_ghash.h"
#include "BLI_math.h"
#include "BLI_stack.h"
#include "BLI_utildefines.h"
@@ -1817,31 +1818,32 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_stroke_convertcoords_tpoint(
tgpf->scene, tgpf->region, tgpf->ob, &point2D, NULL, &pt->x);
+ /* Hash of selected frames.*/
+ GHash *frame_list = BLI_ghash_int_new_ex(__func__, 64);
+ BKE_gpencil_frame_selected_hash(tgpf->gpd, frame_list);
+
/* Set active frame as current for filling. */
int cfra_prv = CFRA;
- bGPDframe *init_gpf = (is_multiedit) ? tgpf->gpl->frames.first : tgpf->gpl->actframe;
- for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
- if ((gpf == tgpf->gpl->actframe) ||
- ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
-
- CFRA = gpf->framenum;
- tgpf->active_cfra = CFRA;
-
- /* Render screen to temp image and do fill. */
- gpencil_do_frame_fill(tgpf, is_inverted);
-
- /* restore size */
- tgpf->region->winx = (short)tgpf->bwinx;
- tgpf->region->winy = (short)tgpf->bwiny;
- tgpf->region->winrct = tgpf->brect;
-
- /* if not multiedit, exit loop*/
- if (!is_multiedit) {
- break;
- }
- }
+
+ /* Loop all frames. */
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, frame_list) {
+ int *cfra = BLI_ghashIterator_getKey(&gh_iter);
+ tgpf->active_cfra = POINTER_AS_INT(cfra);
+ CFRA = tgpf->active_cfra;
+
+ /* Render screen to temp image and do fill. */
+ gpencil_do_frame_fill(tgpf, is_inverted);
+
+ /* restore size */
+ tgpf->region->winx = (short)tgpf->bwinx;
+ tgpf->region->winy = (short)tgpf->bwiny;
+ tgpf->region->winrct = tgpf->brect;
}
+ /* Free hash table. */
+ BLI_ghash_free(frame_list, NULL, NULL);
+
/* Back to previous frame. */
CFRA = cfra_prv;
More information about the Bf-blender-cvs
mailing list