Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
index 746a689c08e..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;
@@ -66,7 +67,7 @@ static void deformStroke(GpencilModifierData *md,
mmd->layername,
mmd->pass_index,
mmd->layer_pass,
- 4,
+ mmd->mode == GP_SIMPLIFY_SAMPLE ? 3 : 4,
gpl,
gps,
mmd->flag & GP_SIMPLIFY_INVERT_LAYER,
@@ -75,14 +76,29 @@ static void deformStroke(GpencilModifierData *md,
return;
}
- if (mmd->mode == GP_SIMPLIFY_FIXED) {
- for (int i = 0; i < mmd->step; i++) {
- BKE_gpencil_simplify_fixed(gps);
+ /* Select simplification mode. */
+ switch (mmd->mode) {
+ case GP_SIMPLIFY_FIXED: {
+ for (int i = 0; i < mmd->step; i++) {
+ BKE_gpencil_simplify_fixed(gps);
+ }
+ break;
}
- }
- else {
- /* simplify stroke using Ramer-Douglas-Peucker algorithm */
- BKE_gpencil_simplify_stroke(gps, mmd->factor);
+ case GP_SIMPLIFY_ADAPTIVE: {
+ /* simplify stroke using Ramer-Douglas-Peucker algorithm */
+ BKE_gpencil_simplify_stroke(gps, mmd->factor);
+ break;
+ }
+ case GP_SIMPLIFY_SAMPLE: {
+ 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;
}
}