[Bf-blender-cvs] [d436ffd68f7] soc-2020-greasepencil-curve: GPencil: Fixed stroke duplicate kernel function
Falk David
noreply at git.blender.org
Wed Jun 3 17:22:56 CEST 2020
Commit: d436ffd68f74d6e11706d3f15fc02299744a76a6
Author: Falk David
Date: Wed Jun 3 16:17:47 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rBd436ffd68f74d6e11706d3f15fc02299744a76a6
GPencil: Fixed stroke duplicate kernel function
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 3190c2b9dde..6a33e52a687 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -111,6 +111,7 @@ struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]);
struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
+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);
struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 2ea84a152d6..05fa92b840f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -630,6 +630,21 @@ void BKE_gpencil_stroke_weights_duplicate(bGPDstroke *gps_src, bGPDstroke *gps_d
BKE_defvert_array_copy(gps_dst->dvert, gps_src->dvert, gps_src->totpoints);
}
+/* make a copy of a given gpencil stroke editcurve */
+bGPDcurve *BKE_gpencil_stroke_curve_duplicate(bGPDcurve *gpc_src)
+{
+ bGPDcurve *gpc_dst = NULL;
+
+ gpc_dst = MEM_dupallocN(gpc_src);
+ gpc_dst->point_index_array = MEM_dupallocN(gpc_src->point_index_array);
+
+ if (gpc_src->curve_points != NULL) {
+ gpc_dst->curve_points = MEM_dupallocN(gpc_src->curve_points);
+ }
+
+ return gpc_dst;
+}
+
/* make a copy of a given gpencil stroke */
bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points)
{
@@ -646,6 +661,9 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_poi
gps_dst->dvert = MEM_dupallocN(gps_src->dvert);
BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
}
+ if (gps_src->editcurve != NULL) {
+ gps_dst->editcurve = BKE_gpencil_stroke_curve_duplicate(gps_src->editcurve);
+ }
else {
gps_dst->dvert = NULL;
}
More information about the Bf-blender-cvs
mailing list