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.
This commit is contained in:

committed by
Antonioya

parent
179e886ab3
commit
45ec08dc99
@@ -1792,6 +1792,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
|
|||||||
col.prop(md, "factor")
|
col.prop(md, "factor")
|
||||||
elif md.mode == 'SAMPLE':
|
elif md.mode == 'SAMPLE':
|
||||||
col.prop(md, "length")
|
col.prop(md, "length")
|
||||||
|
elif md.mode == 'MERGE':
|
||||||
|
col.prop(md, "length", text="Threshold")
|
||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.separator()
|
col.separator()
|
||||||
|
@@ -45,6 +45,7 @@ static void initData(GpencilModifierData *md)
|
|||||||
gpmd->pass_index = 0;
|
gpmd->pass_index = 0;
|
||||||
gpmd->step = 1;
|
gpmd->step = 1;
|
||||||
gpmd->factor = 0.0f;
|
gpmd->factor = 0.0f;
|
||||||
|
gpmd->length = 0.1f;
|
||||||
gpmd->layername[0] = '\0';
|
gpmd->layername[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ static void deformStroke(GpencilModifierData *md,
|
|||||||
Depsgraph *UNUSED(depsgraph),
|
Depsgraph *UNUSED(depsgraph),
|
||||||
Object *ob,
|
Object *ob,
|
||||||
bGPDlayer *gpl,
|
bGPDlayer *gpl,
|
||||||
bGPDframe *UNUSED(gpf),
|
bGPDframe *gpf,
|
||||||
bGPDstroke *gps)
|
bGPDstroke *gps)
|
||||||
{
|
{
|
||||||
SimplifyGpencilModifierData *mmd = (SimplifyGpencilModifierData *)md;
|
SimplifyGpencilModifierData *mmd = (SimplifyGpencilModifierData *)md;
|
||||||
@@ -92,6 +93,10 @@ static void deformStroke(GpencilModifierData *md,
|
|||||||
BKE_gpencil_sample_stroke(gps, mmd->length, false);
|
BKE_gpencil_sample_stroke(gps, mmd->length, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GP_SIMPLIFY_MERGE: {
|
||||||
|
BKE_gpencil_merge_distance_stroke(gpf, gps, mmd->length, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -519,6 +519,8 @@ typedef enum eSimplifyGpencil_Mode {
|
|||||||
GP_SIMPLIFY_ADAPTIVE = 1,
|
GP_SIMPLIFY_ADAPTIVE = 1,
|
||||||
/* Sample the stroke using a fixed length */
|
/* Sample the stroke using a fixed length */
|
||||||
GP_SIMPLIFY_SAMPLE = 2,
|
GP_SIMPLIFY_SAMPLE = 2,
|
||||||
|
/* Sample the stroke doing vertex merge */
|
||||||
|
GP_SIMPLIFY_MERGE = 3,
|
||||||
} eSimplifyGpencil_Mode;
|
} eSimplifyGpencil_Mode;
|
||||||
|
|
||||||
typedef struct OffsetGpencilModifierData {
|
typedef struct OffsetGpencilModifierData {
|
||||||
|
@@ -622,6 +622,11 @@ static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna)
|
|||||||
ICON_IPO_EASE_IN_OUT,
|
ICON_IPO_EASE_IN_OUT,
|
||||||
"Sample",
|
"Sample",
|
||||||
"Sample a curve using a fixed length"},
|
"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},
|
{0, NULL, 0, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user