[Bf-blender-cvs] [ca06bcdcbf8] greasepencil-edit-curve: GPencil: Basic structure for the Bezier Editing

Antonio Vazquez noreply at git.blender.org
Mon Jun 1 16:07:24 CEST 2020


Commit: ca06bcdcbf83e18ca37b63d8206d1ae717a1d10d
Author: Antonio Vazquez
Date:   Mon Jun 1 16:07:10 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rBca06bcdcbf83e18ca37b63d8206d1ae717a1d10d

GPencil: Basic structure for the Bezier Editing

This is the minimum data we need to create the Bezier Curve.

===================================================================

M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

===================================================================

diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index c3180ae79db..57f41ffd793 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -30,6 +30,7 @@
 
 struct AnimData;
 struct MDeformVert;
+struct Curve;
 
 #define GP_DEFAULT_PIX_FACTOR 1.0f
 #define GP_DEFAULT_GRID_LINES 4
@@ -166,6 +167,25 @@ typedef enum eGPDpalette_Flag {
   PL_PALETTE_ACTIVE = (1 << 0),
 } eGPDpalette_Flag;
 
+/* Curve for Bezier Editing. */
+typedef struct bGPDcurve {
+  /** Bezier curve. */
+  Curve *curve;
+  /** Array of indexes of nearest stroke points. */
+  int *point_index_array;
+  /* Total elements in the point index array. */
+  int tot_index_array;
+  /** General flag */
+  short flag;
+  char _pad[2];
+} bGPDcurve;
+
+/* bGPDcurve_Flag->flag */
+typedef enum bGPDcurve_Flag {
+  /* Curve requires recalc of the Bezier editing data. */
+  GP_CURVE_RECALC_GEOMETRY = (1 << 0),
+} bGPDcurve_Flag;
+
 /* ***************************************** */
 /* GP Strokes */
 
@@ -246,6 +266,9 @@ typedef struct bGPDstroke {
   /** Vertex Color for Fill (one for all stroke, A=mix factor). */
   float vert_color_fill[4];
 
+  /** Curve used to edit the stroke using Bezier handlers. */
+  struct bGPDcurve *editcurve;
+
   bGPDstroke_Runtime runtime;
 } bGPDstroke;
 
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index a52811a9a9a..e8d6e9d5dac 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1071,6 +1071,23 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 }
 
+/* Editing Curve data. */
+static void rna_def_gpencil_curve(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "GPencilEditCurve", NULL);
+  RNA_def_struct_sdna(srna, "bGPDcurve");
+  RNA_def_struct_ui_text(srna, "Edit Curve", "Edition Curve");
+
+  /* Curve. */
+  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");
+}
+
 static void rna_def_gpencil_mvert_group(BlenderRNA *brna)
 {
   StructRNA *srna;
@@ -1145,6 +1162,12 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
   RNA_def_property_struct_type(prop, "GPencilTriangle");
   RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill");
 
+  /* Edit Curve. */
+  prop = RNA_def_property(srna, "edit_curve", PROP_POINTER, PROP_NONE);
+  RNA_def_property_pointer_sdna(prop, NULL, "editcurve");
+  RNA_def_property_struct_type(prop, "GPencilEditCurve");
+  RNA_def_property_ui_text(prop, "Edit Curve", "Temporary data for Edit Curve");
+
   /* Material Index */
   prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_NONE);
   RNA_def_property_int_sdna(prop, NULL, "mat_nr");
@@ -2134,6 +2157,7 @@ void RNA_def_gpencil(BlenderRNA *brna)
   rna_def_gpencil_stroke(brna);
   rna_def_gpencil_stroke_point(brna);
   rna_def_gpencil_triangle(brna);
+  rna_def_gpencil_curve(brna);
 
   rna_def_gpencil_mvert_group(brna);
 }



More information about the Bf-blender-cvs mailing list