svn merge ^/trunk/blender -r43381:43392
authorCampbell Barton <ideasman42@gmail.com>
Sun, 15 Jan 2012 10:33:41 +0000 (10:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 15 Jan 2012 10:33:41 +0000 (10:33 +0000)
25 files changed:
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/editors/armature/armature_ops.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/metaball/mball_ops.c
source/blender/editors/object/object_ops.c
source/blender/editors/physics/physics_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_nla/nla_ops.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/makesdna/DNA_brush_types.h
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_scene.c
source/blender/windowmanager/intern/wm_operators.c

index c05bc3cb72670cf8285a644b61557aa66dd6ea00..8fd54c9d49ac70d0f57a1730b48661cd4596a83b 100644 (file)
@@ -645,8 +645,8 @@ class VIEW3D_MT_select_edit_armature(Menu):
 
         layout.separator()
 
-        layout.operator("armature.select_all", text="Select/Deselect All")
-        layout.operator("armature.select_inverse", text="Inverse")
+        layout.operator("armature.select_all", text="Select/Deselect All").action = 'TOGGLE'
+        layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
 
         layout.separator()
 
index 1867ef74e2b407b8649d8d3b739859472fd9abab..1e537c23ea3011519402243b38433a00038e4c6b 100644 (file)
@@ -476,16 +476,16 @@ class PaintPanel():
         parent.prop(ups, "use_unified_strength", text="Strength")
 
     @staticmethod
-    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text=""):
+    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
         ups = context.tool_settings.unified_paint_settings
         ptr = ups if ups.use_unified_size else brush
-        parent.prop(ptr, prop_name, icon=icon, text=text)
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
 
     @staticmethod
-    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text=""):
+    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
         ups = context.tool_settings.unified_paint_settings
         ptr = ups if ups.use_unified_strength else brush
-        parent.prop(ptr, prop_name, icon=icon, text=text)
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
 
 class VIEW3D_PT_tools_brush(PaintPanel, Panel):
     bl_label = "Brush"
@@ -545,10 +545,10 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
             if ((ups.use_unified_size and ups.use_locked_size) or
                 ((not ups.use_unified_size) and brush.use_locked_size)):
                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
-                row.prop(brush, "unprojected_radius", text="Radius", slider=True)
+                self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
             else:
                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
-                row.prop(brush, "size", slider=True)
+                self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
 
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
@@ -563,12 +563,12 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
                     else:
                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
 
-                row.prop(brush, "strength", text="Strength", slider=True)
+                self.prop_unified_strength(row, context, brush, "strength")
                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool == 'ROTATE':
                 row = col.row(align=True)
-                row.prop(brush, "strength", text="Strength", slider=True)
+                self.prop_unified_strength(row, context, brush, "strength")
                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool != 'SMOOTH':
@@ -656,11 +656,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
             col.prop(brush, "color", text="")
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
@@ -682,11 +682,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
             col = layout.column()
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
@@ -700,11 +700,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
             col.prop(brush, "color", text="")
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             # XXX - TODO
index 687da70974c3d1d21957db7fe05df16dcaff9e2b..13f72634bdac7e433f827cff1115899b9cb18592 100644 (file)
@@ -59,7 +59,8 @@ int brush_clone_image_set_nr(struct Brush *brush, int nr);
 int brush_clone_image_delete(struct Brush *brush);
 
 /* jitter */
-void brush_jitter_pos(struct Brush *brush, float *pos, float *jitterpos);
+void brush_jitter_pos(const struct Scene *scene, struct Brush *brush,
+                                         float *pos, float *jitterpos);
 
 /* brush curve */
 void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset);
@@ -67,8 +68,8 @@ float brush_curve_strength_clamp(struct Brush *br, float p, const float len);
 float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
 
 /* sampling */
-void brush_sample_tex(struct Brush *brush, const float xy[2], float rgba[4], const int thread);
-void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
+void brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread);
+void brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size,
        struct ImBuf **imbuf, int use_color_correction);
 
 /* painting */
@@ -92,18 +93,27 @@ struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br);
 
 /* unified strength and size */
 
-int  brush_size(struct Brush *brush);
-void brush_set_size(struct Brush *brush, int value);
+int  brush_size(const struct Scene *scene, struct Brush *brush);
+void brush_set_size(struct Scene *scene, struct Brush *brush, int value);
+
+float brush_unprojected_radius(const struct Scene *scene, struct Brush *brush);
+void  brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value);
+
+float brush_alpha(const struct Scene *scene, struct Brush *brush);
 
 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);
+/* scale unprojected radius to reflect a change in the brush's 2D size */
+void brush_scale_unprojected_radius(float *unprojected_radius,
+                                                                       int new_brush_size,
+                                                                       int old_brush_size);
 
-float brush_alpha(struct Brush *brush);
-void  brush_set_alpha(struct Brush *brush, float value);
+/* scale brush size to reflect a change in the brush's unprojected radius */
+void brush_scale_size(int *brush_size,
+                                         float new_unprojected_radius,
+                                         float old_unprojected_radius);
 
 /* debugging only */
 void brush_debug_print_state(struct Brush *br);
index b78b15c9a6a5f90a0a3f2d1a2d183ea86fc46c51..362fa6e5e9ac7cd8d27e803f7f19c5c1e597d761 100644 (file)
@@ -487,14 +487,14 @@ int brush_clone_image_delete(Brush *brush)
 }
 
 /* Brush Sampling */
-void brush_sample_tex(Brush *brush, const float xy[2], float rgba[4], const int thread)
+void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread)
 {
        MTex *mtex= &brush->mtex;
 
        if (mtex && mtex->tex) {
                float co[3], tin, tr, tg, tb, ta;
                int hasrgb;
-               const int radius= brush_size(brush);
+               const int radius= brush_size(scene, brush);
 
                co[0]= xy[0]/radius;
                co[1]= xy[1]/radius;
@@ -521,14 +521,14 @@ void brush_sample_tex(Brush *brush, const float xy[2], float rgba[4], const int
 }
 
 /* TODO, use define for 'texfall' arg */
-void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
+void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
 {
        ImBuf *ibuf;
        float xy[2], rgba[4], *dstf;
        int x, y, rowbytes, xoff, yoff, imbflag;
-       const int radius= brush_size(brush);
+       const int radius= brush_size(scene, brush);
        char *dst, crgb[3];
-       const float alpha= brush_alpha(brush);
+       const float alpha= brush_alpha(scene, brush);
        float brush_rgb[3];
     
        imbflag= (flt)? IB_rectfloat: IB_rect;
@@ -559,10 +559,10 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                        dstf[3]= alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius);
                                }
                                else if (texfall == 1) {
-                                       brush_sample_tex(brush, xy, dstf, 0);
+                                       brush_sample_tex(scene, brush, xy, dstf, 0);
                                }
                                else {
-                                       brush_sample_tex(brush, xy, rgba, 0);
+                                       brush_sample_tex(scene, brush, xy, rgba, 0);
                                        mul_v3_v3v3(dstf, rgba, brush_rgb);
                                        dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius);
                                }
@@ -589,14 +589,14 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                        dst[3] = FTOCHAR(alpha_f);
                                }
                                else if (texfall == 1) {
-                                       brush_sample_tex(brush, xy, rgba, 0);
+                                       brush_sample_tex(scene, brush, xy, rgba, 0);
                                        dst[0] = FTOCHAR(rgba[0]);
                                        dst[1] = FTOCHAR(rgba[1]);
                                        dst[2] = FTOCHAR(rgba[2]);
                                        dst[3] = FTOCHAR(rgba[3]);
                                }
                                else if (texfall == 2) {
-                                       brush_sample_tex(brush, xy, rgba, 0);
+                                       brush_sample_tex(scene, brush, xy, rgba, 0);
                                        mul_v3_v3(rgba, brush->rgb);
                                        alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius);
 
@@ -606,7 +606,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                        dst[3] = FTOCHAR(alpha_f);
                                }
                                else {
-                                       brush_sample_tex(brush, xy, rgba, 0);
+                                       brush_sample_tex(scene, brush, xy, rgba, 0);
                                        alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius);
 
                                        dst[0] = crgb[0];
@@ -621,6 +621,125 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
        *outbuf= ibuf;
 }
 
+/* Unified Size and Strength */
+
+// XXX: be careful about setting size and unprojected radius
+// because they depend on one another
+// these functions do not set the other corresponding value
+// this can lead to odd behavior if size and unprojected
+// radius become inconsistent.
+// the biggest problem is that it isn't possible to change
+// unprojected radius because a view context is not
+// available.  my ussual solution to this is to use the
+// ratio of change of the size to change the unprojected
+// radius.  Not completely convinced that is correct.
+// In anycase, a better solution is needed to prevent
+// inconsistency.
+
+void brush_set_size(Scene *scene, Brush *brush, int size)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       if (ups->flag & UNIFIED_PAINT_SIZE)
+               ups->size= size;
+       else
+               brush->size= size;
+}
+
+int brush_size(const Scene *scene, Brush *brush)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       return (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
+}
+
+int brush_use_locked_size(const Scene *scene, Brush *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);
+}
+
+int brush_use_size_pressure(const Scene *scene, Brush *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);
+}
+
+int brush_use_alpha_pressure(const Scene *scene, Brush *brush)
+{
+       const short us_flag = scene->toolsettings->unified_paint_settings.flag;
+
+       return (us_flag & UNIFIED_PAINT_ALPHA) ?
+               (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) :
+               (brush->flag & BRUSH_ALPHA_PRESSURE);
+}
+
+void brush_set_unprojected_radius(Scene *scene, Brush *brush, float unprojected_radius)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       if (ups->flag & UNIFIED_PAINT_SIZE)
+               ups->unprojected_radius= unprojected_radius;
+       else
+               brush->unprojected_radius= unprojected_radius;
+}
+
+float brush_unprojected_radius(const Scene *scene, Brush *brush)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       return (ups->flag & UNIFIED_PAINT_SIZE) ?
+               ups->unprojected_radius :
+               brush->unprojected_radius;
+}
+
+static void brush_set_alpha(Scene *scene, Brush *brush, float alpha)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       if (ups->flag & UNIFIED_PAINT_ALPHA)
+               ups->alpha= alpha;
+       else
+               brush->alpha= alpha;
+}
+
+float brush_alpha(const Scene *scene, Brush *brush)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha;
+}
+
+/* scale unprojected radius to reflect a change in the brush's 2D size */
+void brush_scale_unprojected_radius(float *unprojected_radius,
+                                                                       int new_brush_size,
+                                                                       int old_brush_size)
+{
+       float scale = new_brush_size;
+       /* avoid division by zero */
+       if(old_brush_size != 0)
+               scale /= (float)old_brush_size;
+       (*unprojected_radius) *= scale;
+}
+
+/* scale brush size to reflect a change in the brush's unprojected radius */
+void brush_scale_size(int *brush_size,
+                                         float new_unprojected_radius,
+                                         float old_unprojected_radius)
+{
+       float scale = new_unprojected_radius;
+       /* avoid division by zero */
+       if(old_unprojected_radius != 0)
+               scale /= new_unprojected_radius;
+       (*brush_size)= (int)((float)(*brush_size) * scale);
+}
+
 /* Brush Painting */
 
 typedef struct BrushPainterCache {
@@ -673,8 +792,8 @@ BrushPainter *brush_painter_new(Scene *scene, Brush *brush)
        painter->firsttouch= 1;
        painter->cache.lastsize= -1; /* force ibuf create in refresh */
 
-       painter->startsize = brush_size(brush);
-       painter->startalpha = brush_alpha(brush);
+       painter->startsize = brush_size(scene, brush);
+       painter->startalpha = brush_alpha(scene, brush);
        painter->startjitter = brush->jitter;
        painter->startspacing = brush->spacing;
 
@@ -707,8 +826,8 @@ void brush_painter_free(BrushPainter *painter)
 {
        Brush *brush = painter->brush;
 
-       brush_set_size(brush, painter->startsize);
-       brush_set_alpha(brush, painter->startalpha);
+       brush_set_size(painter->scene, brush, painter->startsize);
+       brush_set_alpha(painter->scene, brush, painter->startalpha);
        brush->jitter = painter->startjitter;
        brush->spacing = painter->startspacing;
 
@@ -720,12 +839,13 @@ void brush_painter_free(BrushPainter *painter)
 
 static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, int x, int y, int w, int h, int xt, int yt, float *pos)
 {
+       Scene *scene= painter->scene;
        Brush *brush= painter->brush;
        ImBuf *ibuf, *maskibuf, *texibuf;
        float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4];
        char *b, *m, *t, *ot= NULL;
        int dotexold, origx= x, origy= y;
-       const int radius= brush_size(brush);
+       const int radius= brush_size(painter->scene, brush);
 
        xoff = -radius + 0.5f;
        yoff = -radius + 0.5f;
@@ -763,7 +883,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
                                        xy[0] = x + xoff;
                                        xy[1] = y + yoff;
 
-                                       brush_sample_tex(brush, xy, tf, 0);
+                                       brush_sample_tex(scene, brush, xy, tf, 0);
                                }
 
                                bf[0] = tf[0]*mf[0];
