[Bf-blender-cvs] [9cac03cb212] greasepencil-edit-curve: GPencil: Add point index array RNA property
Falk David
noreply at git.blender.org
Sun Jun 7 17:50:45 CEST 2020
Commit: 9cac03cb2125954678e2b196e5b3197c790acd77
Author: Falk David
Date: Sat Jun 6 16:50:11 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rB9cac03cb2125954678e2b196e5b3197c790acd77
GPencil: Add point index array RNA property
This property should be used for debugging purposes.
===================================================================
M source/blender/editors/gpencil/gpencil_edit_curve.c
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c
index f19a4358a01..016e80c42bb 100644
--- a/source/blender/editors/gpencil/gpencil_edit_curve.c
+++ b/source/blender/editors/gpencil/gpencil_edit_curve.c
@@ -70,6 +70,8 @@ static bGPDcurve *create_example_gp_curve(int num_points)
}
bezt->radius = 1.0f;
bezt->weight = 2.0f;
+
+ new_gp_curve->point_index_array[i] = i;
}
return new_gp_curve;
}
@@ -115,7 +117,7 @@ void GPENCIL_OT_write_sample_stroke_curve_data(wmOperatorType *ot)
ot->name = "Write sample stroke curve data";
ot->idname = "GPENCIL_OT_write_stroke_curve_data";
ot->description =
- "Test operator to write sample curve data to the selected grease pencil strokes.";
+ "Test operator to write sample curve data to the selected grease pencil strokes";
/* api callbacks */
ot->exec = gp_write_stroke_curve_data_exec;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 8959d2913a4..19a749aeb36 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -992,6 +992,41 @@ static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
copy_v3_v3(bezt->vec[1], values);
}
+static int rna_point_index_array_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
+{
+ bGPDcurve *editcurve = (bGPDcurve *)ptr->data;
+ if (editcurve != NULL) {
+ length[0] = editcurve->tot_curve_points;
+ }
+ else {
+ length[0] = 0;
+ }
+
+ return length[0];
+}
+
+static void rna_point_index_get(PointerRNA *ptr, int *values)
+{
+ bGPDcurve *editcurve = (bGPDcurve *)ptr->data;
+ if (editcurve != NULL) {
+ int len = editcurve->tot_curve_points;
+ for (int i = 0; i < len; i++) {
+ values[i] = editcurve->point_index_array[i];
+ }
+ }
+}
+
+static void rna_point_index_set(PointerRNA *ptr, const int *values)
+{
+ bGPDcurve *editcurve = (bGPDcurve *)ptr->data;
+ if (editcurve != NULL) {
+ int len = editcurve->tot_curve_points;
+ for (int i = 0; i < len; i++) {
+ editcurve->point_index_array[i] = values[i];
+ }
+ }
+}
+
#else
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
@@ -1193,17 +1228,12 @@ static void rna_def_gpencil_curve(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GPencilEditCurvePoint");
RNA_def_property_ui_text(prop, "Curve Points", "Curve data points");
- // RNA_def_property_srna(prop, "GPencilStrokePoints");
- // srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL);
- // RNA_def_struct_sdna(srna, "bGPDstroke");
- // RNA_def_struct_ui_text(
- // srna, "Grease Pencil Stroke Points", "Collection of grease pencil stroke points");
-
- /* Curve. TODO: make BezTriple collection */
- // prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
- // RNA_def_property_pointer_sdna(prop, NULL, "curve");
- // RNA_def_property_struct_type(prop, "Curve");
- // RNA_def_property_ui_text(prop, "Curve", "Curve data");
+ prop = RNA_def_property(srna, "point_index_array", PROP_INT, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_DYNAMIC);
+ RNA_def_property_multi_array(prop, 1, NULL);
+ RNA_def_property_ui_text(prop, "Index array", "Point index array");
+ RNA_def_property_dynamic_array_funcs(prop, "rna_point_index_array_get_length");
+ RNA_def_property_int_funcs(prop, "rna_point_index_get", "rna_point_index_set", NULL);
}
static void rna_def_gpencil_mvert_group(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list