Revision: 56986
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56986
Author:   psy-fi
Date:     2013-05-23 21:02:51 +0000 (Thu, 23 May 2013)
Log Message:
-----------
Fix #35426, masking works wrong in projection painting. When we don't
use tiling, we need to sample the mask texture when determining the
pixel masking.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c        
2013-05-23 20:20:24 UTC (rev 56985)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c        
2013-05-23 21:02:51 UTC (rev 56986)
@@ -248,7 +248,8 @@
        short is_ortho;
        bool do_masking;              /* use masking during painting. Some 
operations such as airbrush may disable */
        bool is_texbrush;              /* only to avoid running  */
-       bool is_maskbrush;
+       bool is_maskbrush;            /* mask brush is applied before masking */
+       bool is_maskbrush_tiled;      /* mask brush is applied after masking */
 #ifndef PROJ_DEBUG_NOSEAMBLEED
        float seam_bleed_px;
 #endif
@@ -3841,7 +3842,14 @@
                                                         * and never exceeds 
it, which gives nice smooth results. */
                                                        float mask_accum = 
projPixel->mask_accum;
 
-                                                       mask = mask_accum + 
(brush_alpha * 65535.0f - mask_accum) * mask;
+                                                       if (ps->is_maskbrush) {
+                                                               float texmask = 
BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, 
thread_index, pool);
+                                                               CLAMP(texmask, 
0.0, 1.0);
+                                                               mask = 
mask_accum + (brush_alpha * texmask * 65535.0f - mask_accum) * mask;
+                                                       }
+                                                       else {
+                                                               mask = 
mask_accum + (brush_alpha * 65535.0f - mask_accum) * mask;
+                                                       }
                                                        mask_short = (unsigned 
short)mask;
 
                                                        if (mask_short > 
projPixel->mask_accum) {
@@ -3853,8 +3861,9 @@
                                                                continue;
                                                        }
                                                }
-                                               else
+                                               else {
                                                        mask *= brush_alpha;
+                                               }
 
                                                if (ps->is_texbrush) {
                                                        MTex *mtex = 
&brush->mtex;
@@ -3877,7 +3886,7 @@
                                                        mask *= texrgba[3];
                                                }
 
-                                               if (ps->is_maskbrush) {
+                                               if (ps->is_maskbrush_tiled) {
                                                        mask *= 
BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, 
thread_index, pool);
                                                }
 
@@ -4099,13 +4108,23 @@
                                  (brush->mtex.tex && 
!ELEM3(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, 
MTEX_MAP_MODE_3D)))
                                 ? false : true;
                ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == 
PAINT_TOOL_DRAW) ? true : false;
-               ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
+               ps->is_maskbrush = false;
+               ps->is_maskbrush_tiled = false;
+               if (brush->mask_mtex.tex) {
+                       if (ELEM(brush->mask_mtex.brush_map_mode, 
MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_TILED)) {
+                               ps->is_maskbrush_tiled = true;
+                       }
+                       else {
+                               ps->is_maskbrush = true;
+                       }
+               }
        }
        else {
                /* brush may be NULL*/
                ps->do_masking = false;
                ps->is_texbrush = false;
                ps->is_maskbrush = false;
+               ps->is_maskbrush_tiled = false;
        }
 
        /* sizeof(ProjPixel), since we alloc this a _lot_ */
@@ -4290,6 +4309,7 @@
        /* override */
        ps.is_texbrush = false;
        ps.is_maskbrush = false;
+       ps.is_maskbrush_tiled = false;
        ps.do_masking = false;
        orig_brush_size = BKE_brush_size_get(scene, ps.brush);
        BKE_brush_size_set(scene, ps.brush, 32); /* cover the whole image */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to