From ae200cb2e4d399f7561c4bee86eae70599d0396f Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Thu, 10 Sep 2020 16:37:31 +0200 Subject: GPencil: Fix unreported Eraser Point problem for one point selected The Eraser Point mode was erasing too much points. This eraser existed before the new Soft erasers were created and now it was working wrongly. The eraser point mode must remove the points below the eraser cursor at the first contact. For more soft erasers, the new Soft modes can be used. --- source/blender/editors/gpencil/gpencil_paint.c | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 6748211a1bc..fdab3649b13 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1525,6 +1525,9 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, pt1 = gps->points + i; pt2 = gps->points + i + 1; + float inf1 = 0.0f; + float inf2 = 0.0f; + /* only process if it hasn't been masked out... */ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { continue; @@ -1603,22 +1606,36 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, pt2->flag |= GP_SPOINT_TAG; do_cull = true; } + + inf1 = 1.0f; + inf2 = 1.0f; } else { - pt1->pressure -= gpencil_stroke_eraser_calc_influence(p, mval, radius, pc1) * - strength; - pt2->pressure -= gpencil_stroke_eraser_calc_influence(p, mval, radius, pc2) * - strength * 0.5f; + /* Erase point. Only erase if the eraser is on top of the point. */ + inf1 = gpencil_stroke_eraser_calc_influence(p, mval, radius, pc1); + if (inf1 > 0.0f) { + pt1->pressure = 0.0f; + pt1->flag |= GP_SPOINT_TAG; + do_cull = true; + } + inf2 = gpencil_stroke_eraser_calc_influence(p, mval, radius, pc2); + if (inf2 > 0.0f) { + pt2->pressure = 0.0f; + pt2->flag |= GP_SPOINT_TAG; + do_cull = true; + } } /* 2) Tag any point with overly low influence for removal in the next pass */ - if ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) { + if ((inf1 > 0.0f) && + (((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)))) { pt1->flag |= GP_SPOINT_TAG; do_cull = true; } - if ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) { + if ((inf1 > 2.0f) && + (((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)))) { pt2->flag |= GP_SPOINT_TAG; do_cull = true; } -- cgit v1.2.3