[Bf-blender-cvs] [45ec08dc991] master: GPencil: Add mode Merge to Simplify modifier

Antonio Vazquez noreply at git.blender.org
Thu Aug 8 17:19:42 CEST 2019


Commit: 45ec08dc991c29f60d1ec4a39df7c7364cde631c
Author: Antonio Vazquez
Date:   Thu Aug 8 17:16:06 2019 +0200
Branches: master
https://developer.blender.org/rB45ec08dc991c29f60d1ec4a39df7c7364cde631c

GPencil: Add mode Merge to Simplify modifier

This option uses the same logic of the merge by distance but as an option of modifier to allow dynamic merge.

This option will be very useful for LANPR generated strokes.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.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 5595408f1da..316ce818530 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1792,6 +1792,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
             col.prop(md, "factor")
         elif md.mode == 'SAMPLE':
             col.prop(md, "length")
+        elif md.mode == 'MERGE':
+            col.prop(md, "length", text="Threshold")
 
         col = layout.column()
         col.separator()
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
index 06f6f012818..a27fb27d518 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
@@ -45,6 +45,7 @@ static void initData(GpencilModifierData *md)
   gpmd->pass_index = 0;
   gpmd->step = 1;
   gpmd->factor = 0.0f;
+  gpmd->length = 0.1f;
   gpmd->layername[0] = '\0';
 }
 
@@ -57,7 +58,7 @@ static void deformStroke(GpencilModifierData *md,
                          Depsgraph *UNUSED(depsgraph),
                          Object *ob,
                          bGPDlayer *gpl,
-                         bGPDframe *UNUSED(gpf),
+                         bGPDframe *gpf,
                          bGPDstroke *gps)
 {
   SimplifyGpencilModifierData *mmd = (SimplifyGpencilModifierData *)md;
@@ -92,6 +93,10 @@ static void deformStroke(GpencilModifierData *md,
       BKE_gpencil_sample_stroke(gps, mmd->length, false);
       break;
     }
+    case GP_SIMPLIFY_MERGE: {
+      BKE_gpencil_merge_distance_stroke(gpf, gps, mmd->length, true);
+      break;
+    }
     default:
       break;
   }
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 3acd7d6de12..82628065014 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -519,6 +519,8 @@ typedef enum eSimplifyGpencil_Mode {
   GP_SIMPLIFY_ADAPTIVE = 1,
   /* Sample the stroke using a fixed length */
   GP_SIMPLIFY_SAMPLE = 2,
+  /* Sample the stroke doing vertex merge */
+  GP_SIMPLIFY_MERGE = 3,
 } eSimplifyGpencil_Mode;
 
 typedef struct OffsetGpencilModifierData {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index ed23e603bec..dfe9e018e94 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -622,6 +622,11 @@ static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna)
        ICON_IPO_EASE_IN_OUT,
        "Sample",
        "Sample a curve using a fixed length"},
+      {GP_SIMPLIFY_MERGE,
+       "MERGE",
+       ICON_IPO_EASE_IN_OUT,
+       "Merge",
+       "Sample a curve using doing merge of vertex"},
       {0, NULL, 0, NULL, NULL},
   };



More information about the Bf-blender-cvs mailing list