Commit: 203ec4c69b4bbd08db6ad98945bb26fcde83643f
Author: Darshan Kadu
Date:   Sun Aug 6 19:17:05 2017 +0530
Branches: soc-2017-vertex_paint
https://developer.blender.org/rB203ec4c69b4bbd08db6ad98945bb26fcde83643f

fixed texture painting brush issue

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

M       source/blender/editors/sculpt_paint/paint_vertex.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index e73090d6217..837bf037658 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -612,7 +612,7 @@ BLI_INLINE unsigned int mcol_blend(unsigned int col1, 
unsigned int col2, int fac
        cp[0] = lock->lock_red?    cp1[0] : (unsigned 
char)round(sqrt(divide_round_i((mfac * r1 + fac * r2), 255)));
        cp[1] = lock->lock_green ? cp1[1] : (unsigned 
char)round(sqrt(divide_round_i((mfac * g1 + fac * g2), 255)));
        cp[2] = lock->lock_blue ?  cp1[2] : (unsigned 
char)round(sqrt(divide_round_i((mfac * b1 + fac * b2), 255)));
-       cp[3] = lock->lock_alpha ? cp1[3] : (unsigned 
char)round(sqrt(divide_round_i((mfac * a1 + fac * a2), 255)));
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (unsigned 
char)round(sqrt(divide_round_i((mfac * a1 + fac * a2), 255))) : 255);
 
        return col;
 }
@@ -641,7 +641,7 @@ BLI_INLINE unsigned int mcol_add(unsigned int col1, 
unsigned int col2, int fac,
        temp = cp1[2] + divide_round_i((fac * cp2[2]), 255);
        cp[2] = lock->lock_blue ? cp1[2] : ((temp > 254) ? 255 : temp);
        temp = cp1[3] + divide_round_i((fac * cp2[3]), 255);
-       cp[3] = lock->lock_alpha ? cp1[3] : ((temp > 254) ? 255 : temp);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? ((temp > 254) ? 255 : 
temp) : 255);
        
        return col;
 }
@@ -670,7 +670,7 @@ BLI_INLINE unsigned int mcol_sub(unsigned int col1, 
unsigned int col2, int fac,
        temp = cp1[2] - divide_round_i((fac * cp2[2]), 255);
        cp[2] = lock->lock_blue ? cp1[2] : ((temp < 0) ? 0 : temp);
        temp = cp1[3] - divide_round_i((fac * cp2[3]), 255);
-       cp[3] = lock->lock_alpha ? cp1[3] : ((temp < 0) ? 0 : temp);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? ((temp < 0) ? 0 : 
temp) : 255);
 
        return col;
 }
@@ -698,7 +698,7 @@ BLI_INLINE unsigned int mcol_mul(unsigned int col1, 
unsigned int col2, int fac,
        cp[0] = lock->lock_red   ? cp1[0] : (divide_round_i(mfac * cp1[0] * 255 
+ fac * cp2[0] * cp1[0], 255 * 255));
        cp[1] = lock->lock_green ? cp1[1] : (divide_round_i(mfac * cp1[1] * 255 
+ fac * cp2[1] * cp1[1], 255 * 255));
        cp[2] = lock->lock_blue  ? cp1[2] : (divide_round_i(mfac * cp1[2] * 255 
+ fac * cp2[2] * cp1[2], 255 * 255));
-       cp[3] = lock->lock_alpha ? cp1[3] : (divide_round_i(mfac * cp1[3] * 255 
+ fac * cp2[3] * cp1[3], 255 * 255));
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (divide_round_i(mfac * 
cp1[3] * 255 + fac * cp2[3] * cp1[3], 255 * 255)) : 255);
 
        return col;
 }
