diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2016-05-08 04:38:54 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-05-08 15:53:51 +0300 |
commit | 9dbe7bbe9a943ffd18fa670c4f68b4f90a6fc773 (patch) | |
tree | d2b62543842dbe02f796cedaa0e6d78f62126b81 | |
parent | dc78e47b770b33645f3cda1a4750422cd5105d6b (diff) |
D1886: GPencil - Add smooth iterations parameter to get better quality
After some test, a new iteration parameter has been added in order to
apply repetitive smoothing to the stroke. By default 1 iteration is applied,
but can used any number between 1 and 3.
The repetition uses different levels of intensity from 100% of the defined smooth
factor for the first loop, 50% for the second and 25% for the third. We use in each
loop a smaller value in order to avoid deform too much the stroke.
-rw-r--r-- | release/scripts/startup/bl_ui/properties_grease_pencil_common.py | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_blender_version.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 9 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 15 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 7 |
7 files changed, 37 insertions, 8 deletions
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 894160c2c16..698a9f53119 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -629,6 +629,8 @@ class GreasePencilDataPanel: col = layout.column(align=True) col.label(text="New Stroke Quality:") col.prop(gpl, "pen_smooth_factor") + col.prop(gpl, "pen_smooth_steps") + col.separator() col.prop(gpl, "pen_subdivision_steps") diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 5e7fdb91645..618b36c5851 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 277 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 /* Several breakages with 270, e.g. constraint deg vs rad */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 6 diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index c23429d86b7..f3eb5430bce 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -262,9 +262,12 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setactive) ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */ ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */ - /* HQ fill by default */ + /* high quality fill by default */ gpl->flag |= GP_LAYER_HQ_FILL; - + + /* default smooth iterations */ + gpl->draw_smoothlvl = 1; + /* auto-name */ BLI_strncpy(gpl->info, name, sizeof(gpl->info)); BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 54b2582c56c..f7d208a6a1b 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1040,6 +1040,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } + /* init grease pencil smooth level iterations */ + for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if (gpl->draw_smoothlvl == 0) { + gpl->draw_smoothlvl = 1; + } + } + } + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 06829cc92be..fba2f30e715 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -716,11 +716,18 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) } } - /* smooth stroke - only if there's something to do */ - /* NOTE: No pressure smoothing, or else we get annoying thickness changes while drawing... */ + /* smooth stroke after subdiv - only if there's something to do + * for each iteration, the factor is reduced to get a better smoothing without changing too much + * the original stroke + */ if (gpl->draw_smoothfac > 0.0f) { - for (i = 0; i < gps->totpoints; i++) { - gp_smooth_stroke(gps, i, gpl->draw_smoothfac, false); + float reduce = 0.0f; + for (int r = 0; r < gpl->draw_smoothlvl; ++r) { + for (i = 0; i < gps->totpoints; i++) { + /* NOTE: No pressure smoothing, or else we get annoying thickness changes while drawing... */ + gp_smooth_stroke(gps, i, gpl->draw_smoothfac - reduce, false); + } + reduce += 0.25f; // reduce the factor } } diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index ab0fcb81379..43d42012b2c 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -146,8 +146,9 @@ typedef struct bGPDlayer { * this is used for the name of the layer too and kept unique. */ float draw_smoothfac; /* amount of smoothing to apply to newly created strokes */ + short draw_smoothlvl; /* number of times to apply smooth factor to new strokes */ short sublevel; /* number of times to subdivide new strokes */ - short pad[5]; /* padding for compiler error */ + short pad[4]; /* padding for compiler error */ } bGPDlayer; /* bGPDlayer->flag */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 10d7efe9374..0aebca8f56b 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -810,6 +810,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Smooth", "Amount of smoothing to apply to newly created strokes, to reduce jitter/noise"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Iterations of the Smoothing factor */ + prop = RNA_def_property(srna, "pen_smooth_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "draw_smoothlvl"); + RNA_def_property_range(prop, 1, 3); + RNA_def_property_ui_text(prop, "Iterations", "Number of times to smooth newly created strokes [+ reason/effect of using higher values of this property]"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Subdivision level for new strokes */ prop = RNA_def_property(srna, "pen_subdivision_steps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "sublevel"); |