[Bf-blender-cvs] [4e6bd9ae169] temp-gpencil-fill: GPencil: Draw in all selected frames for draw
Antonio Vazquez
noreply at git.blender.org
Fri Jan 29 16:01:37 CET 2021
Commit: 4e6bd9ae169b5d668ae3ef2773422526702a2005
Author: Antonio Vazquez
Date: Fri Jan 29 16:00:46 2021 +0100
Branches: temp-gpencil-fill
https://developer.blender.org/rB4e6bd9ae169b5d668ae3ef2773422526702a2005
GPencil: Draw in all selected frames for draw
Now any selected frame in any layer is used.
===================================================================
M source/blender/blenkernel/BKE_gpencil_geom.h
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 7cb635a09e4..89a794f2df3 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -149,7 +149,8 @@ void BKE_gpencil_stroke_join(struct bGPDstroke *gps_a,
struct bGPDstroke *gps_b,
const bool leave_gaps,
const bool fit_thickness);
-void BKE_gpencil_stroke_copy_to_keyframes(struct bGPDlayer *gpl,
+void BKE_gpencil_stroke_copy_to_keyframes(struct bGPdata *gpd,
+ struct bGPDlayer *gpl,
struct bGPDframe *gpf,
struct bGPDstroke *gps,
const bool tail);
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 9aa0b595924..6b0169003d4 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -3228,25 +3228,42 @@ void BKE_gpencil_stroke_join(bGPDstroke *gps_a,
}
/* Copy the stroke of the frame to all frames selected (except current). */
-void BKE_gpencil_stroke_copy_to_keyframes(bGPDlayer *gpl,
- bGPDframe *gpf,
- bGPDstroke *gps,
- const bool tail)
+void BKE_gpencil_stroke_copy_to_keyframes(
+ bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const bool tail)
{
- LISTBASE_FOREACH (bGPDframe *, gpf_key, &gpl->frames) {
- if ((gpf_key != gpf) && (gpf_key->flag & GP_FRAME_SELECT)) {
+ GHash *frame_list = BLI_ghash_int_new_ex(__func__, 64);
+ BKE_gpencil_frame_selected_hash(gpd, frame_list);
+
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, frame_list) {
+ int cfra = POINTER_AS_INT(BLI_ghashIterator_getKey(&gh_iter));
+
+ if (gpf->framenum != cfra) {
+ bGPDframe *gpf_new = BKE_gpencil_layer_frame_find(gpl, cfra);
+ if (gpf_new == NULL) {
+ gpf_new = BKE_gpencil_frame_addnew(gpl, cfra);
+ }
+
+ if (gpf_new == NULL) {
+ continue;
+ }
+
bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, true, true);
if (gps_new == NULL) {
continue;
}
+
if (tail) {
- BLI_addhead(&gpf_key->strokes, gps_new);
+ BLI_addhead(&gpf_new->strokes, gps_new);
}
else {
- BLI_addtail(&gpf_key->strokes, gps_new);
+ BLI_addtail(&gpf_new->strokes, gps_new);
}
}
}
+
+ /* Free hash table. */
+ BLI_ghash_free(frame_list, NULL, NULL);
}
/* Stroke Uniform Subdivide ------------------------------------- */
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 5c0cf014f97..af1ff4bc5c1 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1778,7 +1778,6 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
BrushGpencilSettings *brush_settings = brush->gpencil_settings;
const bool is_brush_inv = brush_settings->fill_direction == BRUSH_DIR_IN;
const bool is_inverted = (is_brush_inv && !event->ctrl) || (!is_brush_inv && event->ctrl);
- const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(tgpf->gpd);
int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 14c87c0cde4..d6f85908c2b 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1309,7 +1309,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* In Multiframe mode, duplicate the stroke in other frames. */
if (GPENCIL_MULTIEDIT_SESSIONS_ON(p->gpd)) {
const bool tail = (ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK);
- BKE_gpencil_stroke_copy_to_keyframes(gpl, p->gpf, gps, tail);
+ BKE_gpencil_stroke_copy_to_keyframes(gpd, gpl, p->gpf, gps, tail);
}
gpencil_stroke_added_enable(p);
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 944bf708c04..abbe2fb26e5 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -1380,7 +1380,7 @@ static void gpencil_primitive_interaction_end(bContext *C,
/* In Multiframe mode, duplicate the stroke in other frames. */
if (GPENCIL_MULTIEDIT_SESSIONS_ON(tgpi->gpd)) {
const bool tail = (ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK);
- BKE_gpencil_stroke_copy_to_keyframes(tgpi->gpl, gpf, gps, tail);
+ BKE_gpencil_stroke_copy_to_keyframes(tgpi->gpd, tgpi->gpl, gpf, gps, tail);
}
DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_COPY_ON_WRITE);
More information about the Bf-blender-cvs
mailing list