Bugfix: texture paint brushes didn't work correct with multiple
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Feb 2007 15:08:53 +0000 (15:08 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Feb 2007 15:08:53 +0000 (15:08 +0000)
texture channels.

source/blender/blenkernel/intern/brush.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_shading.c
source/blender/src/drawimage.c

index 53fdb2ac1158c3797cec1cdb76eba7b68750bead..b9687af3a20410586999eb003fec1cb5a18f5e09 100644 (file)
@@ -330,7 +330,9 @@ float brush_sample_falloff(Brush *brush, float dist)
 
 void brush_sample_tex(Brush *brush, float *xy, float *rgba)
 {
-       if (brush->mtex[0] && brush->mtex[0]->tex) {
+       MTex *mtex= brush->mtex[brush->texact];
+
+       if (mtex && mtex->tex) {
                float co[3], tin, tr, tg, tb, ta;
                int hasrgb;
                
@@ -338,7 +340,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba)
                co[1]= xy[1]/(brush->size >> 1);
                co[2]= 0.0f;
 
-               hasrgb= externtex(brush->mtex[0], co, &tin, &tr, &tg, &tb, &ta);
+               hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
 
                if (hasrgb) {
                        rgba[0]= tr;
@@ -686,6 +688,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
 {
        Brush *brush= painter->brush;
        BrushPainterCache *cache= &painter->cache;
+       MTex *mtex= brush->mtex[brush->texact];
        int size;
        short flt;
 
@@ -703,7 +706,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
                flt= cache->flt;
                size= (cache->size)? cache->size: brush->size;
 
-               if (!(brush->mtex[0] && brush->mtex[0]->tex) || (brush->mtex[0]->tex->type==0)) {
+               if (!(mtex && mtex->tex) || (mtex->tex->type==0)) {
                        brush_imbuf_new(brush, flt, 0, size, &cache->ibuf);
                }
                else if (brush->flag & BRUSH_FIXED_TEX) {
@@ -717,7 +720,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
                cache->lastalpha= brush->alpha;
                cache->lastinnerradius= brush->innerradius;
        }
-       else if ((brush->flag & BRUSH_FIXED_TEX) && brush->mtex[0] && brush->mtex[0]->tex) {
+       else if ((brush->flag & BRUSH_FIXED_TEX) && mtex && mtex->tex) {
                int dx = (int)painter->lastpaintpos[0] - (int)pos[0];
                int dy = (int)painter->lastpaintpos[1] - (int)pos[1];
 
index 52acf7b662f455bd27897fbddcb5001e4acb075a..94d294d25043c333c27ab1fcba5bf4e5081fa9e5 100644 (file)
@@ -5020,6 +5020,8 @@ static void editing_panel_mesh_paint(void)
                uiBlockSetCol(block, TH_AUTO);
 
                if(brush && !brush->id.lib) {
+                       MTex *mtex= brush->mtex[brush->texact];
+
                        butw= 320-(xco+10);
 
                        uiDefButS(block, MENU, B_NOP, "Mix %x0|Add %x1|Subtract %x2|Multiply %x3|Lighten %x4|Darken %x5|Erase Alpha %x6|Add Alpha %x7", xco+10,yco,butw,19, &brush->blend, 0, 0, 0, 0, "Blending method for applying brushes");
@@ -5048,7 +5050,7 @@ static void editing_panel_mesh_paint(void)
                        yco -= 110;
 
                        uiBlockSetCol(block, TH_BUT_SETTING2);
-                       id= (brush->mtex[0])? (ID*)brush->mtex[0]->tex: NULL;
+                       id= (mtex)? (ID*)mtex->tex: NULL;
                        xco= std_libbuttons(block, 0, yco, 0, NULL, B_BTEXBROWSE, ID_TE, 0, id, NULL, &(G.buts->menunr), 0, 0, B_BTEXDELETE, 0, 0);
                        /*uiDefButBitS(block, TOG|BIT, BRUSH_FIXED_TEX, B_BRUSHCHANGE, "Fixed", xco+5,yco,butw,19, &brush->flag, 0, 0, 0, 0, "Keep texture origin in fixed position");*/
                        uiBlockSetCol(block, TH_AUTO);
index 514c54a175935a98cfd0628480086a77d765df3e..51e29f623bd178e5d95dc7b0d170c02c0f600a6c 100644 (file)
@@ -270,6 +270,8 @@ void do_texbuts(unsigned short event)
                scrarea_queue_headredraw(curarea);
                BIF_preview_changed(ID_TE);
                allqueue(REDRAWBUTSSHADING, 0);
+               if(G.buts->texfrom == 3) /* brush texture */
+                       allqueue(REDRAWIMAGE, 0);
                break;
        case B_TEXTYPE:
                if(tex==NULL) return;
index de80f5513a1c361e39b51c12a39e9db540c0ef17..119beb8981c6352bb604c033c920a4871fa979e5 100644 (file)
@@ -1022,8 +1022,10 @@ static void image_panel_paint(short cntrl)       // IMAGE_HANDLER_PAINT
                        }
                }
                else {
+                       MTex *mtex= brush->mtex[brush->texact];
+
                        uiBlockSetCol(block, TH_BUT_SETTING2);
-                       id= (brush->mtex[0])? (ID*)brush->mtex[0]->tex: NULL;
+                       id= (mtex)? (ID*)mtex->tex: NULL;
                        xco= std_libbuttons(block, 0, yco, 0, NULL, B_SIMABTEXBROWSE, ID_TE, 0, id, NULL, &(G.sima->menunr), 0, 0, B_SIMABTEXDELETE, 0, 0);
                        /*uiDefButBitS(block, TOG|BIT, BRUSH_FIXED_TEX, B_SIMABRUSHCHANGE, "Fixed",     xco+5,yco,butw,19, &brush->flag, 0, 0, 0, 0, "Keep texture origin in fixed position");*/
                        uiBlockSetCol(block, TH_AUTO);