Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-01-13 01:48:08 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-01-13 01:48:08 +0400
commitb2ae44dc41f7cf09bf20081734bf098d0f7cdb78 (patch)
treea201d5b2345374a4aa50a69dc3c4f4c98c522d2f /source/blender/blenkernel
parent1b8eab0fab7b6c4755e10366c43f7f1a7097f661 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_brush.h13
-rw-r--r--source/blender/blenkernel/intern/brush.c90
2 files changed, 15 insertions, 88 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 32418384795..b69eabbb371 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -76,7 +76,7 @@ struct BrushPainter;
typedef struct BrushPainter BrushPainter;
typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, float *lastpos, float *pos);
-BrushPainter *brush_painter_new(struct Brush *brush);
+BrushPainter *brush_painter_new(struct Scene *scene, struct Brush *brush);
void brush_painter_require_imbuf(BrushPainter *painter, short flt,
short texonly, int size);
int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos,
@@ -95,14 +95,9 @@ struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br);
int brush_size(struct Brush *brush);
void brush_set_size(struct Brush *brush, int value);
-int brush_use_locked_size(struct Brush *brush);
-void brush_set_use_locked_size(struct Brush *brush, int value);
-
-int brush_use_alpha_pressure(struct Brush *brush);
-void brush_set_use_alpha_pressure(struct Brush *brush, int value);
-
-int brush_use_size_pressure(struct Brush *brush);
-void brush_set_use_size_pressure(struct Brush *brush, int value);
+int brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
+int brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);
+int brush_use_size_pressure(const struct Scene *scene, struct Brush *brush);
float brush_unprojected_radius(struct Brush *brush);
void brush_set_unprojected_radius(struct Brush *brush, float value);
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) :