Option to hide overlay during a stroke. To enable, press the brush icon

next to the overlay alpha.
This commit is contained in:
Antony Riakiotakis
2013-04-16 15:02:41 +00:00
parent ea0ad013d3
commit 53c9507c28
9 changed files with 124 additions and 24 deletions

View File

@@ -734,11 +734,13 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
row = col.row()
if brush.use_texture_overlay:
row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
else:
row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
@@ -756,6 +758,15 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
brush_mask_texture_settings(col, brush)
if tex_slot_alpha.map_mode != 'STENCIL':
if brush.use_secondary_overlay:
row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
else:
row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):

View File

@@ -767,12 +767,13 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
row = col.row()
if tex_slot.map_mode != 'STENCIL':
if brush.use_texture_overlay:
row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
else:
row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
@@ -796,6 +797,21 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
brush_mask_texture_settings(col, brush)
col = layout.column(align=True)
col.active = brush.brush_capabilities.has_overlay
col.label(text="Overlay:")
row = col.row()
if tex_slot_alpha.map_mode != 'STENCIL':
if brush.use_secondary_overlay:
row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
else:
row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
sub.prop(brush, "cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):

View File

@@ -68,15 +68,21 @@ typedef enum PaintMode {
} PaintMode;
/* overlay invalidation */
#define PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY 1
#define PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY 2
#define PAINT_INVALID_OVERLAY_CURVE 4
typedef enum OverlayControlFlags {
PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY = 1,
PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY = (1 << 2),
PAINT_INVALID_OVERLAY_CURVE = (1 << 2),
PAINT_OVERLAY_OVERRIDE = (1 << 3)
} OverlayControlFlags;
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);
int BKE_paint_get_overlay_flags (void);
OverlayControlFlags BKE_paint_get_overlay_flags (void);
void BKE_paint_reset_overlay_invalid (void);
void BKE_paint_set_overlay_override (bool flag);
bool BKE_paint_get_overlay_override (void);
void BKE_paint_init(struct Paint *p, const char col[3]);
void BKE_paint_free(struct Paint *p);

View File

@@ -274,6 +274,11 @@ void BKE_brush_debug_print_state(Brush *br)
else if (!(br->flag & _f) && (def.flag & _f)) \
printf("br->flag &= ~" #_f ";\n")
#define BR_TEST_FLAG_OVERLAY(_f) \
if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) \
printf("br->overlay_flags |= " #_f ";\n"); \
else if (!(br->overlay_flags & _f) && (def.overlay_flags & _f)) \
printf("br->overlay_flags &= ~" #_f ";\n")
/* print out any non-default brush state */
BR_TEST(normal_weight, f);
@@ -301,7 +306,6 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST_FLAG(BRUSH_SPACE_ATTEN);
BR_TEST_FLAG(BRUSH_ADAPTIVE_SPACE);
BR_TEST_FLAG(BRUSH_LOCK_SIZE);
BR_TEST_FLAG(BRUSH_TEXTURE_OVERLAY);
BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE);
BR_TEST_FLAG(BRUSH_RESTORE_MESH);
BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE);
@@ -310,6 +314,11 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST_FLAG(BRUSH_FRONTFACE);
BR_TEST_FLAG(BRUSH_CUSTOM_ICON);
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(jitter, f);
BR_TEST(spacing, d);
BR_TEST(smooth_stroke_radius, d);

View File

