[Bf-blender-cvs] [84e9dbe38bc] blender2.8: GP: Improve SOFT eraser to affect strength and less to thickness

Antonioya noreply at git.blender.org
Wed Sep 12 16:55:35 CEST 2018


Commit: 84e9dbe38bc8923a93d0e6092318e6f9ebcaa3b1
Author: Antonioya
Date:   Wed Sep 12 16:55:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB84e9dbe38bc8923a93d0e6092318e6f9ebcaa3b1

GP: Improve SOFT eraser to affect strength and less to thickness

===================================================================

M	source/blender/editors/gpencil/gpencil_paint.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 14eeb167825..c57c45cdf34 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1453,12 +1453,32 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
 					    (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false))
 					{
 						/* Point is affected: */
-						/* 1) Adjust thickness
+						/* 1a) Adjust thickness
 						 *  - Influence of eraser falls off with distance from the middle of the eraser
 						 *  - Second point gets less influence, as it might get hit again in the next segment
 						 */
-						pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength;
-						pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength / 2.0f;
+						/* 1b) Adjust strength if the eraser is soft */
+						if (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_SOFT) {
+							pt1->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength;
+							CLAMP_MIN(pt1->strength, 0.0f);
+							pt2->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * 0.5f;
+							CLAMP_MIN(pt2->strength, 0.0f);
+
+							pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * 0.50f;
+							pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * 0.25f;
+
+							/* if invisible, delete point */
+							if ((pt1->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || (pt1->pressure < cull_thresh)) {
+								pt1->flag |= GP_SPOINT_TAG;
+							}
+							if ((pt2->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || (pt2->pressure < cull_thresh)) {
+								pt2->flag |= GP_SPOINT_TAG;
+							}
+						}
+						else {
+							pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength;
+							pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * 0.5f;
+						}
 
 						/* 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) ||



More information about the Bf-blender-cvs mailing list