Allow hiding separate hiding of overlays on stroke.

This commit is contained in:
Antony Riakiotakis 2013-04-23 00:32:51 +00:00
parent 157244b13c
commit 51010f5035
8 changed files with 59 additions and 31 deletions

@ -814,7 +814,7 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
sub.prop(brush, "primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
@ -852,7 +852,7 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
sub = row.row()
sub.prop(brush, "mask_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
sub.prop(brush, "secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):

@ -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);

@ -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);

@ -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;
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);
}
}
bool BKE_paint_get_overlay_override(void)
{
return ((overlay_flags & PAINT_OVERLAY_OVERRIDE) != 0 );
}
void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag)
{
overlay_flags &= ~(flag);

@ -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 */

@ -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;
}

@ -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,

@ -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");