diff options
author | Antonioya <blendergit@gmail.com> | 2018-09-14 23:24:03 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-09-14 23:54:18 +0300 |
commit | 54f1375e298696b81aea86862ae634eaa8c97464 (patch) | |
tree | f8a72c0d85e2f3be6bb0751272347a8f22e0c0c1 | |
parent | 460731f39e438cf283080d9bd138c622eb255504 (diff) |
GP: Add pressure option to eraser size
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 1 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 26 |
2 files changed, 22 insertions, 5 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 2ebcc48810c..c714af1a7b5 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1421,6 +1421,7 @@ class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel): if gp_settings.gpencil_brush_type == 'ERASE': row = layout.row(align=True) row.prop(brush, "size", text="Radius") + row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE') if gp_settings.eraser_mode == 'SOFT': row = layout.row(align=True) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 8239afd1a48..e8b4d1088df 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1609,12 +1609,28 @@ static void gp_stroke_doeraser(tGPsdata *p) bGPDlayer *gpl; bGPDstroke *gps, *gpn; rcti rect; + Brush *brush = p->brush; + Brush *eraser = p->eraser; + bool use_pressure = false; + float press = 1.0f; + /* detect if use pressure in eraser */ + if (brush->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE) { + use_pressure = (bool)(brush->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE); + } + else if ((eraser != NULL) & (eraser->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE)) { + use_pressure = (bool)(eraser->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE); + } + if (use_pressure) { + press = p->pressure; + CLAMP(press, 0.01f, 1.0f); + } /* rect is rectangle of eraser */ - rect.xmin = p->mval[0] - p->radius; - rect.ymin = p->mval[1] - p->radius; - rect.xmax = p->mval[0] + p->radius; - rect.ymax = p->mval[1] + p->radius; + const int calc_radius = (int)p->radius * press; + rect.xmin = p->mval[0] - calc_radius; + rect.ymin = p->mval[1] - calc_radius; + rect.xmax = p->mval[0] + calc_radius; + rect.ymax = p->mval[1] + calc_radius; if (p->sa->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { @@ -1650,7 +1666,7 @@ static void gp_stroke_doeraser(tGPsdata *p) * (e.g. 2D space strokes in the 3D view, if the same datablock is shared) */ if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) { - gp_stroke_eraser_dostroke(p, gpl, gpf, gps, p->mval, p->mvalo, p->radius, &rect); + gp_stroke_eraser_dostroke(p, gpl, gpf, gps, p->mval, p->mvalo, calc_radius, &rect); } } } |