@@ -794,7 +914,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
                                        xy[0] = x + xoff;
                                        xy[1] = y + yoff;
 
-                                       brush_sample_tex(brush, xy, rgba, 0);
+                                       brush_sample_tex(scene, brush, xy, rgba, 0);
                                        t[0]= FTOCHAR(rgba[0]);
                                        t[1]= FTOCHAR(rgba[1]);
                                        t[2]= FTOCHAR(rgba[2]);
@@ -812,11 +932,12 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
 
 static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float *pos)
 {
+       const Scene *scene= painter->scene;
        Brush *brush= painter->brush;
        BrushPainterCache *cache= &painter->cache;
        ImBuf *oldtexibuf, *ibuf;
        int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2;
-       const int diameter= 2*brush_size(brush);
+       const int diameter= 2*brush_size(scene, brush);
 
        imbflag= (cache->flt)? IB_rectfloat: IB_rect;
        if (!cache->ibuf)
@@ -866,13 +987,14 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float
 
 static void brush_painter_refresh_cache(BrushPainter *painter, float *pos, int use_color_correction)
 {
+       const Scene *scene= painter->scene;
        Brush *brush= painter->brush;
        BrushPainterCache *cache= &painter->cache;
        MTex *mtex= &brush->mtex;
        int size;
        short flt;
-       const int diameter= 2*brush_size(brush);
-       const float alpha= brush_alpha(brush);
+       const int diameter= 2*brush_size(scene, brush);
+       const float alpha= brush_alpha(scene, brush);
 
        if (diameter != cache->lastsize ||
                alpha != cache->lastalpha ||
@@ -891,11 +1013,11 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos, int u
                size= (cache->size)? cache->size: diameter;
 
                if (brush->flag & BRUSH_FIXED_TEX) {
-                       brush_imbuf_new(brush, flt, 3, size, &cache->maskibuf, use_color_correction);
+                       brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction);
                        brush_painter_fixed_tex_partial_update(painter, pos);
                }
                else
-                       brush_imbuf_new(brush, flt, 2, size, &cache->ibuf, use_color_correction);
+                       brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction);
 
                cache->lastsize= diameter;
                cache->lastalpha= alpha;
@@ -918,16 +1040,16 @@ void brush_painter_break_stroke(BrushPainter *painter)
 static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure)
 {
        if (brush_use_alpha_pressure(painter->scene, brush)) 
-               brush_set_alpha(brush, MAX2(0.0f, painter->startalpha*pressure));
+               brush_set_alpha(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure));
        if (brush_use_size_pressure(painter->scene, brush))
-               brush_set_size(brush, MAX2(1.0f, painter->startsize*pressure));
+               brush_set_size(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure));
        if (brush->flag & BRUSH_JITTER_PRESSURE)
                brush->jitter = MAX2(0.0f, painter->startjitter*pressure);
        if (brush->flag & BRUSH_SPACING_PRESSURE)
                brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure));
 }
 
-void brush_jitter_pos(Brush *brush, float pos[2], float jitterpos[2])
+void brush_jitter_pos(const Scene *scene, Brush *brush, float pos[2], float jitterpos[2])
 {
        int use_jitter= brush->jitter != 0;
 
@@ -937,7 +1059,7 @@ void brush_jitter_pos(Brush *brush, float pos[2], float jitterpos[2])
 
        if(use_jitter){
                float rand_pos[2];
-               const int radius= brush_size(brush);
+               const int radius= brush_size(scene, brush);
                const int diameter= 2*radius;
 
                // find random position within a circle of diameter 1
@@ -956,6 +1078,7 @@ void brush_jitter_pos(Brush *brush, float pos[2], float jitterpos[2])
 
 int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user, int use_color_correction)
 {
+       Scene *scene= painter->scene;
        Brush *brush= painter->brush;
        int totpaintops= 0;
 
@@ -1017,7 +1140,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
        else {
                float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2];
                float t, len, press;
-               const int radius= brush_size(brush);
+               const int radius= brush_size(scene, brush);
 
                /* compute brush spacing adapted to brush radius, spacing may depend
                   on pressure, so update it */
@@ -1042,7 +1165,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
                                brush_apply_pressure(painter, brush, press);
                                spacing= MAX2(1.0f, radius)*brush->spacing*0.01f;
 
-                               brush_jitter_pos(brush, paintpos, finalpos);
+                               brush_jitter_pos(scene, brush, paintpos, finalpos);
 
                                if (painter->cache.enabled)
                                        brush_painter_refresh_cache(painter, finalpos, use_color_correction);
@@ -1056,7 +1179,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
                                startdistance -= spacing;
                        }
                } else {
-                       brush_jitter_pos(brush, pos, finalpos);
+                       brush_jitter_pos(scene, brush, pos, finalpos);
 
                        if (painter->cache.enabled)
                                brush_painter_refresh_cache(painter, finalpos, use_color_correction);
@@ -1084,7 +1207,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
                        while (painter->accumtime >= (double)brush->rate) {
                                brush_apply_pressure(painter, brush, pressure);
 
-                               brush_jitter_pos(brush, pos, finalpos);
+                               brush_jitter_pos(scene, brush, pos, finalpos);
 
                                if (painter->cache.enabled)
                                        brush_painter_refresh_cache(painter, finalpos, use_color_correction);
@@ -1102,8 +1225,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
        painter->lastmousepos[1]= pos[1];
        painter->lastpressure= pressure;
 
-       brush_set_alpha(brush, painter->startalpha);
-       brush_set_size(brush, painter->startsize);
+       brush_set_alpha(scene, brush, painter->startalpha);
+       brush_set_size(scene, brush, painter->startsize);
        brush->jitter = painter->startjitter;
        brush->spacing = painter->startspacing;
 
@@ -1213,228 +1336,3 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
 
        return im;
 }
-
-/* Unified Size and Strength */
-
-/* XXX, wouldnt it be better to only pass the active scene?
- * this can return any old scene! - campbell*/
-
-static short unified_settings(Brush *brush)
-{
-       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))))
-               {
-                       return sce->toolsettings->unified_paint_settings.flag;
-               }
-       }
-
-       return 0;
-}
-
-// XXX: be careful about setting size and unprojected radius
-// because they depend on one another
-// these functions do not set the other corresponding value
-// this can lead to odd behavior if size and unprojected
-// radius become inconsistent.
-// the biggest problem is that it isn't possible to change
-// unprojected radius because a view context is not
-// available.  my ussual solution to this is to use the
-// ratio of change of the size to change the unprojected
-// radius.  Not completely convinced that is correct.
-// In anycase, a better solution is needed to prevent
-// inconsistency.
-
-static void set_unified_size(Brush *brush, 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))))
-               {
-                       sce->toolsettings->unified_paint_settings.size= value;
-               }
-       }
-}
-
-static int unified_size(Brush *brush)
-{
-       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))))
-               {
-                       return sce->toolsettings->unified_paint_settings.size;
-               }
-       }
-
-       return 35; // XXX magic number
-}
-
-static void set_unified_alpha(Brush *brush, float 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))))
-               {
-                       sce->toolsettings->unified_paint_settings.alpha= value;
-               }
-       }
-}
-
-static float unified_alpha(Brush *brush)
-{
-       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))))
-               {
-                       return sce->toolsettings->unified_paint_settings.alpha;
-               }
-       }
-
-       return 0.5f; // XXX magic number
-}
-
-static void set_unified_unprojected_radius(Brush *brush, float 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))))
-               {
-                       sce->toolsettings->unified_paint_settings.unprojected_radius= value;
-               }
-       }
-}
-
-static float unified_unprojected_radius(Brush *brush)
-{
-       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))))
-               {
-                       return sce->toolsettings->unified_paint_settings.unprojected_radius;
-               }
-       }
-
-       return 0.125f; // XXX magic number
-}
-void brush_set_size(Brush *brush, int size)
-{
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_SIZE)
-               set_unified_size(brush, size);
-       else
-               brush->size= size;
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-int brush_size(Brush *brush)
-{
-       const short us_flag = unified_settings(brush);
-
-       return (us_flag & UNIFIED_PAINT_SIZE) ? unified_size(brush) : brush->size;
-}
-
-int brush_use_locked_size(const Scene *scene, Brush *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);
-}
-
-int brush_use_size_pressure(const Scene *scene, Brush *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);
-}
-
-int brush_use_alpha_pressure(const Scene *scene, Brush *brush)
-{
-       const short us_flag = scene->toolsettings->unified_paint_settings.flag;
-
-       return (us_flag & UNIFIED_PAINT_ALPHA) ?
-               (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) :
-               (brush->flag & BRUSH_ALPHA_PRESSURE);
-}
-
-void brush_set_unprojected_radius(Brush *brush, float unprojected_radius)
-{
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_SIZE)
-               set_unified_unprojected_radius(brush, unprojected_radius);
-       else
-               brush->unprojected_radius= unprojected_radius;
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-float brush_unprojected_radius(Brush *brush)
-{
-       const short us_flag = unified_settings(brush);
-
-       return (us_flag & UNIFIED_PAINT_SIZE) ?
-               unified_unprojected_radius(brush) :
-               brush->unprojected_radius;
-}
-
-void brush_set_alpha(Brush *brush, float alpha)
-{
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_ALPHA)
-               set_unified_alpha(brush, alpha);
-       else
-               brush->alpha= alpha;
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-float brush_alpha(Brush *brush)
-{
-       const short us_flag = unified_settings(brush);
-
-       return (us_flag & UNIFIED_PAINT_ALPHA) ?
-               unified_alpha(brush) :
-               brush->alpha;
-}
index c4bd9382939673e5885073c2db3002d80efffb9e..81482466a30f934ebe00c28ae29d9592537b1bc2 100644 (file)
@@ -226,9 +226,10 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
        RNA_boolean_set(kmi->ptr, "snap", 1);
 
        /* only set in editmode armature, by space_view3d listener */
