[Bf-blender-cvs] [148eb777fde] temp-gpencil-fill: GPencil: Draw Free Hand in multiframe
Antonio Vazquez
noreply at git.blender.org
Thu Jan 28 19:42:26 CET 2021
Commit: 148eb777fde8d74abc48efad5cb86c44203a1d67
Author: Antonio Vazquez
Date: Thu Jan 28 19:42:23 2021 +0100
Branches: temp-gpencil-fill
https://developer.blender.org/rB148eb777fde8d74abc48efad5cb86c44203a1d67
GPencil: Draw Free Hand in multiframe
When draw in this mode, the stroke is replicated in all frames.
===================================================================
M source/blender/blenkernel/BKE_gpencil_geom.h
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/editors/gpencil/gpencil_paint.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 1c86df73d3c..7cb635a09e4 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -149,6 +149,10 @@ 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,
+ struct bGPDframe *gpf,
+ struct bGPDstroke *gps,
+ const bool tail);
bool BKE_gpencil_convert_mesh(struct Main *bmain,
struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 981f5d50353..27614639f8f 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -3227,6 +3227,28 @@ 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)
+{
+ LISTBASE_FOREACH (bGPDframe *, gpf_key, &gpl->frames) {
+ if (gpf_key != gpf || (gpf_key->flag & GP_FRAME_SELECT)) {
+ bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, true, true);
+ if (gps_new == NULL) {
+ continue;
+ }
+ if (tail) {
+ BLI_addhead(&gpf_key->strokes, gps_new);
+ }
+ else {
+ BLI_addtail(&gpf_key->strokes, gps_new);
+ }
+ }
+ }
+}
+
/* Stroke Uniform Subdivide ------------------------------------- */
typedef struct tSamplePoint {
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 93d1ad63f8b..14c87c0cde4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1306,6 +1306,12 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, gps);
+ /* 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);
+ }
+
gpencil_stroke_added_enable(p);
}
More information about the Bf-blender-cvs
mailing list