diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-08-08 18:16:06 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-08-08 18:16:17 +0300 |
commit | 45ec08dc991c29f60d1ec4a39df7c7364cde631c (patch) | |
tree | 30ad952c6b76eff8770d42aa97032511bd568935 | |
parent | 179e886ab3d6f8b762ff66c5bb2cb203a4adcb62 (diff) |
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.
4 files changed, 15 insertions, 1 deletions
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}, }; |