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
path: root/source
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-12-16 20:24:52 +0300
committerAntonioya <blendergit@gmail.com>2018-12-16 20:25:55 +0300
commitfbed69866ea574dcf3a304ca2ca5b223f997b13f (patch)
tree40ff48835dd84010c668365069dd9198791650f7 /source
parentc733062d27104e992718801d8c4e8ce5c4bead02 (diff)
GP: Add option to occlude eraser
This adds the functionality requested in T59417 adding a new button near of pressure button of the brush to enable/disable occlude effect for eraser.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c33
-rw-r--r--source/blender/makesdna/DNA_brush_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c6
3 files changed, 24 insertions, 17 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index c163ce40a6c..35e7ca1132f 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -116,7 +116,6 @@ typedef enum eGP_StrokeAdd_Result {
typedef enum eGPencil_PaintFlags {
GP_PAINTFLAG_FIRSTRUN = (1 << 0), /* operator just started */
GP_PAINTFLAG_STROKEADDED = (1 << 1),
- GP_PAINTFLAG_V3D_ERASER_DEPTH = (1 << 2),
GP_PAINTFLAG_SELECTMASK = (1 << 3),
GP_PAINTFLAG_HARD_ERASER = (1 << 4),
GP_PAINTFLAG_STROKE_ERASER = (1 << 5),
@@ -1200,9 +1199,19 @@ static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, const int x, const int y)
{
Object *obact = (Object *)p->ownerPtr.data;
+ Brush *brush = p->brush;
+ Brush *eraser = p->eraser;
+ BrushGpencilSettings *gp_settings = NULL;
+
+ if (brush->gpencil_tool == GPAINT_TOOL_ERASE) {
+ gp_settings = brush->gpencil_settings;
+ }
+ else if ((eraser != NULL) & (eraser->gpencil_tool == GPAINT_TOOL_ERASE)) {
+ gp_settings = eraser->gpencil_settings;
+ }
- if ((p->sa->spacetype == SPACE_VIEW3D) &&
- (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH))
+ if ((gp_settings != NULL) && (p->sa->spacetype == SPACE_VIEW3D) &&
+ (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER))
{
RegionView3D *rv3d = p->ar->regiondata;
bGPDlayer *gpl = p->gpl;
@@ -1550,13 +1559,16 @@ static void gp_stroke_doeraser(tGPsdata *p)
Brush *eraser = p->eraser;
bool use_pressure = false;
float press = 1.0f;
+ BrushGpencilSettings *gp_settings = NULL;
/* detect if use pressure in eraser */
if (brush->gpencil_tool == GPAINT_TOOL_ERASE) {
use_pressure = (bool)(brush->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE);
+ gp_settings = brush->gpencil_settings;
}
else if ((eraser != NULL) & (eraser->gpencil_tool == GPAINT_TOOL_ERASE)) {
use_pressure = (bool)(eraser->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE);
+ gp_settings = eraser->gpencil_settings;
}
if (use_pressure) {
press = p->pressure;
@@ -1570,7 +1582,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
rect.ymax = p->mval[1] + calc_radius;
if (p->sa->spacetype == SPACE_VIEW3D) {
- if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
+ if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0);
@@ -2063,23 +2075,10 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->paintmode = paintmode;
if (p->paintmode == GP_PAINTMODE_ERASER) {
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_ERASER;
-
- /* check if we should respect depth while erasing */
- if (p->sa->spacetype == SPACE_VIEW3D) {
- if (p->gpl->flag & GP_LAYER_NO_XRAY) {
- p->flags |= GP_PAINTFLAG_V3D_ERASER_DEPTH;
- }
- }
}
else {
/* disable eraser flags - so that we can switch modes during a session */
p->gpd->runtime.sbuffer_sflag &= ~GP_STROKE_ERASER;
-
- if (p->sa->spacetype == SPACE_VIEW3D) {
- if (p->gpl->flag & GP_LAYER_NO_XRAY) {
- p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH;
- }
- }
}
/* set special fill stroke mode */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index d51c94fb536..398c79e0111 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -123,6 +123,8 @@ typedef enum eGPDbrush_Flag {
GP_BRUSH_MATERIAL_PINNED = (1 << 13),
/* Do not show fill color while drawing (no lasso mode) */
GP_BRUSH_DISSABLE_LASSO = (1 << 14),
+ /* Do not erase strokes oLcluded */
+ GP_BRUSH_OCCLUDE_ERASER = (1 << 15),
} eGPDbrush_Flag;
/* BrushGpencilSettings->gp_fill_draw_mode */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 445ceb6ddb5..ccf6f73f284 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1227,6 +1227,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_DISSABLE_LASSO);
RNA_def_property_ui_text(prop, "Show Lasso", "Do not draw fill color while drawing the stroke");
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
+ prop = RNA_def_property(srna, "use_occlude_eraser", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_OCCLUDE_ERASER);
+ RNA_def_property_ui_text(prop, "Occlude Eraser",
+ "Erase only strokes visible and not occluded");
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
}
static void rna_def_brush(BlenderRNA *brna)