[Bf-blender-cvs] [0609ca4e80e] greasepencil-object: GPencil: Change Subdivision Simple mode to more clear UI

Antonio Vazquez noreply at git.blender.org
Sun Feb 23 13:11:47 CET 2020


Commit: 0609ca4e80e9027bf583b299df857fcda1b80121
Author: Antonio Vazquez
Date:   Sun Feb 23 12:41:13 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB0609ca4e80e9027bf583b299df857fcda1b80121

GPencil: Change Subdivision Simple mode to more clear UI

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 15dfbca70ad..ee20c0e0338 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1845,12 +1845,11 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
 
     def GP_SUBDIV(self, layout, ob, md):
         gpd = ob.data
+        layout.row().prop(md, "subdivision_type", expand=True)
         split = layout.split()
-
         col = split.column()
         row = col.row(align=True)
         row.prop(md, "level")
-        row.prop(md, "simple", text="", icon='PARTICLE_POINT')
 
         col = layout.column()
         col.separator()
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 8e9aafbd472..646ab481f92 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -248,7 +248,7 @@ void BKE_gpencil_frame_active_set(struct Depsgraph *depsgraph, struct bGPdata *g
 void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
 void BKE_gpencil_stroke_simplify_adaptive(struct bGPDstroke *gps, float factor);
 void BKE_gpencil_stroke_simplify_fixed(struct bGPDstroke *gps);
-void BKE_gpencil_stroke_subdivide(struct bGPDstroke *gps, int level, int flag);
+void BKE_gpencil_stroke_subdivide(struct bGPDstroke *gps, int level, int flag, int type);
 bool BKE_gpencil_stroke_trim(struct bGPDstroke *gps);
 void BKE_gpencil_stroke_merge_distance(struct bGPDframe *gpf,
                                        struct bGPDstroke *gps,
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 08200789876..5a257dd5304 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -622,7 +622,7 @@ GpencilModifierData *BKE_gpencil_modifiers_findByName(Object *ob, const char *na
   return BLI_findstring(&(ob->greasepencil_modifiers), name, offsetof(GpencilModifierData, name));
 }
 
-void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int flag)
+void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int flag, int type)
 {
   bGPDspoint *temp_points;
   MDeformVert *temp_dverts = NULL;
@@ -710,8 +710,8 @@ void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int flag)
     MEM_SAFE_FREE(temp_points);
     MEM_SAFE_FREE(temp_dverts);
 
-    /* move points to smooth stroke (not simple flag )*/
-    if ((flag & GP_SUBDIV_SIMPLE) == 0) {
+    /* move points to smooth stroke (not simple type )*/
+    if (type != GP_SUBDIV_SIMPLE) {
       /* duplicate points in a temp area with the new subdivide data */
       temp_points = MEM_dupallocN(gps->points);
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
index 71b2bd2e040..d7178981205 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
@@ -85,7 +85,7 @@ static void deformStroke(GpencilModifierData *md,
     return;
   }
 
-  BKE_gpencil_stroke_subdivide(gps, mmd->level, mmd->flag);
+  BKE_gpencil_stroke_subdivide(gps, mmd->level, mmd->flag, mmd->type);
 }
 
 static void bakeModifier(struct Main *UNUSED(bmain),
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 45e98c9f6e0..79a7510c072 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -127,16 +127,23 @@ typedef struct SubdivGpencilModifierData {
   int level;
   /** Custom index for passes. */
   int layer_pass;
+  /** Type of subdivision */
+  short type;
+  char _pad[6];
 } SubdivGpencilModifierData;
 
 typedef enum eSubdivGpencil_Flag {
-  GP_SUBDIV_SIMPLE = (1 << 0),
   GP_SUBDIV_INVERT_LAYER = (1 << 1),
   GP_SUBDIV_INVERT_PASS = (1 << 2),
   GP_SUBDIV_INVERT_LAYERPASS = (1 << 3),
   GP_SUBDIV_INVERT_MATERIAL = (1 << 4),
 } eSubdivGpencil_Flag;
 
+typedef enum eSubdivGpencil_Type {
+  GP_SUBDIV_CATMULL = 0,
+  GP_SUBDIV_SIMPLE = 1,
+} eSubdivGpencil_Type;
+
 typedef struct ThickGpencilModifierData {
   GpencilModifierData modifier;
   /** Layer name. */
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 5bd0f6ce989..7d881e5cd81 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -164,6 +164,11 @@ static const EnumPropertyItem rna_enum_time_mode_items[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
+static const EnumPropertyItem gpencil_subdivision_type_items[] = {
+    {GP_SUBDIV_CATMULL, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
+    {GP_SUBDIV_SIMPLE, "SIMPLE", 0, "Simple", ""},
+    {0, NULL, 0, NULL, NULL},
+};
 #endif
 
 #ifdef RNA_RUNTIME
@@ -619,9 +624,10 @@ static void rna_def_modifier_gpencilsubdiv(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Level", "Number of subdivisions");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
-  prop = RNA_def_property(srna, "simple", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SUBDIV_SIMPLE);
-  RNA_def_property_ui_text(prop, "Simple", "The modifier only add control points");
+  prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "type");
+  RNA_def_property_enum_items(prop, gpencil_subdivision_type_items);
+  RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);



More information about the Bf-blender-cvs mailing list