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:
authorHenrik Dick <hen-di@web.de>2022-03-25 13:51:45 +0300
committerHenrik Dick <hen-di@web.de>2022-03-25 13:51:45 +0300
commitd4e1458db3a0e0eaf80219dc8e6d10cb27620793 (patch)
tree0c1284faaa1f437c0eab156c8b76167bc0dd7b00 /source/blender/editors/gpencil/gpencil_interpolate.c
parent0c33e84020deca84c987dffa1302651f59c27158 (diff)
GPencil: Improve smooth operation
This patch makes the grease pencil smooth operation symmetric. It also increases the performance a lot if strong smoothing is required. Additionally there is an option for the position smooth operation to keep the shape closer to the original for more iterations. Since the result differs from the previous algorithm, versioning is used to change the iterations and factor to match the old result. Differential Revision: http://developer.blender.org/D14325
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_interpolate.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 65060e1bab5..8630b7f23d4 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -310,23 +310,6 @@ static void gpencil_stroke_pair_table(bContext *C,
}
}
-static void gpencil_interpolate_smooth_stroke(bGPDstroke *gps,
- float smooth_factor,
- int smooth_steps)
-{
- if (smooth_factor == 0.0f) {
- return;
- }
-
- float reduce = 0.0f;
- for (int r = 0; r < smooth_steps; r++) {
- for (int i = 0; i < gps->totpoints - 1; i++) {
- BKE_gpencil_stroke_smooth_point(gps, i, smooth_factor - reduce, false);
- BKE_gpencil_stroke_smooth_strength(gps, i, smooth_factor);
- }
- reduce += 0.25f; /* reduce the factor */
- }
-}
/* Perform interpolation */
static void gpencil_interpolate_update_points(const bGPDstroke *gps_from,
const bGPDstroke *gps_to,
@@ -553,7 +536,15 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
/* Update points position. */
gpencil_interpolate_update_points(gps_from, gps_to, new_stroke, tgpil->factor);
- gpencil_interpolate_smooth_stroke(new_stroke, tgpi->smooth_factor, tgpi->smooth_steps);
+ BKE_gpencil_stroke_smooth(new_stroke,
+ tgpi->smooth_factor,
+ tgpi->smooth_steps,
+ true,
+ true,
+ false,
+ false,
+ true,
+ NULL);
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
@@ -1385,7 +1376,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
/* Update points position. */
gpencil_interpolate_update_points(gps_from, gps_to, new_stroke, factor);
- gpencil_interpolate_smooth_stroke(new_stroke, smooth_factor, smooth_steps);
+ BKE_gpencil_stroke_smooth(
+ new_stroke, smooth_factor, smooth_steps, true, true, false, false, true, NULL);
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, new_stroke);