-       WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "unselected", FALSE);
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "unselected", 1);
+               RNA_boolean_set(kmi->ptr, "unselected", TRUE);
        WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
@@ -240,20 +241,24 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "ARMATURE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
        
-       WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "ARMATURE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
+       kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
        
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
        
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
 
        WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
        
@@ -320,22 +325,26 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
        kmi= WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
                RNA_boolean_set(kmi->ptr, "flipped", 1);
        
-       WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
 
        WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0);
 
        kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
        
        kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
 
        WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
index cef86c8d1d3c523ff3afc0d490fa071d1ae038ce..60fca7ae4bd640c8a8833a370e56c5abd76055cc 100644 (file)
@@ -158,7 +158,7 @@ void ED_operatormacros_curve(void)
 void ED_keymap_curve(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
-//     wmKeyMapItem *kmi;
+       wmKeyMapItem *kmi;
        
        keymap= WM_keymap_find(keyconf, "Font", 0, 0);
        keymap->poll= ED_operator_editfont;
@@ -222,8 +222,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", LEFTMOUSE, KM_CLICK, KM_CTRL, 0);
 
-       WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
 
        WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
index 872cfbec9a2a7412dc1f2c3741509a62d841e62f..ffceaf1c6989e5cf4529cccbdeeff9b840b96c7b 100644 (file)
@@ -266,8 +266,10 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
 
-       WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
 
        WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
index 4f90578c665ca718ff5cb11f30f98a11944507bf..4c69bb3e559b87dafdcba7f3c384f36563fdb24c 100644 (file)
@@ -54,6 +54,7 @@ void ED_operatortypes_metaball(void)
 void ED_keymap_metaball(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
+       wmKeyMapItem *kmi;
        
        keymap= WM_keymap_find(keyconf, "Metaball", 0, 0);
        keymap->poll= ED_operator_editmball;
@@ -68,7 +69,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0);
        
-       WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
 }
 
index a86e5f343c17d368e395a1ac4fdc0b38337a36f8..68d11837d0d8d7dc62667befe97b0082741bd9c3 100644 (file)
@@ -296,8 +296,10 @@ void ED_keymap_object(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
 
-       WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
 
        WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
@@ -305,15 +307,17 @@ void ED_keymap_object(wmKeyConfig *keyconf)
        
        kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
 
        kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
                RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
 
        WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
index ba0465b866faab68af3a22cdcfac3e945d76a4e1..09f99a58dd765d74d019511e0c3640265a19ba9d 100644 (file)
@@ -116,11 +116,11 @@ static void keymap_particle(wmKeyConfig *keyconf)
 
        /* size radial control */
        kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size");
+       RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.size");
 
        /* size radial control */
        kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength");
+       RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.strength");
 
        WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
        
index b7c4404c143e7b1398555057f069187ddc505f59..5f4777331c3bc47802e26a86f81cf219e99faf58 100644 (file)
@@ -2937,7 +2937,7 @@ static void project_paint_begin(ProjPaintState *ps)
        
        MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */
 
-       const int diameter= 2*brush_size(ps->brush);
+       const int diameter= 2*brush_size(ps->scene, ps->brush);
        
        /* ---- end defines ---- */
        
@@ -3580,7 +3580,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
 {
        if(ps->source==PROJ_SRC_VIEW) {
                float min_brush[2], max_brush[2];
-               const float radius = (float)brush_size(ps->brush);
+               const float radius = (float)brush_size(ps->scene, ps->brush);
 
                /* so we dont have a bucket bounds that is way too small to paint into */
                // if (radius < 1.0f) radius = 1.0f; // this doesn't work yet :/
@@ -3618,7 +3618,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
 
 static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
 {
-       const int diameter= 2*brush_size(ps->brush);
+       const int diameter= 2*brush_size(ps->scene, ps->brush);
 
        if (ps->thread_tot > 1)
                BLI_lock_thread(LOCK_CUSTOM1);
@@ -3844,7 +3844,7 @@ static void *do_projectpaint_thread(void *ph_v)
        float co[2];
        float mask = 1.0f; /* airbrush wont use mask */
        unsigned short mask_short;
-       const float radius= (float)brush_size(ps->brush);
+       const float radius= (float)brush_size(ps->scene, ps->brush);
        const float radius_squared= radius*radius; /* avoid a square root with every dist comparison */
        
        short lock_alpha= ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA;
@@ -3903,7 +3903,7 @@ static void *do_projectpaint_thread(void *ph_v)
                                        if (falloff > 0.0f) {
                                                if (ps->is_texbrush) {
                                                        /* note, for clone and smear, we only use the alpha, could be a special function */
-                                                       brush_sample_tex(ps->brush, projPixel->projCoSS, rgba, thread_index);
+                                                       brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index);
                                                        alpha = rgba[3];
                                                } else {
                                                        alpha = 1.0f;
@@ -3911,7 +3911,7 @@ static void *do_projectpaint_thread(void *ph_v)
                                                
                                                if (ps->is_airbrush) {
                                                        /* for an aurbrush there is no real mask, so just multiply the alpha by it */
-                                                       alpha *= falloff * brush_alpha(ps->brush);
+                                                       alpha *= falloff * brush_alpha(ps->scene, ps->brush);
                                                        mask = ((float)projPixel->mask)/65535.0f;
                                                }
                                                else {
@@ -3919,7 +3919,7 @@ static void *do_projectpaint_thread(void *ph_v)
                                                        falloff = 1.0f - falloff;
                                                        falloff = 1.0f - (falloff * falloff);
                                                        
-                                                       mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->brush) * falloff));
+                                                       mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->scene, ps->brush) * falloff));
                                                        if (mask_short > projPixel->mask_max) {
                                                                mask = ((float)mask_short)/65535.0f;
                                                                projPixel->mask_max = mask_short;
@@ -4801,7 +4801,7 @@ static int texture_paint_init(bContext *C, wmOperator *op)
        if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE))
                pop->s.tool = PAINT_TOOL_DRAW;
        pop->s.blend = brush->blend;
-       pop->orig_brush_size= brush_size(brush);
+       pop->orig_brush_size= brush_size(scene, brush);
 
        if(pop->mode != PAINT_MODE_2D) {
                pop->s.ob = OBACT;
@@ -4837,8 +4837,8 @@ static int texture_paint_init(bContext *C, wmOperator *op)
                        return 0;
 
                /* Dont allow brush size below 2 */
-               if (brush_size(brush) < 2)
-                       brush_set_size(brush, 2);
+               if (brush_size(scene, brush) < 2)
+                       brush_set_size(scene, brush, 2);
 
                /* allocate and initialize spacial data structures */
                project_paint_begin(&pop->ps);
@@ -4922,7 +4922,7 @@ static void paint_exit(bContext *C, wmOperator *op)
        brush_painter_free(pop->painter);
 
        if(pop->mode == PAINT_MODE_3D_PROJECT) {
-               brush_set_size(pop->ps.brush, pop->orig_brush_size);
+               brush_set_size(scene, pop->ps.brush, pop->orig_brush_size);
                paint_brush_exit_tex(pop->ps.brush);
                
                project_paint_end(&pop->ps);
@@ -5111,12 +5111,13 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
 #define PX_SIZE_FADE_MAX 12.0f
 #define PX_SIZE_FADE_MIN 4.0f
 
+       Scene *scene= CTX_data_scene(C);
        Brush *brush= image_paint_brush(C);
-       Paint *paint= paint_get_active(CTX_data_scene(C));
+       Paint *paint= paint_get_active(scene);
 
        if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
                float zoomx, zoomy;
-               const float size= (float)brush_size(brush);
+               const float size= (float)brush_size(scene, brush);
                const short use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy);
                const float pixel_size= MAX2(size * zoomx, size * zoomy);
                float alpha= 0.5f;
@@ -5570,8 +5571,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
        /* override */
        ps.is_texbrush= 0;
        ps.is_airbrush= 1;
-       orig_brush_size= brush_size(ps.brush);
-       brush_set_size(ps.brush, 32); /* cover the whole image */
+       orig_brush_size= brush_size(scene, ps.brush);
+       brush_set_size(scene, ps.brush, 32); /* cover the whole image */
 
        ps.tool= PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */
 
@@ -5584,7 +5585,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
        project_paint_begin(&ps);
 
        if(ps.dm==NULL) {
-               brush_set_size(ps.brush, orig_brush_size);
+               brush_set_size(scene, ps.brush, orig_brush_size);
                return OPERATOR_CANCELLED;
        }
        else {
@@ -5608,7 +5609,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
        project_paint_end(&ps);
 
        scene->toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
-       brush_set_size(ps.brush, orig_brush_size);
+       brush_set_size(scene, ps.brush, orig_brush_size);
 
        return OPERATOR_FINISHED;
 }
index eb20465a2ab4baecea979a2da4ce36f3c1cabbf7..e81e1f6dc779fc1c4099ae0c5fee88a16eeee9cc 100644 (file)
@@ -89,7 +89,8 @@ static void BRUSH_OT_add(wmOperatorType *ot)
 
 static int brush_scale_size_exec(bContext *C, wmOperator *op)
 {
-       Paint  *paint=  paint_get_active(CTX_data_scene(C));
+       Scene *scene = CTX_data_scene(C);
+       Paint  *paint=  paint_get_active(scene);
        struct Brush  *brush=  paint_brush(paint);
        // Object *ob=     CTX_data_active_object(C);
        float   scalar= RNA_float_get(op->ptr, "scalar");
@@ -97,7 +98,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
        if (brush) {
                // pixel radius
                {
-                       const int old_size= brush_size(brush);
+                       const int old_size= brush_size(scene, brush);
                        int size= (int)(scalar*old_size);
 
                        if (old_size == size) {
@@ -110,17 +111,17 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
                        }
                        CLAMP(size, 1, 2000); // XXX magic number
 
-                       brush_set_size(brush, size);
+                       brush_set_size(scene, brush, size);
                }
 
                // unprojected radius
                {
-                       float unprojected_radius= scalar*brush_unprojected_radius(brush);
+                       float unprojected_radius= scalar*brush_unprojected_radius(scene, brush);
 
                        if (unprojected_radius < 0.001f) // XXX magic number
                                unprojected_radius= 0.001f;
 
-                       brush_set_unprojected_radius(brush, unprojected_radius);
+                       brush_set_unprojected_radius(scene, brush, unprojected_radius);
                }
        }
 
@@ -475,7 +476,7 @@ typedef enum {
 } RCFlags;
 
 static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
-                             const char *output_name, const char *input_name)
+                                                         const char *output_name, const char *input_name)
 {
        char *path;
 
@@ -485,21 +486,35 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
 }
 
 static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
