[Bf-blender-cvs] [f872c6a8fe5] greasepencil-edit-curve: GPencil: Add new edit_curve_resolution prop

Antonio Vazquez noreply at git.blender.org
Thu Jun 11 16:47:24 CEST 2020


Commit: f872c6a8fe5f184d7ec6d80c5de917b1ab1e8ae8
Author: Antonio Vazquez
Date:   Thu Jun 11 15:44:41 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rBf872c6a8fe5f184d7ec6d80c5de917b1ab1e8ae8

GPencil: Add new edit_curve_resolution prop

This will be used to define the qualitty of the generated stroke.

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

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

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

diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index c5628b43960..69a07513741 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -26,6 +26,7 @@
 #include "DNA_brush_types.h"
 #include "DNA_genfile.h"
 #include "DNA_gpencil_modifier_types.h"
+#include "DNA_gpencil_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
@@ -279,5 +280,12 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Init grease pencil default curve resolution. */
+    if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "editcurve_resolution")) {
+      for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+        gpd->editcurve_resolution = GP_DEFAULT_CURVE_RESOLUTION;
+      }
+    }
   }
 }
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index ea19108bbe9..799590c5bde 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -38,6 +38,8 @@ struct Curve;
 
 #define GP_MATERIAL_BUFFER_LEN 256
 
+#define GP_DEFAULT_CURVE_RESOLUTION 16
+
 /* ***************************************** */
 /* GP Stroke Points */
 
@@ -587,7 +589,8 @@ typedef struct bGPdata {
   ListBase layers;
   /** Settings for this data-block. */
   int flag;
-  char _pad1[4];
+  /** Default resolution for generated curves using curve editing method. */
+  int editcurve_resolution;
 
   /* Palettes */
   /** List of bGPDpalette's   - Deprecated (2.78 - 2.79 only). */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 1ea27a68d90..757a7519127 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -170,6 +170,19 @@ static void rna_GPencil_curve_edit_update(Main *bmain, Scene *scene, PointerRNA
   rna_GPencil_update(bmain, scene, ptr);
 }
 
+static void rna_GPencil_curve_resolution_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+  bGPdata *gpd = (bGPdata *)ptr->owner_id;
+
+  if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+    /* TODO GPXX */
+    /* Update any stroke selected with different resolution */
+  }
+
+  /* Standard update. */
+  rna_GPencil_update(bmain, scene, ptr);
+}
+
 static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
 {
   DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
@@ -2173,6 +2186,15 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
       "Scale conversion factor for pixel size (use larger values for thicker lines)");
   RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
+  prop = RNA_def_property(srna, "edit_curve_resolution", PROP_INT, PROP_NONE);
+  RNA_def_property_int_sdna(prop, NULL, "editcurve_resolution");
+  RNA_def_property_range(prop, 1, 64);
+  RNA_def_property_int_default(prop, GP_DEFAULT_CURVE_RESOLUTION);
+  RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+  RNA_def_property_ui_text(
+      prop, "Resolution", "Number of segments generated between control points");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_curve_resolution_update");
+
   prop = RNA_def_property(srna, "use_multiedit", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_MULTIEDIT);
   RNA_def_property_ui_text(prop,



More information about the Bf-blender-cvs mailing list