Fix T59450: brush colors flip inactive w/ texture paint
authorCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jan 2019 12:24:38 +0000 (23:24 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jan 2019 12:25:36 +0000 (23:25 +1100)
source/blender/editors/sculpt_paint/paint_image.c

index b8ac4403e1dd67824430dd7f2b4935636484bcd1..04941e364555a9eac99317934dbaca8a79c693e2 100644 (file)
@@ -1177,20 +1177,12 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
 
 static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
+       Scene *scene = CTX_data_scene(C);
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 
-       Object *ob = CTX_data_active_object(C);
-       Brush *br;
-       if (!(ob && (ob->mode & OB_MODE_VERTEX_PAINT))) {
-               br = image_paint_brush(C);
-       }
-       else {
-               /* At the moment, wpaint does not support the color flipper.
-                * So for now we're only handling vpaint */
-               ToolSettings *ts = CTX_data_tool_settings(C);
-               VPaint *vp = ts->vpaint;
-               br = BKE_paint_brush(&vp->paint);
-       }
+       ViewLayer *view_layer = CTX_data_view_layer(C);
+       Paint *paint = BKE_paint_get_active(scene, view_layer);
+       Brush *br = BKE_paint_brush(paint);
 
        if (ups->flag & UNIFIED_PAINT_COLOR) {
                swap_v3_v3(ups->rgb, ups->secondary_rgb);
@@ -1208,15 +1200,17 @@ static bool brush_colors_flip_poll(bContext *C)
        if (image_paint_poll(C)) {
                Brush *br = image_paint_brush(C);
                if (br->imagepaint_tool == PAINT_TOOL_DRAW)
-                       return 1;
+                       return true;
        }
        else {
                Object *ob = CTX_data_active_object(C);
-               if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) {
-                       return 1;
+               if (ob != NULL) {
+                       if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)) {
+                               return true;
+                       }
                }
        }
-       return 0;
+       return false;
 }
 
 void PAINT_OT_brush_colors_flip(wmOperatorType *ot)