-                              const char *prop, RCFlags flags)
+                                                          const char *prop, const char *secondary_prop,
+                                                          RCFlags flags)
 {
+       const char *ups_path = "tool_settings.unified_paint_settings";
        char *brush_path;
 
        brush_path = BLI_sprintfN("tool_settings.%s.brush", paint);
 
-       set_brush_rc_path(ptr, brush_path, "data_path", prop);
+       set_brush_rc_path(ptr, brush_path, "data_path_primary", prop);
+       if(secondary_prop) {
+               set_brush_rc_path(ptr, ups_path, "use_secondary", secondary_prop);
+               set_brush_rc_path(ptr, ups_path, "data_path_secondary", prop);
+       }
+       else {
+               RNA_string_set(ptr, "use_secondary", "");
+               RNA_string_set(ptr, "data_path_secondary", "");
+       }
        set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
        set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
        RNA_string_set(ptr, "image_id", brush_path);
 
        if(flags & RC_COLOR)
                set_brush_rc_path(ptr, brush_path, "fill_color_path", "color");
+       else
+               RNA_string_set(ptr, "fill_color_path", "");
        if(flags & RC_ZOOM)
                RNA_string_set(ptr, "zoom_path", "space_data.zoom");
+       else
+               RNA_string_set(ptr, "zoom_path", "");
 
        MEM_freeN(brush_path);
 }
@@ -510,14 +525,14 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
        wmKeyMapItem *kmi;
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
-       set_brush_rc_props(kmi->ptr, paint, "size", flags);
+       set_brush_rc_props(kmi->ptr, paint, "size", "use_unified_size", flags);
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
-       set_brush_rc_props(kmi->ptr, paint, "strength", flags);
+       set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags);
 
        if(flags & RC_ROTATION) {
                kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
-               set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags);
+               set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags);
        }
 }
 
index ca5abc16ec872d52f01015c68970e627a419af36..c3e0c35f524aee2e08968828670ee37860628a54 100644 (file)
@@ -123,19 +123,19 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
 {
        MTex* mtex = &brush->mtex;
 
-       return  ( (mtex->tex) &&
-                 equals_v3v3(mtex->ofs, snap->ofs) &&
-                 equals_v3v3(mtex->size, snap->size) &&
-                 mtex->rot == snap->rot
-                 ) &&
-
-               /* make brush smaller shouldn't cause a resample */
-               ( (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && (brush_size(brush) <= snap->brush_size)) ||
-                 (brush_size(brush) == snap->brush_size)) &&
-
-               (mtex->brush_map_mode == snap->brush_map_mode) &&
-               (vc->ar->winx == snap->winx) &&
-               (vc->ar->winy == snap->winy);
+       return (((mtex->tex) &&
+                        equals_v3v3(mtex->ofs, snap->ofs) &&
+                        equals_v3v3(mtex->size, snap->size) &&
+                        mtex->rot == snap->rot) &&
+
+                       /* make brush smaller shouldn't cause a resample */
+                       ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+                         (brush_size(vc->scene, brush) <= snap->brush_size)) ||
+                        (brush_size(vc->scene, brush) == snap->brush_size)) &&
+
+                       (mtex->brush_map_mode == snap->brush_map_mode) &&
+                       (vc->ar->winx == snap->winx) &&
+                       (vc->ar->winy == snap->winy));
 }
 
 static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
@@ -153,7 +153,7 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
                snap->rot = -1;
        }
 
-       snap->brush_size = brush_size(brush);
+       snap->brush_size = brush_size(vc->scene, brush);
        snap->winx = vc->ar->winx;
        snap->winy = vc->ar->winy;
 }
@@ -198,7 +198,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
                make_snap(&snap, br, vc);
 
                if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
-                       int s = brush_size(br);
+                       int s = brush_size(vc->scene, br);
                        int r = 1;
 
                        for (s >>= 1; s > 0; s >>= 1)
@@ -239,7 +239,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
                                // largely duplicated from tex_strength
 
                                const float rotation = -br->mtex.rot;
-                               float radius = brush_size(br);
+                               float radius = brush_size(vc->scene, br);
                                int index = j*size + i;
                                float x;
                                float avg;
@@ -373,6 +373,7 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
                              float location[3])
 {
        struct PaintStroke *stroke;
+       const Scene *scene = CTX_data_scene(C);
        float window[2];
        int hit;
 
@@ -384,11 +385,11 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
        if(stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh &&
           sculpt_stroke_get_location(C, stroke, location, window)) {
                *pixel_radius = project_brush_radius(stroke->vc.rv3d,
-                                                    brush_unprojected_radius(stroke->brush),
+                                                    brush_unprojected_radius(scene, stroke->brush),
                                                     location, &stroke->mats);
 
                if (*pixel_radius == 0)
-                       *pixel_radius = brush_size(stroke->brush);
+                       *pixel_radius = brush_size(scene, stroke->brush);
 
                mul_m4_v3(stroke->vc.obact->obmat, location);
 
@@ -398,7 +399,7 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
                Sculpt* sd    = CTX_data_tool_settings(C)->sculpt;
                Brush*  brush = paint_brush(&sd->paint);
 
-               *pixel_radius = brush_size(brush);
+               *pixel_radius = brush_size(scene, brush);
                hit = 0;
        }
 
@@ -468,7 +469,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
                                quad.ymax = aim[1]+sd->anchored_size - win->ymin;
                        }
                        else {
-                               const int radius= brush_size(brush);
+                               const int radius= brush_size(vc->scene, brush);
                                quad.xmin = x - radius;
                                quad.ymin = y - radius;
                                quad.xmax = x + radius;
@@ -524,7 +525,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
                if(brush->flag & BRUSH_ANCHORED)
                        projected_radius = 8;
                else
-                       projected_radius = brush_size(brush);
+                       projected_radius = brush_size(vc->scene, brush);
        }
        unprojected_radius = paint_calc_object_space_radius(vc, location,
                                                            projected_radius);
@@ -533,7 +534,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
                unprojected_radius *= sd->pressure_value;
 
        if(!brush_use_locked_size(vc->scene, brush))
-               brush_set_unprojected_radius(brush, unprojected_radius);
+               brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
 }
 
 static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
@@ -551,7 +552,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
        translation[1] = y;
        outline_alpha = 0.5;
        outline_col = brush->add_col;
-       final_radius = brush_size(brush);
+       final_radius = brush_size(scene, brush);
 
        /* check that brush drawing is enabled */
        if(!(paint->flags & PAINT_SHOW_BRUSH))
@@ -567,7 +568,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
                Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
                float location[3];
                int pixel_radius, hit;
-               const float root_alpha = brush_alpha(brush);
+               const float root_alpha = brush_alpha(scene, brush);
                float visual_strength = root_alpha*root_alpha;
                const float min_alpha = 0.20f;
                const float max_alpha = 0.80f;
@@ -599,7 +600,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
                paint_draw_alpha_overlay(sd, brush, &vc, x, y);
 
                if(brush_use_locked_size(scene, brush))
-                       brush_set_size(brush, pixel_radius);
+                       brush_set_size(scene, brush, pixel_radius);
 
                /* check if brush is subtracting, use different color then */
                /* TODO: no way currently to know state of pen flip or
@@ -669,7 +670,8 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
 /* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
 static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2])
 {
-       Paint *paint = paint_get_active(CTX_data_scene(C));
+       Scene *scene = CTX_data_scene(C);
+       Paint *paint = paint_get_active(scene);
        Brush *brush = paint_brush(paint);
        PaintStroke *stroke = op->customdata;
        float mouse[3];
@@ -686,7 +688,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
        if(stroke->vc.obact->sculpt) {
                float delta[2];
 
-               brush_jitter_pos(brush, mouse_in, mouse);
+               brush_jitter_pos(scene, brush, mouse_in, mouse);
 
                /* XXX: meh, this is round about because
                   brush_jitter_pos isn't written in the best way to
@@ -775,7 +777,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
                                pressure = event_tablet_data(event, NULL);
                        
                        if(pressure > FLT_EPSILON) {
-                               scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+                               scale = (brush_size(scene, stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
                                if(scale > FLT_EPSILON) {
                                        mul_v2_fl(vec, scale);
 
index cdb82426473032a4d93ac364ecdc47e0f521bad1..ca16e8dfc7cdb9a7015e7c818460bf0f458f9617 100644 (file)
 
 #include "paint_intern.h"
 
-/* brush->vertexpaint_tool */
-#define VP_MIX 0
-#define VP_ADD 1
-#define VP_SUB 2
-#define VP_MUL 3
-#define VP_BLUR        4
-#define VP_LIGHTEN     5
-#define VP_DARKEN      6
-
 /* polling - retrieve whether cursor should be set or operator should be done */
 
 
@@ -735,34 +726,51 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
        return col;
 }
 
-static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha)
+/* wpaint has 'wpaint_blend_tool' */
+static unsigned int vpaint_blend_tool(const int tool, const unsigned int col,
+                                      const unsigned int paintcol, const int alpha_i)
+{
+       switch (tool) {
+               case PAINT_BLEND_MIX:
+               case PAINT_BLEND_BLUR:
+                       return mcol_blend(col, paintcol, alpha_i);
+               case PAINT_BLEND_ADD:
+                       return mcol_add(col, paintcol, alpha_i);
+               case PAINT_BLEND_SUB:
+                       return mcol_sub(col, paintcol, alpha_i);
+               case PAINT_BLEND_MUL:
+                       return mcol_mul(col, paintcol, alpha_i);
+               case PAINT_BLEND_LIGHTEN:
+                       return mcol_lighten(col, paintcol, alpha_i);
+               case PAINT_BLEND_DARKEN:
+                       return mcol_darken(col, paintcol, alpha_i);
+               default:
+                       BLI_assert(0);
+                       return 0;
+       }
+}
+
+/* wpaint has 'wpaint_blend' */
+static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colorig, const
+                                 unsigned int paintcol, const int alpha_i,
+                                 /* pre scaled from [0-1] --> [0-255] */
+                                 const int brush_alpha_value_i)
 {
        Brush *brush = paint_brush(&vp->paint);
+       const int tool = brush->vertexpaint_tool;
+
+       col = vpaint_blend_tool(tool, col, paintcol, alpha_i);
 
-       if(brush->vertexpaint_tool==VP_MIX || brush->vertexpaint_tool==VP_BLUR) *col= mcol_blend( *col, paintcol, alpha);
-       else if(brush->vertexpaint_tool==VP_ADD) *col= mcol_add( *col, paintcol, alpha);
-       else if(brush->vertexpaint_tool==VP_SUB) *col= mcol_sub( *col, paintcol, alpha);
-       else if(brush->vertexpaint_tool==VP_MUL) *col= mcol_mul( *col, paintcol, alpha);
-       else if(brush->vertexpaint_tool==VP_LIGHTEN) *col= mcol_lighten( *col, paintcol, alpha);
-       else if(brush->vertexpaint_tool==VP_DARKEN) *col= mcol_darken( *col, paintcol, alpha);
-       
        /* if no spray, clip color adding with colorig & orig alpha */
        if((vp->flag & VP_SPRAY)==0) {
-               unsigned int testcol=0, a;
+               unsigned int testcol, a;
                char *cp, *ct, *co;
                
-               alpha= (int)(255.0f*brush_alpha(brush));
+               testcol = vpaint_blend_tool(tool, colorig, paintcol, brush_alpha_value_i);
                
-               if(brush->vertexpaint_tool==VP_MIX || brush->vertexpaint_tool==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha);
-               else if(brush->vertexpaint_tool==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha);
-               else if(brush->vertexpaint_tool==VP_SUB) testcol= mcol_sub( *colorig, paintcol, alpha);
-               else if(brush->vertexpaint_tool==VP_MUL) testcol= mcol_mul( *colorig, paintcol, alpha);
-               else if(brush->vertexpaint_tool==VP_LIGHTEN)  testcol= mcol_lighten( *colorig, paintcol, alpha);
-               else if(brush->vertexpaint_tool==VP_DARKEN)   testcol= mcol_darken( *colorig, paintcol, alpha);
-               
-               cp= (char *)col;
+               cp= (char *)&col;
                ct= (char *)&testcol;
-               co= (char *)colorig;
+               co= (char *)&colorig;
                
                for(a=0; a<4; a++) {
                        if( ct[a]<co[a] ) {
@@ -775,6 +783,8 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u
                        }
                }
        }
+
+       return col;
 }
 
 
