From 51010f50351a5115122dc64e02a5a9b2c76c4edb Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 23 Apr 2013 00:32:51 +0000 Subject: Allow hiding separate hiding of overlays on stroke. --- source/blender/blenkernel/BKE_paint.h | 14 +++++++++---- source/blender/blenkernel/intern/brush.c | 4 +++- source/blender/blenkernel/intern/paint.c | 23 +++++++++++----------- source/blender/editors/sculpt_paint/paint_cursor.c | 20 +++++++++++-------- source/blender/editors/sculpt_paint/paint_stroke.c | 5 ++--- source/blender/makesdna/DNA_brush_types.h | 8 +++++++- source/blender/makesrna/intern/rna_brush.c | 12 ++++++++++- 7 files changed, 57 insertions(+), 29 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index c6226180958..a8e61fc09b9 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -52,6 +52,8 @@ struct Tex; struct ImagePool; struct UnifiedPaintSettings; +enum OverlayFlags; + extern const char PAINT_CURSOR_SCULPT[3]; extern const char PAINT_CURSOR_VERTEX_PAINT[3]; extern const char PAINT_CURSOR_WEIGHT_PAINT[3]; @@ -72,17 +74,21 @@ typedef enum OverlayControlFlags { PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY = 1, PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY = (1 << 2), PAINT_INVALID_OVERLAY_CURVE = (1 << 3), - PAINT_OVERLAY_OVERRIDE = (1 << 4) + PAINT_OVERLAY_OVERRIDE_CURSOR = (1 << 4), + PAINT_OVERLAY_OVERRIDE_PRIMARY = (1 << 5), + PAINT_OVERLAY_OVERRIDE_SECONDARY = (1 << 6) } OverlayControlFlags; +#define PAINT_OVERRIDE_MASK (PAINT_OVERLAY_OVERRIDE_SECONDARY | \ + PAINT_OVERLAY_OVERRIDE_PRIMARY | \ + PAINT_OVERLAY_OVERRIDE_CURSOR) + void BKE_paint_invalidate_overlay_tex(struct Scene *scene, const struct Tex *tex); void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct CurveMapping *curve); void BKE_paint_invalidate_overlay_all(void); OverlayControlFlags BKE_paint_get_overlay_flags(void); void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag); -void BKE_paint_set_overlay_override(bool flag); -bool BKE_paint_get_overlay_override(void); - +void BKE_paint_set_overlay_override(enum OverlayFlags flag); void BKE_paint_init(struct Paint *p, const char col[3]); void BKE_paint_free(struct Paint *p); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e52d1d3b683..e3709143277 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -320,7 +320,9 @@ void BKE_brush_debug_print_state(Brush *br) BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_CURSOR); BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_PRIMARY); BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_SECONDARY); - BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_OVERRIDE_ON_STROKE); + BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE); + BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE); + BR_TEST_FLAG_OVERLAY(BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE); BR_TEST(jitter, f); BR_TEST(spacing, d); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index ef751d130db..3912a79e703 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -94,20 +94,21 @@ OverlayControlFlags BKE_paint_get_overlay_flags(void) return overlay_flags; } -void BKE_paint_set_overlay_override(bool flag) +void BKE_paint_set_overlay_override(OverlayFlags flags) { - if (flag) - overlay_flags |= PAINT_OVERLAY_OVERRIDE; - else - overlay_flags &= ~PAINT_OVERLAY_OVERRIDE; -} - -bool BKE_paint_get_overlay_override(void) -{ - return ((overlay_flags & PAINT_OVERLAY_OVERRIDE) != 0 ); + if (flags & BRUSH_OVERLAY_OVERRIDE_MASK) { + if (flags & BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE) + overlay_flags |= PAINT_OVERLAY_OVERRIDE_CURSOR; + if (flags & BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE) + overlay_flags |= PAINT_OVERLAY_OVERRIDE_PRIMARY; + if (flags & BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE) + overlay_flags |= PAINT_OVERLAY_OVERRIDE_SECONDARY; + } + else { + overlay_flags &= ~(PAINT_OVERRIDE_MASK); + } } - void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag) { overlay_flags &= ~(flag); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 2f49433d5bb..f6b706ba067 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -706,7 +706,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush, { /* color means that primary brush texture is colured and secondary is used for alpha/mask control */ bool col = ELEM3(mode, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D, PAINT_VERTEX) ? true: false; - + OverlayControlFlags flags = BKE_paint_get_overlay_flags(); /* save lots of GL state * TODO: check on whether all of these are needed? */ glPushAttrib(GL_COLOR_BUFFER_BIT | @@ -723,12 +723,17 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush, /* coloured overlay should be drawn separately */ if (col) { - paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true); - paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false); - paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); + if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) + paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true); + if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY)) + paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false); + if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) + paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); } else { - paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true); - paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); + if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) + paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true); + if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) + paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); } glPopAttrib(); @@ -805,8 +810,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) ups->brush_rotation = 0.0; /* draw overlay */ - if (!BKE_paint_get_overlay_override()) - paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode); + paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode); /* TODO: as sculpt and other paint modes are unified, this * special mode of drawing will go away */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d754567bd99..7133585f41d 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -434,15 +434,14 @@ PaintStroke *paint_stroke_new(bContext *C, stroke->done = done; stroke->event_type = event_type; /* for modal, return event */ - if (br->overlay_flags & BRUSH_OVERLAY_OVERRIDE_ON_STROKE) - BKE_paint_set_overlay_override(true); + BKE_paint_set_overlay_override(br->overlay_flags); return stroke; } void paint_stroke_data_free(struct wmOperator *op) { - BKE_paint_set_overlay_override(false); + BKE_paint_set_overlay_override(0); MEM_freeN(op->customdata); op->customdata = NULL; } diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index c37758fb940..824091dab32 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -158,9 +158,15 @@ typedef enum OverlayFlags { BRUSH_OVERLAY_CURSOR = (1), BRUSH_OVERLAY_PRIMARY = (1 << 1), BRUSH_OVERLAY_SECONDARY = (1 << 2), - BRUSH_OVERLAY_OVERRIDE_ON_STROKE = (1 << 3) + BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE = (1 << 3), + BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE = (1 << 4), + BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE = (1 << 5) } OverlayFlags; +#define BRUSH_OVERLAY_OVERRIDE_MASK (BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE | \ + BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE | \ + BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE) + /* Brush.sculpt_tool */ typedef enum BrushSculptTool { SCULPT_TOOL_DRAW = 1, diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 66a5ed947d7..409fc72126c 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1028,7 +1028,17 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Brush_update"); prop = RNA_def_property(srna, "cursor_overlay_override", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_OVERRIDE_ON_STROKE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE); + RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "primary_overlay_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE); + RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "secondary_overlay_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE); RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke"); RNA_def_property_update(prop, 0, "rna_Brush_update"); -- cgit v1.2.3