@@ -736,7 +736,7 @@ BLI_INLINE unsigned int mcol_lighten(unsigned int col1, 
unsigned int col2, int f
        cp[0] = lock->lock_red   ? cp1[0] : (divide_round_i(mfac * cp1[0] + fac 
* cp2[0], 255));
        cp[1] = lock->lock_green ? cp1[2] : (divide_round_i(mfac * cp1[1] + fac 
* cp2[1], 255));
        cp[2] = lock->lock_blue  ? cp1[3] : (divide_round_i(mfac * cp1[2] + fac 
* cp2[2], 255));
-       cp[3] = lock->lock_alpha ? cp1[4] : (divide_round_i(mfac * cp1[3] + fac 
* cp2[3], 255));
+       cp[3] = lock->lock_alpha ? cp1[4] : (use_alpha ? (divide_round_i(mfac * 
cp1[3] + fac * cp2[3], 255)) : 255);
 
        return col;
 }
@@ -779,7 +779,7 @@ BLI_INLINE unsigned int mcol_darken(unsigned int col1, 
unsigned int col2, int fa
        cp[0] = lock->lock_red   ? cp1[0] : (divide_round_i((mfac * cp1[0] + 
fac * cp2[0]), 255));
        cp[1] = lock->lock_green ? cp1[1] : (divide_round_i((mfac * cp1[1] + 
fac * cp2[1]), 255));
        cp[2] = lock->lock_blue  ? cp1[2] : (divide_round_i((mfac * cp1[2] + 
fac * cp2[2]), 255));
-       cp[3] = lock->lock_alpha ? cp1[3] : (divide_round_i((mfac * cp1[3] + 
fac * cp2[3]), 255));
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (divide_round_i((mfac 
* cp1[3] + fac * cp2[3]), 255)) : 255);
        return col;
 }
 
@@ -809,7 +809,7 @@ BLI_INLINE unsigned int mcol_colordodge(unsigned int col1, 
unsigned int col2, in
        temp = (cp2[2] == 255) ? 255 : min_ii((cp1[2] * 225 )/ (255 - cp2[2]), 
255);
        cp[2] = lock->lock_blue ? cp1[2] : ((mfac * cp1[2] + temp * fac) / 255);
        temp = (cp2[3] == 255) ? 255 : min_ii((cp1[3] * 225) / (255 - cp2[3]), 
255);
-       cp[3] = lock->lock_alpha ? cp1[3] : ((mfac * cp1[3] + temp * fac) / 
255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? ((mfac * cp1[3] + temp 
* fac) / 255) : 255);
        return col;
 }
 
@@ -839,7 +839,7 @@ BLI_INLINE unsigned int mcol_difference(unsigned int col1, 
unsigned int col2, in
        temp = abs(cp1[2] - cp2[2]);
        cp[2] = lock->lock_blue  ? cp1[2] : ((mfac * cp1[2] + temp * fac) / 
255);
        temp = abs(cp1[3] - cp2[3]);
-       cp[3] = lock->lock_alpha ? cp1[3] : ((mfac * cp1[3] + temp * fac) / 
255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? ((mfac * cp1[3] + temp 
* fac) / 255) : 255);
        return col;
 }
 
@@ -869,7 +869,7 @@ BLI_INLINE unsigned int mcol_screen(unsigned int col1, 
unsigned int col2, int fa
        temp = max_ii(255 - (((255 - cp1[2]) * (255 - cp2[2])) / 255), 0);
        cp[2] = lock->lock_blue  ? cp1[2] : ((mfac * cp1[2] + temp * fac) / 
255);
        temp = max_ii(255 - (((255 - cp1[3]) * (255 - cp2[3])) / 255), 0);
-       cp[3] = lock->lock_alpha ? cp1[3] : ((mfac * cp1[3] + temp * fac) / 
255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? ((mfac * cp1[3] + temp 
* fac) / 255) : 255);
        return col;
 }
 