@@ -817,7 +827,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
 
 /* whats _dl mean? */
 static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float *vert_nor,
-                              const float mval[2], const float brush_size_final)
+                              const float mval[2], const float brush_size_pressure)
 {
        Brush *brush = paint_brush(&vp->paint);
        float dist_squared;
@@ -826,24 +836,24 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float *vert_
        project_float_noclip(vc->ar, vert_nor, vertco);
        sub_v2_v2v2(delta, mval, vertco);
        dist_squared= dot_v2v2(delta, delta); /* len squared */
-       if (dist_squared > brush_size_final * brush_size_final) {
+       if (dist_squared > brush_size_pressure * brush_size_pressure) {
                return 0.0f;
        }
        else {
                const float dist = sqrtf(dist_squared);
-               return brush_curve_strength_clamp(brush, dist, brush_size_final);
+               return brush_curve_strength_clamp(brush, dist, brush_size_pressure);
        }
 }
 
 static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
                               float vpimat[][3], const float *vert_nor,
                               const float mval[2],
-                              const float brush_size_final, const float brush_alpha_final)
+                              const float brush_size_pressure, const float brush_alpha_pressure)
 {
-       float strength = calc_vp_strength_dl(vp, vc, vert_nor, mval, brush_size_final);
+       float strength = calc_vp_strength_dl(vp, vc, vert_nor, mval, brush_size_pressure);
 
        if (strength > 0.0f) {
-               float alpha= brush_alpha_final * strength;
+               float alpha= brush_alpha_pressure * strength;
 
                if(vp->flag & VP_NORMALS) {
                        float dvec[3];
@@ -868,86 +878,83 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
        return 0.0f;
 }
 
-static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *dw_prev, float alpha, float paintval, int flip, int multipaint)
+/* vpaint has 'vpaint_blend_tool' */
+/* result is not clamped from [0-1] */
+static float wpaint_blend_tool(const int tool,
+                               /* dw->weight */
+                               const float weight,
+                               const float paintval, const float alpha)
+{
+       switch (tool) {
+               case PAINT_BLEND_MIX:
+               case PAINT_BLEND_BLUR:
+                       return (paintval * alpha) + (weight * (1.0f - alpha));
+               case PAINT_BLEND_ADD:
+                       return (paintval * alpha) + weight;
+               case PAINT_BLEND_SUB:
+                       return (paintval * alpha) - weight;
+               case PAINT_BLEND_MUL:
+                       /* first mul, then blend the fac */
+                       return ((1.0f - alpha) + alpha * paintval) * weight;
+               case PAINT_BLEND_LIGHTEN:
+                       return (weight < paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
+               case PAINT_BLEND_DARKEN:
+                       return (weight > paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
+               default:
+                       BLI_assert(0);
+                       return 0.0f;
+       }
+}
+
+/* vpaint has 'vpaint_blend' */
+static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
+                          const float alpha, float paintval,
+                          const float brush_alpha_value,
+                          const short do_flip, const short do_multipaint_totsel)
 {
        Brush *brush = paint_brush(&wp->paint);
        int tool = brush->vertexpaint_tool;
 
-       if (flip) {
+       if (do_flip) {
                switch(tool) {
-                       case VP_MIX:
+                       case PAINT_BLEND_MIX:
                                paintval = 1.f - paintval; break;
-                       case VP_ADD:
-                               tool= VP_SUB; break;
-                       case VP_SUB:
-                               tool= VP_ADD; break;
-                       case VP_LIGHTEN:
-                               tool= VP_DARKEN; break;
-                       case VP_DARKEN:
-                               tool= VP_LIGHTEN; break;
-               }
-       }
-       
-       if(tool==VP_MIX || tool==VP_BLUR)
-               dw->weight = paintval*alpha + dw->weight*(1.0f-alpha);
-       else if(tool==VP_ADD)
-               dw->weight += paintval*alpha;
-       else if(tool==VP_SUB) 
-               dw->weight -= paintval*alpha;
-       else if(tool==VP_MUL) 
-               /* first mul, then blend the fac */
-               dw->weight = ((1.0f-alpha) + alpha*paintval)*dw->weight;
-       else if(tool==VP_LIGHTEN) {
-               if (dw->weight < paintval)
-                       dw->weight = paintval*alpha + dw->weight*(1.0f-alpha);
-       } else if(tool==VP_DARKEN) {
-               if (dw->weight > paintval)
-                       dw->weight = paintval*alpha + dw->weight*(1.0f-alpha);
-       }
-       /*  delay clamping until the end so multi-paint can function when the active group is at the limits */
-       if(multipaint == FALSE) {
-               CLAMP(dw->weight, 0.0f, 1.0f);
+                       case PAINT_BLEND_ADD:
+                               tool= PAINT_BLEND_SUB; break;
+                       case PAINT_BLEND_SUB:
+                               tool= PAINT_BLEND_ADD; break;
+                       case PAINT_BLEND_LIGHTEN:
+                               tool= PAINT_BLEND_DARKEN; break;
+                       case PAINT_BLEND_DARKEN:
+                               tool= PAINT_BLEND_LIGHTEN; break;
+               }
+       }
+       
+       weight = wpaint_blend_tool(tool, weight, paintval, alpha);
+
+       /* delay clamping until the end so multi-paint can function when the active group is at the limits */
+       if(do_multipaint_totsel == FALSE) {
+               CLAMP(weight, 0.0f, 1.0f);
        }
        
        /* if no spray, clip result with orig weight & orig alpha */
-       if((wp->flag & VP_SPRAY)==0) {
-               float testw=0.0f;
-               
-               alpha= brush_alpha(brush);
-               if(tool==VP_MIX || tool==VP_BLUR)
-                       testw = paintval*alpha + dw_prev->weight*(1.0f-alpha);
-               else if(tool==VP_ADD)
-                       testw = dw_prev->weight + paintval*alpha;
-               else if(tool==VP_SUB) 
-                       testw = dw_prev->weight - paintval*alpha;
-               else if(tool==VP_MUL) 
-                       /* first mul, then blend the fac */
-                       testw = ((1.0f-alpha) + alpha*paintval)*dw_prev->weight;
-               else if(tool==VP_LIGHTEN) {
-                       if (dw_prev->weight < paintval)
-                               testw = paintval*alpha + dw_prev->weight*(1.0f-alpha);
-                       else
-                               testw = dw_prev->weight;
-               } else if(tool==VP_DARKEN) {
-                       if (dw_prev->weight > paintval)
-                               testw = paintval*alpha + dw_prev->weight*(1.0f-alpha);
-                       else
-                               testw = dw_prev->weight;
-               }
-
-               if(multipaint == FALSE) {
+       if ((wp->flag & VP_SPRAY) == 0) {
+               if(do_multipaint_totsel == FALSE) {
+                       float testw = wpaint_blend_tool(tool, weight_prev, paintval, brush_alpha_value);
+
                        CLAMP(testw, 0.0f, 1.0f);
-                       if( testw<dw_prev->weight ) {
-                               if(dw->weight < testw) dw->weight= testw;
-                               else if(dw->weight > dw_prev->weight) dw->weight= dw_prev->weight;
+                       if (testw < weight_prev) {
+                               if(weight < testw) weight = testw;
+                               else if(weight > weight_prev) weight = weight_prev;
                        }
                        else {
-                               if(dw->weight > testw) dw->weight= testw;
-                               else if(dw->weight < dw_prev->weight) dw->weight= dw_prev->weight;
+                               if (weight > testw) weight = testw;
+                               else if (weight < weight_prev) weight = weight_prev;
                        }
                }
        }
-       
+
+       return weight;
 }
 
 /* ----------------------------------------------------- */
@@ -1592,6 +1599,8 @@ typedef struct WeightPaintInfo {
        char do_flip;
        char do_multipaint;
        char do_auto_normalize;
+
+       float brush_alpha_value;  /* result of brush_alpha() */
 } WeightPaintInfo;
 
 /* fresh start to make multi-paint and locking modular */
@@ -1676,9 +1685,9 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba
 static char *wpaint_make_validmap(Object *ob);
 
 
-static void do_weight_paint_vertex( /* vars which remain the same for every vert */
+static void do_weight_paint_vertex(/* vars which remain the same for every vert */
                                    VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
-                                    /* vars which change on each stroke */
+                                   /* vars which change on each stroke */
                                    const unsigned int index, float alpha, float paintweight
                                    )
 {
@@ -1694,6 +1703,8 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
        MDeformVert *dv_mirr;
        MDeformWeight *dw_mirr;
 
+       const short do_multipaint_totsel = (wpi->do_multipaint && wpi->defbase_tot_sel > 1);
+
        if(wp->flag & VP_ONLYVGROUP) {
                dw= defvert_find_index(dv, wpi->vgroup_active);
                dw_prev= defvert_find_index(wp->wpaint_prev+index, wpi->vgroup_active);
@@ -1736,7 +1747,20 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
                        }
                }
                else {
-                       dw_mirr = defvert_verify_index(dv_mirr, vgroup_mirr);
+                       if (index != index_mirr) {
+                               dw_mirr = defvert_verify_index(dv_mirr, vgroup_mirr);
+                       }
+                       else {
+                               /* dv and dv_mirr are the same */
+                               int totweight_prev = dv_mirr->totweight;
+                               int dw_offset = (int)(dw - dv_mirr->dw);
+                               dw_mirr = defvert_verify_index(dv_mirr, vgroup_mirr);
+
+                               /* if we added another, get our old one back */
+                               if (totweight_prev != dv_mirr->totweight) {
+                                       dw = &dv_mirr->dw[dw_offset];
+                               }
+                       }
                }
        }
        else {
@@ -1750,10 +1774,11 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
 
        /* If there are no locks or multipaint,
         * then there is no need to run the more complicated checks */
-       if ( (wpi->do_multipaint == FALSE || wpi->defbase_tot_sel <= 1) &&
+       if ( (do_multipaint_totsel == FALSE) &&
             (wpi->lock_flags == NULL || has_locked_group(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->lock_flags) == FALSE))
        {
-               wpaint_blend(wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, FALSE);
+               dw->weight = wpaint_blend(wp, dw->weight, dw_prev->weight, alpha, paintweight,
+                                         wpi->brush_alpha_value, wpi->do_flip, FALSE);
 
                /* WATCH IT: take care of the ordering of applying mirror -> normalize,
                 * can give wrong results [#26193], least confusing if normalize is done last */
@@ -1818,12 +1843,11 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
                MDeformVert dv_copy= {NULL};
 
                oldw = dw->weight;
-               wpaint_blend(wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, wpi->do_multipaint && wpi->defbase_tot_sel >1);
-               neww = dw->weight;
-               dw->weight = oldw;
+               neww = wpaint_blend(wp, dw->weight, dw_prev->weight, alpha, paintweight,
+                                   wpi->brush_alpha_value, wpi->do_flip, do_multipaint_totsel);
                
                /* setup multi-paint */
-               if(wpi->defbase_tot_sel > 1 && wpi->do_multipaint) {
+               if (do_multipaint_totsel) {
                        dv_copy.dw= BLI_cellalloc_dupalloc(dv->dw);
                        dv_copy.flag = dv->flag;
                        dv_copy.totweight = dv->totweight;
@@ -2159,7 +2183,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
 
 static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 {
-       const Scene *scene= CTX_data_scene(C);
+       Scene *scene= CTX_data_scene(C);
        ToolSettings *ts= CTX_data_tool_settings(C);
        VPaint *wp= ts->wpaint;
        Brush *brush = paint_brush(&wp->paint);
@@ -2178,8 +2202,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        char *defbase_sel;
 
        const float pressure = RNA_float_get(itemptr, "pressure");
-       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
-       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_size_pressure = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_alpha_value = brush_alpha(scene, brush);
+       const float brush_alpha_pressure = brush_alpha_value * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
 
        /* intentionally dont initialize as NULL, make sure we initialize all members below */
        WeightPaintInfo wpi;
@@ -2223,6 +2248,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        wpi.do_flip=            RNA_boolean_get(itemptr, "pen_flip");
        wpi.do_multipaint=      (ts->multipaint != 0);
        wpi.do_auto_normalize=  ((ts->auto_normalize != 0) && (wpi.vgroup_validmap != NULL));
+       wpi.brush_alpha_value=  brush_alpha_value;
        /* *** done setting up WeightPaintInfo *** */
 
 
@@ -2235,7 +2261,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        if(wp->flag & VP_AREA) {
                /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */
                me->editflag &= ~ME_EDIT_VERT_SEL;
-               totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_final);
+               totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
                me->editflag |= use_vert_sel ? ME_EDIT_VERT_SEL : 0;
        }
        else {
@@ -2271,7 +2297,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        /* make sure each vertex gets treated only once */
        /* and calculate filter weight */
        totw= 0.0f;
-       if(brush->vertexpaint_tool==VP_BLUR) 
+       if (brush->vertexpaint_tool == PAINT_BLEND_BLUR)
                paintweight= 0.0f;
        else
                paintweight= ts->vgroup_weight;
@@ -2293,7 +2319,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                                }
                        }
                                        
-                       if(brush->vertexpaint_tool==VP_BLUR) {
+                       if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
                                MDeformWeight *dw, *(*dw_func)(MDeformVert *, const int);
                                                
                                if(wp->flag & VP_ONLYVGROUP)
@@ -2303,7 +2329,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                                                
                                ml = me->mloop + mpoly->loopstart;
                                for (i=0; i<mpoly->totloop; i++, ml++) {
-                                       const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos+6*ml->v, mval, brush_size_final);
+                                       const float fac = calc_vp_strength_dl(wp, vc, wpd->vertexcosnos+6*ml->v, mval, brush_size_pressure);
                                        if (fac > 0.0f) {
                                                dw = dw_func(&me->dvert[ml->v], wpi.vgroup_active);
                                                paintweight += dw ? (dw->weight * fac) : 0.0f;
@@ -2314,7 +2340,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                }
        }
                        
-       if (brush->vertexpaint_tool==VP_BLUR) {
+       if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
                paintweight /= totw;
        }
 
@@ -2328,7 +2354,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                                unsigned int vidx= ml->v;
                                if (me->dvert[vidx].flag) {
                                        alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx,
-                                                               mval, brush_size_final, brush_alpha_final);
+                                                               mval, brush_size_pressure, brush_alpha_pressure);
                                        if(alpha) {
                                                do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight);
                                        }
@@ -2632,7 +2658,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent
 #if 0
 static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
                               const unsigned int index, const float mval[2],
-                              const float brush_size_final, const float brush_alpha_final,
+                              const float brush_size_pressure, const float brush_alpha_pressure,
                               int UNUSED(flip))
 {
        ViewContext *vc = &vpd->vc;
@@ -2643,12 +2669,14 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
        unsigned int *mcolorig= ((unsigned int*)vp->vpaint_prev) + 4*index;
        float alpha;
        int i;
+
+       int brush_alpha_pressure_i;
        
        if((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) ||
           ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
                return;
 
-       if(brush->vertexpaint_tool==VP_BLUR) {
+       if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
                unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128);
                if(mface->v4) {
                        unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128);
@@ -2657,14 +2685,16 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
                else {
                        vpd->paintcol= mcol_blend( mcol[2], fcol1, 170);
                }
-               
        }
 
+       brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f);
+
        for(i = 0; i < (mface->v4 ? 4 : 3); ++i) {
                alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i],
-                                        mval, brush_size_final, brush_alpha_final);
-               if(alpha) {
-                       vpaint_blend(vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
+                                        mval, brush_size_pressure, brush_alpha_pressure);
+               if (alpha) {
+                       const int alpha_i = (int)(alpha*255.0f);
+                       mcol[i] = vpaint_blend(vp, mcol[i], mcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i);
                }
        }
 }
@@ -2672,7 +2702,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
 
 static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 {
-       const Scene *scene= CTX_data_scene(C);
+       Scene *scene= CTX_data_scene(C);
        ToolSettings *ts= CTX_data_tool_settings(C);
        struct VPaintData *vpd = paint_stroke_mode_data(stroke);
        VPaint *vp= ts->vpaint;
@@ -2687,8 +2717,10 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        float mval[2];
 
        const float pressure = RNA_float_get(itemptr, "pressure");
-       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
-       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_size_pressure = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_alpha_pressure = brush_alpha(scene, brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+
+       int brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f);
 
        RNA_float_get_array(itemptr, "mouse", mval);
        flip = RNA_boolean_get(itemptr, "pen_flip");
@@ -2706,7 +2738,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                        
        /* which faces are involved */
        if(vp->flag & VP_AREA) {
-               totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_final);
+               totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
        }
        else {
                indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
@@ -2742,7 +2774,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        swap_m4m4(vc->rv3d->persmat, mat);
 
        /* was disabled because it is slow, but necessary for blur */
-       if(brush->vertexpaint_tool == VP_BLUR)
+       if (brush->vertexpaint_tool == PAINT_BLEND_BLUR)
                do_shared_vertexcol(me);
                        
        for(index=0; index<totindex; index++) {
@@ -2758,7 +2790,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                        float alpha;
                        int i, j;
                                        
-                       if(brush->vertexpaint_tool==VP_BLUR) {
+                       if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
                                unsigned int blend[5] = {0};
                                char *col;
 
@@ -2787,8 +2819,11 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                        for (i=0; i<mpoly->totloop; i++, ml++) {
                                alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, 
                                                        vpd->vertexcosnos+6*ml->v, mval,
-                                                       brush_size_final, brush_alpha_final);
-                               if(alpha > 0.0f) vpaint_blend(vp, lcol+i, lcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
+                                                       brush_size_pressure, brush_alpha_pressure);
+                               if(alpha > 0.0f) {
+                                       const int alpha_i = (int)(alpha*255.0f);
+                                       lcol[i] = vpaint_blend(vp, lcol[i], lcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i);
+                               }
                        }
        
                        #ifdef CPYCOL
@@ -2823,7 +2858,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        swap_m4m4(vc->rv3d->persmat, mat);
                        
        /* was disabled because it is slow, but necessary for blur */
-       if(brush->vertexpaint_tool == VP_BLUR) {
+       if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
                do_shared_vertexcol(me);
        }
 
index f323a592b074e189a1fdf235035a1a80dcfeaf3d..ae5316e71c41ae6dec8dd99908da36ba7dcc744a 100644 (file)
@@ -543,13 +543,14 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache)
    special multiplier found experimentally to scale the strength factor. */
 static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
 {
+       const Scene *scene = cache->vc->scene;
        Brush *brush = paint_brush(&sd->paint);
 
        /* Primary strength input; square it to make lower values more sensitive */
-       const float root_alpha = brush_alpha(brush);
+       const float root_alpha = brush_alpha(scene, brush);
        float alpha        = root_alpha*root_alpha;
        float dir          = brush->flag & BRUSH_DIR_IN ? -1 : 1;
-       float pressure     = brush_use_alpha_pressure(cache->vc->scene, brush) ? cache->pressure : 1;
+       float pressure     = brush_use_alpha_pressure(scene, brush) ? cache->pressure : 1;
        float pen_flip     = cache->pen_flip ? -1 : 1;
        float invert       = cache->invert ? -1 : 1;
        float accum        = integrate_overlap(brush);
@@ -679,7 +680,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
                else /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED),
                        leave the coordinates relative to the screen */
                {
-                       radius = brush_size(br); // use unadjusted size for tiled mode
+                       radius = brush_size(ss->cache->vc->scene, br); // use unadjusted size for tiled mode
                
                        x = point_2d[0];
                        y = point_2d[1];
@@ -1167,6 +1168,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 {
        SculptSession *ss = ob->sculpt;
+       const Scene *scene = ss->cache->vc->scene;
        Brush *brush = paint_brush(&sd->paint);
        float offset[3], area_normal[3];
        float bstrength= ss->cache->bstrength;
@@ -1182,8 +1184,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
        
        /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
        
-       if(brush_alpha(brush) > 0.0f)
-               crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(brush)*brush_alpha(brush));
+       if(brush_alpha(scene, brush) > 0.0f)
+               crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(scene, brush)*brush_alpha(scene, brush));
        else
                crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor;
 
@@ -2658,10 +2660,10 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob)
        cache->first_time= 0;
 }
 
-static void sculpt_update_tex(Sculpt *sd, SculptSession *ss)
+static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
 {
        Brush *brush = paint_brush(&sd->paint);
-       const int radius= brush_size(brush);
+       const int radius= brush_size(scene, brush);
 
        if(ss->texcache) {
                MEM_freeN(ss->texcache);
@@ -3017,7 +3019,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
                                                                                 struct PaintStroke *stroke,
                                                                                 PointerRNA *ptr)
 {
-       const Scene *scene = CTX_data_scene(C);
+       Scene *scene = CTX_data_scene(C);
        SculptSession *ss = ob->sculpt;
        StrokeCache *cache = ss->cache;
        Brush *brush = paint_brush(&sd->paint);
@@ -3052,15 +3054,15 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
        sd->pressure_value= cache->pressure;
 
        cache->previous_pixel_radius = cache->pixel_radius;
-       cache->pixel_radius = brush_size(brush);
+       cache->pixel_radius = brush_size(scene, brush);
 
        if(cache->first_time) {
                if (!brush_use_locked_size(scene, brush)) {
-                       cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush));
-                       brush_set_unprojected_radius(brush, cache->initial_radius);
+                       cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush));
+                       brush_set_unprojected_radius(scene, brush, cache->initial_radius);
                }
                else {
-                       cache->initial_radius= brush_unprojected_radius(brush);
+                       cache->initial_radius= brush_unprojected_radius(scene, brush);
                }
        }
 
@@ -3246,7 +3248,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
        return srd.hit;
 }
 
