[Bf-blender-cvs] [35490c3ead0] master: Fix T73656: Use BKE_brush_alpha_get in texture paint

Pablo Dobarro noreply at git.blender.org
Tue Feb 11 17:47:14 CET 2020


Commit: 35490c3ead03d472dbcba36c85d428e81b442520
Author: Pablo Dobarro
Date:   Tue Feb 11 17:28:46 2020 +0100
Branches: master
https://developer.blender.org/rB35490c3ead03d472dbcba36c85d428e81b442520

Fix T73656: Use BKE_brush_alpha_get in texture paint

The code was using brush->alpha directly, so the alpha value from
UnifiedPaintSettings was not used when eneabled.

Reviewed By: brecht

Maniphest Tasks: T73656

Differential Revision: https://developer.blender.org/D6804

===================================================================

M	source/blender/editors/sculpt_paint/paint_image_2d.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index c5c2c524af9..1bd6a831be2 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -1893,7 +1893,7 @@ void paint_2d_bucket_fill(const bContext *C,
   int x_px, y_px;
   unsigned int color_b;
   float color_f[4];
-  float strength = br ? br->alpha : 1.0f;
+  float strength = br ? BKE_brush_alpha_get(s->scene, br) : 1.0f;
 
   bool do_float;
 
@@ -2118,6 +2118,7 @@ void paint_2d_gradient_fill(
   float image_init[2], image_final[2];
   float tangent[2];
   float line_len_sq_inv, line_len;
+  const float brush_alpha = BKE_brush_alpha_get(s->scene, br);
 
   bool do_float;
 
@@ -2179,7 +2180,7 @@ void paint_2d_gradient_fill(
         BKE_colorband_evaluate(br->gradient, f, color_f);
         /* convert to premultiplied */
         mul_v3_fl(color_f, color_f[3]);
-        color_f[3] *= br->alpha;
+        color_f[3] *= brush_alpha;
         IMB_blend_color_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
                               ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
                               color_f,
@@ -2208,7 +2209,7 @@ void paint_2d_gradient_fill(
         BKE_colorband_evaluate(br->gradient, f, color_f);
         linearrgb_to_srgb_v3_v3(color_f, color_f);
         rgba_float_to_uchar((unsigned char *)&color_b, color_f);
-        ((unsigned char *)&color_b)[3] *= br->alpha;
+        ((unsigned char *)&color_b)[3] *= brush_alpha;
         IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
                              (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
                              (unsigned char *)&color_b,
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index bb7340b95b0..55779ad61b0 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5293,7 +5293,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool),
               }
             }
             BKE_colorband_evaluate(brush->gradient, f, color_f);
-            color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha;
+            color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f) * brush_alpha;
 
             if (is_floatbuf) {
               /* convert to premultipied */
@@ -5321,7 +5321,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool),
           else {
             if (is_floatbuf) {
               float newColor_f[4];
-              newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha;
+              newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush_alpha;
               copy_v3_v3(newColor_f, ps->paint_color_linear);
 
               IMB_blend_color_float(
@@ -5329,7 +5329,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool),
             }
             else {
               float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
-              projPixel->newColor.ch[3] = mask * 255 * brush->alpha;
+              projPixel->newColor.ch[3] = mask * 255 * brush_alpha;
 
               rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color);
               IMB_blend_color_byte(projPixel->pixel.ch_pt,



More information about the Bf-blender-cvs mailing list