From b2ae44dc41f7cf09bf20081734bf098d0f7cdb78 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 12 Jan 2012 21:48:08 +0000 Subject: Fix some RNA/scene issuess with unified paint settings. Added RNA for the unified paint setting flags that matches the Brush RNA. Fixed the getter/setter functions to avoid guessing which Scene's UnifiedPaintSetting to use. The getter functions take a Scene pointer now, the setter functions are removed in favor of a more explicit approach through RNA: Rather than RNA choosing whether a property's value is in the Brush or in the UnifiedPaintSettings, there are now explicit properties for both. The UI code has been modified accordingly to switch the toggle buttons between affecting the Brush and the UnifiedPaintSettings. --- source/blender/blenkernel/intern/brush.c | 90 ++++---------------------------- 1 file changed, 11 insertions(+), 79 deletions(-) (limited to 'source/blender/blenkernel/intern/brush.c') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index b1aeea99b1b..daa41442ed5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -642,6 +642,7 @@ typedef struct BrushPainterCache { } BrushPainterCache; struct BrushPainter { + Scene *scene; Brush *brush; float lastmousepos[2]; /* mouse position of last paint call */ @@ -665,11 +666,12 @@ struct BrushPainter { BrushPainterCache cache; }; -BrushPainter *brush_painter_new(Brush *brush) +BrushPainter *brush_painter_new(Scene *scene, Brush *brush) { BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter"); painter->brush= brush; + painter->scene= scene; painter->firsttouch= 1; painter->cache.lastsize= -1; /* force ibuf create in refresh */ @@ -917,9 +919,9 @@ void brush_painter_break_stroke(BrushPainter *painter) static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure) { - if (brush_use_alpha_pressure(brush)) + if (brush_use_alpha_pressure(painter->scene, brush)) brush_set_alpha(brush, MAX2(0.0f, painter->startalpha*pressure)); - if (brush_use_size_pressure(brush)) + if (brush_use_size_pressure(painter->scene, brush)) brush_set_size(brush, MAX2(1.0f, painter->startsize*pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) brush->jitter = MAX2(0.0f, painter->startjitter*pressure); @@ -1219,25 +1221,6 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) /* XXX, wouldnt it be better to only pass the active scene? * this can return any old scene! - campbell*/ -static void set_unified_settings(Brush *brush, short flag, int value) -{ - Scene *sce; - for (sce= G.main->scene.first; sce; sce= sce->id.next) { - if (sce->toolsettings && - ELEM4(brush, - paint_brush(&(sce->toolsettings->imapaint.paint)), - paint_brush(&(sce->toolsettings->vpaint->paint)), - paint_brush(&(sce->toolsettings->wpaint->paint)), - paint_brush(&(sce->toolsettings->sculpt->paint)))) - { - if (value) - sce->toolsettings->unified_paint_settings.flag |= flag; - else - sce->toolsettings->unified_paint_settings.flag &= ~flag; - } - } -} - static short unified_settings(Brush *brush) { Scene *sce; @@ -1389,78 +1372,27 @@ int brush_size(Brush *brush) return (us_flag & UNIFIED_PAINT_SIZE) ? unified_size(brush) : brush->size; } -void brush_set_use_locked_size(Brush *brush, int value) -{ - const short us_flag = unified_settings(brush); - - if (us_flag & UNIFIED_PAINT_SIZE) { - set_unified_settings(brush, UNIFIED_PAINT_BRUSH_LOCK_SIZE, value); - } - else { - if (value) - brush->flag |= BRUSH_LOCK_SIZE; - else - brush->flag &= ~BRUSH_LOCK_SIZE; - } - - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); -} - -int brush_use_locked_size(Brush *brush) +int brush_use_locked_size(const Scene *scene, Brush *brush) { - const short us_flag = unified_settings(brush); + const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) : (brush->flag & BRUSH_LOCK_SIZE); } -void brush_set_use_size_pressure(Brush *brush, int value) -{ - const short us_flag = unified_settings(brush); - - if (us_flag & UNIFIED_PAINT_SIZE) { - set_unified_settings(brush, UNIFIED_PAINT_BRUSH_SIZE_PRESSURE, value); - } - else { - if (value) - brush->flag |= BRUSH_SIZE_PRESSURE; - else - brush->flag &= ~BRUSH_SIZE_PRESSURE; - } - - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); -} - -int brush_use_size_pressure(Brush *brush) +int brush_use_size_pressure(const Scene *scene, Brush *brush) { - const short us_flag = unified_settings(brush); + const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) : (brush->flag & BRUSH_SIZE_PRESSURE); } -void brush_set_use_alpha_pressure(Brush *brush, int value) +int brush_use_alpha_pressure(const Scene *scene, Brush *brush) { - const short us_flag = unified_settings(brush); - - if (us_flag & UNIFIED_PAINT_ALPHA) { - set_unified_settings(brush, UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE, value); - } - else { - if (value) - brush->flag |= BRUSH_ALPHA_PRESSURE; - else - brush->flag &= ~BRUSH_ALPHA_PRESSURE; - } - - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); -} - -int brush_use_alpha_pressure(Brush *brush) -{ - const short us_flag = unified_settings(brush); + const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_ALPHA) ? (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) : -- cgit v1.2.3