-static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
+static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
 {
        Brush *brush = paint_brush(&sd->paint);
        MTex *mtex= &brush->mtex;
@@ -3258,7 +3260,7 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
        /* TODO: Shouldn't really have to do this at the start of every
           stroke, but sculpt would need some sort of notification when
           changes are made to the texture. */
-       sculpt_update_tex(sd, ss);
+       sculpt_update_tex(scene, sd, ss);
 }
 
 static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
@@ -3272,7 +3274,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
        int is_smooth= 0;
 
        view3d_operator_needs_opengl(C);
-       sculpt_brush_init_tex(sd, ss);
+       sculpt_brush_init_tex(scene, sd, ss);
 
        is_smooth|= mode == BRUSH_STROKE_SMOOTH;
        is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
index c3af35219184db27f5dd4ec757736e6788863beb..d4e44dee9c3dbac8a576d78a88754fb87b9d064a 100644 (file)
@@ -36,6 +36,7 @@
 #include "DNA_space_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
 
 #include "ED_anim_api.h"
 #include "ED_markers.h"
@@ -110,32 +111,45 @@ static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
        
        /* action_select.c - selection tools */
                /* click-select */
-       WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "column", 1);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", TRUE);
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
-               RNA_boolean_set(kmi->ptr, "column", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "column", TRUE);
                
                /* select left/right */
