[Bf-blender-cvs] [af2d86dc2c0] soc-2020-greasepencil-curve: GPencil: Add num_points property to test operator
Falk David
noreply at git.blender.org
Wed Jun 3 22:28:11 CEST 2020
Commit: af2d86dc2c0e4b1d1fb87ee37a1f2767718ef589
Author: Falk David
Date: Wed Jun 3 22:27:23 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rBaf2d86dc2c0e4b1d1fb87ee37a1f2767718ef589
GPencil: Add num_points property to test operator
===================================================================
M source/blender/blenkernel/intern/gpencil.c
M source/blender/editors/gpencil/gpencil_edit_curve.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index ea16d93edb6..e263902e4bd 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -636,12 +636,10 @@ 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 */
+/* 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);
+ bGPDcurve *gpc_dst = MEM_dupallocN(gpc_src);
gpc_dst->point_index_array = MEM_dupallocN(gpc_src->point_index_array);
if (gpc_src->curve_points != NULL) {
@@ -651,7 +649,7 @@ bGPDcurve *BKE_gpencil_stroke_curve_duplicate(bGPDcurve *gpc_src)
return gpc_dst;
}
-/* make a copy of a given gpencil stroke */
+/* Make a copy of a given gpencil stroke */
bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points)
{
bGPDstroke *gps_dst = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c
index 11d5ddf9970..f19a4358a01 100644
--- a/source/blender/editors/gpencil/gpencil_edit_curve.c
+++ b/source/blender/editors/gpencil/gpencil_edit_curve.c
@@ -39,6 +39,9 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "RNA_access.h"
+#include "RNA_define.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -52,9 +55,8 @@
/** \name Test Operator for curve editing
* \{ */
-static bGPDcurve *create_example_gp_curve(void)
+static bGPDcurve *create_example_gp_curve(int num_points)
{
- int num_points = 2;
bGPDcurve *new_gp_curve = (bGPDcurve *)MEM_callocN(sizeof(bGPDcurve), __func__);
new_gp_curve->tot_curve_points = num_points;
new_gp_curve->curve_points = (BezTriple *)MEM_callocN(sizeof(BezTriple) * num_points, __func__);
@@ -77,6 +79,8 @@ static int gp_write_stroke_curve_data_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ob->data;
+ int num_points = RNA_int_get(op->ptr, "num_points");
+
if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
}
@@ -92,7 +96,7 @@ static int gp_write_stroke_curve_data_exec(bContext *C, wmOperator *op)
if (gps->editcurve != NULL) {
BKE_gpencil_free_stroke_editcurve(gps);
}
- gps->editcurve = create_example_gp_curve();
+ gps->editcurve = create_example_gp_curve(num_points);
}
}
@@ -121,7 +125,8 @@ void GPENCIL_OT_write_sample_stroke_curve_data(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- /* XXX: no props for now */
+ prop = RNA_def_int(
+ ot->srna, "num_points", 2, 0, 100, "Curve points", "Number of test curve points", 0, 100);
}
/** \} */
\ No newline at end of file
More information about the Bf-blender-cvs
mailing list