Commit: 512b7383525d7b9ccdca93816a08a579db148f23
Author: Antony Riakiotakis
Date:   Thu Aug 28 15:48:26 2014 +0200
Branches: master
https://developer.blender.org/rB512b7383525d7b9ccdca93816a08a579db148f23

Texture paint system:

* Add ability to choose blend type and enable/disable toggle for each
slot for blender internal.

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/blenkernel/intern/material.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/makesdna/DNA_material_types.h
M       source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 31e7f60..59c68fc 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -994,11 +994,13 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
 
 class TEXTURE_UL_texpaintslots(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, 
active_propname, index):
-        # ma = data
-        ima = item
+        mat = data
 
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
+            if (not mat.use_nodes) and (context.scene.render.engine == 
'BLENDER_RENDER'):
+                mtex_index = mat.texture_paint_slots[index].index
+                layout.prop(mat, "use_textures", text="", index=mtex_index)
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
             layout.label(text="")
@@ -1045,6 +1047,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
                 if mat.texture_paint_slots:
                     slot = mat.texture_paint_slots[mat.paint_active_slot]
 
+                    col.prop(mat.texture_slots[slot.index], "blend_type")
                     col.separator()
                     col.label("UV Map")
                     col.prop_search(slot, "uv_layer", ob.data, "uv_textures", 
text="")
diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index 7565703..5014714 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1380,7 +1380,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, 
Material *ma)
                        if (get_mtex_slot_valid_texpaint(*mtex)) {
                                ma->texpaintslot[index].ima = (*mtex)->tex->ima;
                                ma->texpaintslot[index].uvname = 
(*mtex)->uvname;
-                               ma->texpaintslot[index].mtex = *mtex;
+                               ma->texpaintslot[index].index = i;
                                
                                index++;
                        }
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index f24c688..9362510 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4972,7 +4972,6 @@ static int 
texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator
        Material *ma;
        bool is_bi = BKE_scene_uses_blender_internal(scene);
        TexPaintSlot *slot;
-       int i;
        
        /* not supported for node-based engines */
        if (!ob || !is_bi)
@@ -4985,24 +4984,17 @@ static int 
texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator
        
        slot = ma->texpaintslot + ma->paint_active_slot;
        
-       /* find the material texture slot that corresponds to the current slot 
*/
-       for (i = 0; i < MAX_MTEX; i++) {
-               if (ma->mtex[i] == slot->mtex) {
-                       if (ma->mtex[i]->tex)
-                               id_us_min(&ma->mtex[i]->tex->id);
-                       MEM_freeN(ma->mtex[i]);
-                       ma->mtex[i] = NULL;
-                       
-                       BKE_texpaint_slot_refresh_cache(scene, ma);
-                       DAG_id_tag_update(&ma->id, 0);
-                       WM_event_add_notifier(C, NC_MATERIAL, 
CTX_data_scene(C));
-                       /* we need a notifier for data change since we change 
the displayed modifier uvs */
-                       WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);  
                
-                       return OPERATOR_FINISHED;
-               }
-       }
+       if (ma->mtex[slot->index]->tex)
+               id_us_min(&ma->mtex[slot->index]->tex->id);
+       MEM_freeN(ma->mtex[slot->index]);
+       ma->mtex[slot->index] = NULL;
        
-       return OPERATOR_CANCELLED;
+       BKE_texpaint_slot_refresh_cache(scene, ma);
+       DAG_id_tag_update(&ma->id, 0);
+       WM_event_add_notifier(C, NC_MATERIAL, CTX_data_scene(C));
+       /* we need a notifier for data change since we change the displayed 
modifier uvs */
+       WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);                  
+       return OPERATOR_FINISHED;
 }
 
 
diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index bd791c9..3f94a9c 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -85,8 +85,9 @@ typedef struct GameSettings {
 
 typedef struct TexPaintSlot {
        struct Image *ima; /* image to be painted on */
-       char *uvname; /* customdata index for uv layer, MAX_NAME*/
-       struct MTex *mtex; /* hook for blender internal materials. Not 
terribily nice, but serves for usability now  */
+       char *uvname;      /* customdata index for uv layer, MAX_NAME*/
+       int index;         /* index for mtex slot in material for blender 
internal */
+       int pad;
 } TexPaintSlot;
 
 typedef struct Material {
diff --git a/source/blender/makesrna/intern/rna_material.c 
b/source/blender/makesrna/intern/rna_material.c
index 4031c70..c395b96 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -2212,8 +2212,9 @@ static void rna_def_tex_slot(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
        RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update");
        
-       prop = RNA_def_property(srna, "mtex", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "MaterialTextureSlot");
+       prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Index", "Index of MTex slot in the 
material");
 }

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

Reply via email to