-       WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST);
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST);
        
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT);
        kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
        
                /* deselect all */
-       WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "invert", FALSE);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "invert", TRUE);
        
                /* borderselect */
-       WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
+       kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
        
                /* column select */
        RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS);
index eecf62421c831637bb1b9a673882d10e03434fe0..5c39da94ecdc401246843d8f5e63ff327b136870 100644 (file)
@@ -269,44 +269,66 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
        
        /* graph_select.c - selection tools */
                /* click-select */
-       WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "curves", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "column", 1);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "curves", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", TRUE);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "curves", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
-               RNA_boolean_set(kmi->ptr, "column", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "curves", FALSE);
+               RNA_boolean_set(kmi->ptr, "column", TRUE);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "curves", 1);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "curves", TRUE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "curves", 1);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "curves", TRUE);
+               RNA_boolean_set(kmi->ptr, "column", FALSE);
        
        /* select left/right */
        WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
        
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
        kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
        
                /* deselect all */
-       WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+       kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "invert", FALSE);
+       kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "invert", TRUE);
        
                /* borderselect */
-       WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
+               RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
        kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "axis_range", 1);
+               RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
+               RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
                
        kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0);
-               RNA_boolean_set(kmi->ptr, "include_handles", 1);
+               RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
+               RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
        kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "axis_range", 1);
-               RNA_boolean_set(kmi->ptr, "include_handles", 1);
+               RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
+               RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
                
                /* column select */
        RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
index 821e302c13dd904be66b19cd115d22ba6b2314ce..f173a3d383599919c5764ae797e01425139069fe 100644 (file)
@@ -192,28 +192,39 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap)
        
        /* selection */
                /* click select */
-       WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
                
                /* select left/right */
-       WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST);
        kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST);
        
        kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT);
        kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
                RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
                
        
                /* deselect all */
-       WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+               /* TODO: uniformize with other select_all ops? */
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "invert", FALSE);
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_boolean_set(kmi->ptr, "invert", TRUE);
        
                /* borderselect */
-       WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
+       kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
        
        /* view*/
                /* auto-set range */
index b5c435b50e86e6967557323f206f2c0e8cbe27f6..b71776f4266f1c4269f61f3f236f569355e98e01 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "BKE_context.h"
 
+#include "BLI_utildefines.h"
+
 #include "ED_node.h"
 #include "ED_screen.h"
 #include "ED_transform.h"
@@ -138,12 +140,14 @@ void node_keymap(struct wmKeyConfig *keyconf)
        /* mouse select in nodes used to be both keys, but perhaps this should be reduced? 
         * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize
         */
-       WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+       kmi = WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
        kmi= WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
        kmi= WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
-               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
        RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0)->ptr, "tweak", 1);
        
        /* each of these falls through if not handled... */
index 883a09ff32887222763e4e07b5d4792786b4b4a9..a6d8b6c2612d3b609a89e8cd5c71875122b5f80b 100644 (file)
@@ -132,17 +132,23 @@ void sequencer_keymap(wmKeyConfig *keyconf)
        
        WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
        
-       WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
        
        RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
        RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
        
-       WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "unselected", FALSE);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "unselected", TRUE);
        
-       WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "unselected", FALSE);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "unselected", TRUE);
 
        WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", LKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
@@ -192,8 +198,16 @@ void sequencer_keymap(wmKeyConfig *keyconf)
        }
 
        /* Mouse selection, a bit verbose :/ */