@@ -57,7 +57,7 @@ const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
static int overlay_flags = 0;
static OverlayControlFlags overlay_flags = 0;
void BKE_paint_invalidate_overlay_tex (Scene *scene, const Tex *tex)
{
@@ -89,11 +89,25 @@ void BKE_paint_invalidate_overlay_all(void)
PAINT_INVALID_OVERLAY_CURVE);
}
int BKE_paint_get_overlay_flags(void)
OverlayControlFlags BKE_paint_get_overlay_flags(void)
{
return overlay_flags;
}
void BKE_paint_set_overlay_override(bool flag)
{
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 );
}
void BKE_paint_reset_overlay_invalid(void)
{
overlay_flags &= ~(PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY |

View File

@@ -109,7 +109,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
static int old_zoom = -1;
static bool old_col = -1;
int invalid = BKE_paint_get_overlay_flags();
OverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags();
GLubyte *buffer = NULL;
int size;
@@ -121,8 +121,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
refresh =
!overlay_texture ||
(invalid & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) ||
(invalid & PAINT_INVALID_OVERLAY_CURVE) ||
(overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) ||
(overlay_flags & PAINT_INVALID_OVERLAY_CURVE) ||
old_zoom != zoom ||
old_col != col ||
!same_tex_snap(&snap, br, vc);
@@ -406,7 +406,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
/* check for overlay mode */
if (!((brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL && brush->mtex.tex) ||
((brush->flag & BRUSH_TEXTURE_OVERLAY) &&
((brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) &&
ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED))))
{
return;
@@ -591,7 +591,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
ups->brush_rotation = 0.0;
/* draw overlay */
paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode);
if (!BKE_paint_get_overlay_override())
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 */

View File

@@ -411,7 +411,7 @@ PaintStroke *paint_stroke_new(bContext *C,
{
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
stroke->brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
Brush *br = stroke->brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
view3d_set_viewcontext(C, &stroke->vc);
if (stroke->vc.v3d)
view3d_get_transformation(stroke->vc.ar, stroke->vc.rv3d, stroke->vc.obact, &stroke->mats);
@@ -422,11 +422,15 @@ 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);
return stroke;
}
void paint_stroke_data_free(struct wmOperator *op)
{
BKE_paint_set_overlay_override(false);
MEM_freeN(op->customdata);
op->customdata = NULL;
}

View File

@@ -73,7 +73,7 @@ typedef struct Brush {
int flag; /* general purpose flag */
float jitter; /* jitter the position of the brush */
int jitter_absolute; /* absolute jitter in pixels */
int pad;
int overlay_flags;
int spacing; /* spacing of paint operations */
int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */
float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */
@@ -99,7 +99,10 @@ typedef struct Brush {
float height; /* affectable height of brush (layer height for layer tool, i.e.) */
float texture_sample_bias;
int texture_overlay_alpha;
int mask_overlay_alpha;
int cursor_overlay_alpha;
float unprojected_radius;
@@ -132,7 +135,7 @@ typedef enum BrushFlags {
BRUSH_SPACE_ATTEN = (1 << 18),
BRUSH_ADAPTIVE_SPACE = (1 << 19),
BRUSH_LOCK_SIZE = (1 << 20),
BRUSH_TEXTURE_OVERLAY = (1 << 21),
// BRUSH_TEXTURE_OVERLAY = (1 << 21), /* obsolete, use overlay_flags |= BRUSH_OVERLAY_PRIMARY instead */
BRUSH_EDGE_TO_EDGE = (1 << 22),
BRUSH_RESTORE_MESH = (1 << 23),
BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),
@@ -147,6 +150,14 @@ typedef enum BrushFlags {
BRUSH_ABSOLUTE_JITTER = (1 << 30)
} BrushFlags;
/* Brush.overlay_flags */
typedef enum OverlayFlags {
BRUSH_OVERLAY_CURSOR = (1),
BRUSH_OVERLAY_PRIMARY = (1 << 1),
BRUSH_OVERLAY_SECONDARY = (1 << 2),
BRUSH_OVERLAY_OVERRIDE_ON_STROKE = (1 << 3)
} OverlayFlags;
/* Brush.sculpt_tool */
typedef enum BrushSculptTool {
SCULPT_TOOL_DRAW = 1,

View File

@@ -983,11 +983,6 @@ static void rna_def_brush(BlenderRNA *brna)
"given in pixels");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_texture_overlay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TEXTURE_OVERLAY);
RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_edge_to_edge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_EDGE_TO_EDGE);
RNA_def_property_ui_text(prop, "Edge-to-edge", "Drag anchor brush from edge-to-edge");
@@ -1009,6 +1004,27 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve");
RNA_def_property_update(prop, 0, "rna_Brush_update");
/* overlay flags */
prop = RNA_def_property(srna, "use_primary_overlay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_PRIMARY);
RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_secondary_overlay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_SECONDARY);
RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_cursor_overlay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_CURSOR);
RNA_def_property_ui_text(prop, "Use Cursor Overlay", "Show cursor in viewport");
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_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke");
RNA_def_property_update(prop, 0, "rna_Brush_update");
/* paint mode flags */
prop = RNA_def_property(srna, "use_paint_sculpt", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT);
@@ -1057,6 +1073,18 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Overlay Alpha", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "mask_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
RNA_def_property_int_sdna(prop, NULL, "mask_overlay_alpha");
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Mask Texture Overlay Alpha", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "cursor_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
RNA_def_property_int_sdna(prop, NULL, "cursor_overlay_alpha");
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Mask Texture Overlay Alpha", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "add_col");
RNA_def_property_array(prop, 3);