From df29715498a2e601f1c57ff68b168e5984ef6491 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 4 Jan 2011 14:46:29 +0000 Subject: Fix #25483: Brush appearance color Set special brush flag when inversion stroke was started, not wery nice, but we can't make better with current events system implementation. --- source/blender/editors/sculpt_paint/paint_stroke.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 14 +++++++++++--- source/blender/makesdna/DNA_brush_types.h | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index ea99844bfac..ccbaa3f5b57 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -591,7 +591,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused) brush_set_size(brush, pixel_radius); // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke - flip = 1; + flip = brush->flag & BRUSH_INVERTED ? -1 : 1; sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 55c7247650a..15d940cc8a3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2904,6 +2904,11 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio cache->invert = mode == WM_BRUSHSTROKE_INVERT; cache->alt_smooth = mode == WM_BRUSHSTROKE_SMOOTH; + /* not very nice, but with current events system implementation + we can't handle brush appearance inversion hotkey separately (sergey) */ + if(cache->invert) brush->flag |= BRUSH_INVERTED; + else brush->flag &= ~BRUSH_INVERTED; + /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p= &sd->paint; @@ -3452,14 +3457,17 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) /* Finished */ if(ss->cache) { + Brush *brush= paint_brush(&sd->paint); + brush->flag &= ~BRUSH_INVERTED; + sculpt_stroke_modifiers_check(C, ss); /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p= &sd->paint; - Brush *br= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if(br) { - paint_brush_set(p, br); + brush= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); + if(brush) { + paint_brush_set(p, brush); } } diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 8fca829101b..37c6200b91f 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -130,6 +130,10 @@ typedef struct Brush { #define BRUSH_FRONTFACE (1<<27) #define BRUSH_CUSTOM_ICON (1<<28) +/* temporary flag which sets up autmatically for correct + brush drawing when inverted modal operator is running */ +#define BRUSH_INVERTED (1<<29) + /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 #define SCULPT_TOOL_SMOOTH 2 -- cgit v1.2.3