-       WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
+               RNA_boolean_set(kmi->ptr, "left_right", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
+               RNA_boolean_set(kmi->ptr, "left_right", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
 
 
        /* 2.4x method, now use Alt for handles and select the side based on which handle was selected */
@@ -220,21 +234,31 @@ void sequencer_keymap(wmKeyConfig *keyconf)
         */
 
        /* 2.5 method, Alt and use selected handle */
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "linked_handle", 1);
+       kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", TRUE);
+               RNA_boolean_set(kmi->ptr, "left_right", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
 
        kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
-       RNA_boolean_set(kmi->ptr, "extend", 1);
-       RNA_boolean_set(kmi->ptr, "linked_handle", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", TRUE);
+               RNA_boolean_set(kmi->ptr, "left_right", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
 
        /* match action editor */
        kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
-       RNA_boolean_set(kmi->ptr, "left_right", 1); /* grr, these conflict - only use left_right if not over an active seq */
-       RNA_boolean_set(kmi->ptr, "linked_time", 1);
+               RNA_boolean_set(kmi->ptr, "extend", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
+               RNA_boolean_set(kmi->ptr, "left_right", TRUE); /* grr, these conflict - only use left_right if not over an active seq */
+               RNA_boolean_set(kmi->ptr, "linked_time", TRUE);
        /* adjusted since 2.4 */
 
        kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
-       RNA_boolean_set(kmi->ptr, "extend", 1);
-       RNA_boolean_set(kmi->ptr, "linked_time", 1);
+               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+               RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
+               RNA_boolean_set(kmi->ptr, "left_right", FALSE);
+               RNA_boolean_set(kmi->ptr, "linked_time", TRUE);
 
        WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
index c8223dadd98c67c8cfa97bfe76d19b1838e515f4..4594544b4f85639d28582b883550d7886a7bc96c 100644 (file)
@@ -262,33 +262,54 @@ void view3d_keymap(wmKeyConfig *keyconf)
        RNA_string_set(kmi->ptr, "value_2", "SOLID");
 
        /* selection*/
-       WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
+       RNA_boolean_set(kmi->ptr, "center", FALSE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
+       RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
        RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       RNA_boolean_set(kmi->ptr, "center", FALSE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
+       RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
        kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
        RNA_boolean_set(kmi->ptr, "center", TRUE);
        RNA_boolean_set(kmi->ptr, "object", TRUE); /* use Ctrl+Select for 2 purposes */
+       RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
        kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
+       RNA_boolean_set(kmi->ptr, "center", FALSE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
        RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
 
        /* selection key-combinations */
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
-       RNA_boolean_set(kmi->ptr, "center", TRUE);
        RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       RNA_boolean_set(kmi->ptr, "center", TRUE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
+       RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
        RNA_boolean_set(kmi->ptr, "center", TRUE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
        RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
        RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       RNA_boolean_set(kmi->ptr, "center", FALSE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
        RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
-       RNA_boolean_set(kmi->ptr, "center", TRUE);
        RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       RNA_boolean_set(kmi->ptr, "center", TRUE);
+       RNA_boolean_set(kmi->ptr, "object", FALSE);
        RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
 
        WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "deselect", 1);
+       kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "deselect", FALSE);
+       kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "deselect", TRUE);
        WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
        
        WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
index e5c500f1fea535afafdad94c4fdcf52f6f2f01f9..6e7385d683d60299e3b8cf3616e861923aea0444 100644 (file)
@@ -81,7 +81,7 @@ typedef struct Brush {
        float plane_offset;             /* offset for plane brushes (clay, flatten, fill, scrape) */
 
        char sculpt_tool;               /* active sculpt tool */
-       char vertexpaint_tool;          /* active vertex/weight paint tool/blend mode */
+       char vertexpaint_tool;          /* active vertex/weight paint blend mode (poorly named) */
        char imagepaint_tool;           /* active image paint tool */
        char pad3[5];
 
@@ -167,9 +167,20 @@ enum {
        SCULPT_DISP_DIR_VIEW,
        SCULPT_DISP_DIR_X,
        SCULPT_DISP_DIR_Y,
-       SCULPT_DISP_DIR_Z,
+       SCULPT_DISP_DIR_Z
 };
 
+enum {
+       PAINT_BLEND_MIX,
+       PAINT_BLEND_ADD,
+       PAINT_BLEND_SUB,
+       PAINT_BLEND_MUL,
+       PAINT_BLEND_BLUR,
+       PAINT_BLEND_LIGHTEN,
+       PAINT_BLEND_DARKEN
+};
+
+
 #define MAX_BRUSH_PIXEL_RADIUS 200
 
 #endif
index 63009e091617ae7005e9407af81017e7f0f2c2af..c1f87240e777777a9d7b6c87758f38198909bea8 100644 (file)
@@ -69,13 +69,13 @@ EnumPropertyItem brush_sculpt_tool_items[] = {
 
 
 EnumPropertyItem brush_vertex_tool_items[] = {
-       {0, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
-       {1, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
-       {2, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
-       {3, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
-       {4, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
-       {5, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
-       {6, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
+       {PAINT_BLEND_MIX, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
+       {PAINT_BLEND_ADD, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
+       {PAINT_BLEND_SUB, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
+       {PAINT_BLEND_MUL, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
+       {PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
+       {PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
+       {PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
        {0, NULL, 0, NULL, NULL}};
        
 EnumPropertyItem brush_image_tool_items[] = {
@@ -164,60 +164,21 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
 
 static void rna_Brush_set_size(PointerRNA *ptr, int value)
 {
-       Brush* me = (Brush*)(ptr->data);
+       Brush* brush = ptr->data;
 
-       float size= (float)brush_size(me);
-       float unprojected_radius;
-
-       // paranoia: previous checks should make sure we don't divide by zero
-       assert(size != 0);
-
-       // set unprojected radius, so it remains consistent with size
-       unprojected_radius= (float)(brush_unprojected_radius(me) * value / size);
-       brush_set_unprojected_radius(me, unprojected_radius);
-
-       brush_set_size(me, value);
-}
-
-static int rna_Brush_get_size(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_size(me);
+       /* scale unprojected radius so it stays consistent with brush size */
+       brush_scale_unprojected_radius(&brush->unprojected_radius,
+                                                                  value, brush->size);
+       brush->size= value;
 }
 
 static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
 {
-       Brush* me = (Brush*)(ptr->data);
-
-       float unprojected_radius= brush_unprojected_radius(me);
-       int size;
-
-       // paranoia: previous checks should make sure we don't divide by zero
-       assert(unprojected_radius != 0.0f);
-
-       // set size, so that it is consistent with unprojected_radius
-       size= (int)((float)brush_size(me) * value / unprojected_radius);
-       brush_set_size(me, size);
-
-       brush_set_unprojected_radius(me, value);
-}
-
-static float rna_Brush_get_unprojected_radius(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_unprojected_radius(me);
-}
+       Brush* brush = ptr->data;
 
-static void rna_Brush_set_alpha(PointerRNA *ptr, float value)
-{
-       Brush* me = (Brush*)(ptr->data);
-       brush_set_alpha(me, value);
-}
-
-static float rna_Brush_get_alpha(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_alpha(me);
+       /* scale brush size so it stays consistent with unprojected_radius */
+       brush_scale_size(&brush->size, value, brush->unprojected_radius);
+       brush->unprojected_radius= value;
 }
 
 static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free))
@@ -412,14 +373,14 @@ static void rna_def_brush(BlenderRNA *brna)
        
        /* number values */
        prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
-       RNA_def_property_int_funcs(prop, "rna_Brush_get_size", "rna_Brush_set_size", NULL);
+       RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL);
        RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10);
        RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
        RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
        
        prop= RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
-       RNA_def_property_float_funcs(prop, "rna_Brush_get_unprojected_radius", "rna_Brush_set_unprojected_radius", NULL);
+       RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
        RNA_def_property_range(prop, 0.001, FLT_MAX);
        RNA_def_property_ui_range(prop, 0.001, 1, 0, 0);
        RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
@@ -463,7 +424,6 @@ static void rna_def_brush(BlenderRNA *brna)
        
        prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_float_sdna(prop, NULL, "alpha");
-       RNA_def_property_float_funcs(prop, "rna_Brush_get_alpha", "rna_Brush_set_alpha", NULL);
        RNA_def_property_float_default(prop, 0.5f);
        RNA_def_property_range(prop, 0.0f, 10.0f);
        RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
index 2d381b023cf5795d14b548e81cb466dcdfc546b0..0dbc0f63d4dc3084c2d79eb5feeba1dddf4bba5d 100644 (file)
@@ -246,6 +246,7 @@ EnumPropertyItem image_color_depth_items[] = {
 #include "BLI_threads.h"
 #include "BLI_editVert.h"
 
+#include "BKE_brush.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
@@ -1290,6 +1291,25 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons
        }
 }
 
+static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value)
+{
+       UnifiedPaintSettings* ups = ptr->data;
+
+       /* scale unprojected radius so it stays consistent with brush size */
+       brush_scale_unprojected_radius(&ups->unprojected_radius,
+                                                                  value, ups->size);
+       ups->size= value;
+}
+
+static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, float value)
+{
+       UnifiedPaintSettings* ups = ptr->data;
+
+       /* scale brush size so it stays consistent with unprojected_radius */
+       brush_scale_size(&ups->size, value, ups->unprojected_radius);
+       ups->unprojected_radius= value;
+}
+
 /* note: without this, when Multi-Paint is activated/deactivated, the colors
  * will not change right away when multiple bones are selected, this function
  * is not for general use and only for the few cases where changing scene
@@ -1656,11 +1676,13 @@ static void rna_def_unified_paint_settings(BlenderRNA  *brna)
        /* unified paint settings that override the equivalent settings
           from the active brush */
        prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
+       RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL);
        RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10);
        RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
        RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
 
        prop= RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
+       RNA_def_property_float_funcs(prop, NULL, "rna_UnifiedPaintSettings_unprojected_radius_set", NULL);
        RNA_def_property_range(prop, 0.001, FLT_MAX);
        RNA_def_property_ui_range(prop, 0.001, 1, 0, 0);
        RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
@@ -2778,7 +2800,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
        prop = RNA_def_property(srna, "use_lossless_output", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flags", FFMPEG_LOSSLESS_OUTPUT);
        RNA_def_property_boolean_funcs(prop, NULL, "rna_FFmpegSettings_lossless_output_set");
-       RNA_def_property_ui_text(prop, "Lossless Output", "Use losslecc output for video streams");
+       RNA_def_property_ui_text(prop, "Lossless Output", "Use lossless output for video streams");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 
        /* FFMPEG Audio*/
index 123d58073259117c4f00bf83256ae679faa058a2..edd822bd2da0ed59ae0b7dfe067b56906db8d21d 100644 (file)
@@ -3083,23 +3083,35 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
        glDisable(GL_LINE_SMOOTH);
 }
 
+typedef enum {
+       RC_PROP_ALLOW_MISSING = 1,
+       RC_PROP_REQUIRE_FLOAT = 2,
+       RC_PROP_REQUIRE_BOOL = 4,
+} RCPropFlags;
+
 /* attempt to retrieve the rna pointer/property from an rna path;
    returns 0 for failure, 1 for success, and also 1 if property is not
    set */
 static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
                                   const char *name, PointerRNA *r_ptr,
-                                  PropertyRNA **r_prop, int req_float,
-                                  int req_length, int allow_missing)
+                                  PropertyRNA **r_prop, int req_length, RCPropFlags flags)
 {
        PropertyRNA *unused_prop;
        int len;
        char *str;
 
+       /* check flags */
+       if((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) {
+               BKE_reportf(op->reports, RPT_ERROR, "Property can't be both boolean and float");
+               return 0;
+       }
+
        /* get an rna string path from the operator's properties */
        if(!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0)))
                return 1;
 
        if(str[0] == '\0') {
+               if(r_prop) *r_prop = NULL;
                MEM_freeN(str);
                return 1;
        }
@@ -3110,7 +3122,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
        /* get rna from path */
        if(!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) {
                MEM_freeN(str);
-               if(allow_missing)
+               if(flags & RC_PROP_ALLOW_MISSING)
                        return 1;
                else {
                        BKE_reportf(op->reports, RPT_ERROR, "Couldn't resolve path %s", name);
@@ -3118,9 +3130,12 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
                }
        }
 
-       /* if property is expected to be a float, check its type */
-       if(req_float) {
-               if(!(*r_prop) || (RNA_property_type(*r_prop) != PROP_FLOAT)) {
+       /* check property type */
+       if(flags & (RC_PROP_REQUIRE_BOOL | RC_PROP_REQUIRE_FLOAT)) {
+               PropertyType prop_type = RNA_property_type(*r_prop);
+
+               if(((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) ||
+                  ((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT)) {
                        MEM_freeN(str);
                        BKE_reportf(op->reports, RPT_ERROR,
                                    "Property from path %s is not a float", name);
@@ -3146,31 +3161,50 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
 static int radial_control_get_properties(bContext *C, wmOperator *op)
 {
        RadialControl *rc = op->customdata;
-       PointerRNA ctx_ptr;
+       PointerRNA ctx_ptr, use_secondary_ptr;
+       PropertyRNA *use_secondary_prop;
+       const char *data_path;
 
        RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
 
-       if(!radial_control_get_path(&ctx_ptr, op, "data_path", &rc->ptr, &rc->prop, 0, 0, 0))
+       /* check if we use primary or secondary path */
+       if(!radial_control_get_path(&ctx_ptr, op, "use_secondary",
+                                                               &use_secondary_ptr, &use_secondary_prop,
+                                                               0, (RC_PROP_ALLOW_MISSING|
+                                                                       RC_PROP_REQUIRE_BOOL))) {
+               return 0;
+       }
+       else {
+               if(use_secondary_prop &&
+                  RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop))
+                       data_path = "data_path_secondary";
+               else
+                       data_path = "data_path_primary";
+       }
+
+       if(!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0))
                return 0;
 
        /* data path is required */
        if(!rc->prop)
                return 0;
        
-       if(!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 1, 0, 0))
+       if(!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT))
                return 0;
-       if(!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 1, 3, 0))
+       if(!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT))
                return 0;
-       if(!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 1, 3, 0))
+       if(!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 3, RC_PROP_REQUIRE_FLOAT))
                return 0;
        
        /* slightly ugly; allow this property to not resolve
           correctly. needed because 3d texture paint shares the same
           keymap as 2d image paint */
-       if(!radial_control_get_path(&ctx_ptr, op, "zoom_path", &rc->zoom_ptr, &rc->zoom_prop, 1, 2, 1))
+       if(!radial_control_get_path(&ctx_ptr, op, "zoom_path",
+                                                               &rc->zoom_ptr, &rc->zoom_prop, 2,
+                                                               RC_PROP_REQUIRE_FLOAT|RC_PROP_ALLOW_MISSING))
                return 0;
        
-       if(!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0, 0))
+       if(!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0))
                return 0;
        else if(rc->image_id_ptr.data) {
                /* extra check, pointer must be to an ID */
@@ -3363,7 +3397,9 @@ static void WM_OT_radial_control(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
 
        /* all paths relative to the context */
-       RNA_def_string(ot->srna, "data_path", "", 0, "Data Path", "Path of property to be set by the radial control");
+       RNA_def_string(ot->srna, "data_path_primary", "", 0, "Primary Data Path", "Primary path of property to be set by the radial control");
+       RNA_def_string(ot->srna, "data_path_secondary", "", 0, "Secondary Data Path", "Secondary path of property to be set by the radial control");
+       RNA_def_string(ot->srna, "use_secondary", "", 0, "Use Secondary", "Path of property to select between the primary and secondary data paths");
        RNA_def_string(ot->srna, "rotation_path", "", 0, "Rotation Path", "Path of property used to rotate the texture display");
        RNA_def_string(ot->srna, "color_path", "", 0, "Color Path", "Path of property used to set the color of the control");
        RNA_def_string(ot->srna, "fill_color_path", "", 0, "Fill Color Path", "Path of property used to set the fill color of the control");