@@ -897,6 +897,10 @@ BLI_INLINE unsigned int mcol_hardlight(unsigned int col1, 
unsigned int col2, int
        for (i = 0; i < 4; i++) {
                if ((&lock->lock_red)[i])
                        continue;
+               if (!use_alpha && i == 3) {
+                       cp[i] = 255;
+                       continue;
+               }
                if (cp2[i] > 127) {
                        temp = 255 - ((255 - 2 * (cp2[i] - 127)) * (255 - 
cp1[i]) / 255);
                }
@@ -933,6 +937,11 @@ BLI_INLINE unsigned int mcol_overlay(unsigned int col1, 
unsigned int col2, int f
                if ((&lock->lock_red)[i])
                        continue;
 
+               if (!use_alpha && i == 3) {
+                       cp[i] = 255;
+                       continue;
+               }
+
                if (cp1[i] > 127) {
                        temp = 255 - ((255 - 2 * (cp1[i] - 127)) * (255 - 
cp2[i]) / 255);
                }
@@ -969,6 +978,11 @@ BLI_INLINE unsigned int mcol_softlight(unsigned int col1, 
unsigned int col2, int
                if ((&lock->lock_red)[i])
                        continue;
 
+               if (!use_alpha && i == 3) {
+                       cp[i] = 255;
+                       continue;
+               }
+
                if (cp1[i] < 127) {
                        temp = ((2 * ((cp2[i] / 2) + 64)) * cp1[i]) / 255;
                }
@@ -1005,6 +1019,11 @@ BLI_INLINE unsigned int mcol_exclusion(unsigned int 
col1, unsigned int col2, int
                if ((&lock->lock_red)[i])
                        continue;
 
+               if (!use_alpha && i == 3) {
+                       cp[i] = 255;
+                       continue;
+               }
+
                temp = 127 - ((2 * (cp1[i] - 127) * (cp2[i] - 127)) / 255);
                cp[i] = (temp * fac + cp1[i] * mfac) / 255;
        }
@@ -1043,7 +1062,7 @@ BLI_INLINE unsigned int mcol_luminocity(unsigned int 
col1, unsigned int col2, in
        cp[0] = lock->lock_red   ? cp1[0] : (((int)(r * 255.0f) * fac + mfac * 
cp1[0]) / 255);
        cp[1] = lock->lock_green ? cp1[1] : (((int)(g * 255.0f) * fac + mfac * 
cp1[1]) / 255);
        cp[2] = lock->lock_blue  ? cp1[2] : (((int)(b * 255.0f) * fac + mfac * 
cp1[2]) / 255);
-       cp[3] = lock->lock_alpha ? cp1[3] : (((int)(cp2[3]) * fac + mfac * 
cp1[3]) / 255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (((int)(cp2[3]) * fac 
+ mfac * cp1[3]) / 255) : 255);
        return col;
 }
 
@@ -1081,7 +1100,7 @@ BLI_INLINE unsigned int mcol_saturation(unsigned int 
col1, unsigned int col2, in
        cp[0] = lock->lock_red   ? cp1[0] : (((int)(r * 255.0f) * fac + mfac * 
cp1[0]) / 255);
        cp[1] = lock->lock_green ? cp1[1] : (((int)(g * 255.0f) * fac + mfac * 
cp1[1]) / 255);
        cp[2] = lock->lock_blue  ? cp1[2] : (((int)(b * 255.0f) * fac + mfac * 
cp1[2]) / 255);
-       cp[3] = lock->lock_alpha ? cp1[3] : (((int)(cp2[3]) * fac + mfac * 
cp1[3]) / 255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (((int)(cp2[3]) * fac 
+ mfac * cp1[3]) / 255) : 255);
        return col;
 }
 
@@ -1117,7 +1136,7 @@ BLI_INLINE unsigned int mcol_hue(unsigned int col1, 
unsigned int col2, int fac,
        cp[0] = lock->lock_red   ? cp1[0] : (((int)(r * 255.0f) * fac + mfac * 
cp1[0]) / 255);
        cp[1] = lock->lock_green ? cp1[1] : (((int)(g * 255.0f) * fac + mfac * 
cp1[1]) / 255);
        cp[2] = lock->lock_blue  ? cp1[2] : (((int)(b * 255.0f) * fac + mfac * 
cp1[2]) / 255);
-       cp[3] = lock->lock_alpha ? cp1[3] : (((int)(cp2[3]) * fac + mfac * 
cp1[3]) / 255);
+       cp[3] = lock->lock_alpha ? cp1[3] : (use_alpha ? (((int)(cp2[3]) * fac 
+ mfac * cp1[3]) / 255) : 255);
        return col;
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to