Texture paint system:
authorAntony Riakiotakis <kalast@gmail.com>
Thu, 28 Aug 2014 13:48:26 +0000 (15:48 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Thu, 28 Aug 2014 13:50:42 +0000 (15:50 +0200)
* Add ability to choose blend type and enable/disable toggle for each
slot for blender internal.

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

index 31e7f60677077903abdf6817b0c4e54494a14fc2..59c68fc615d72501a1576a5c03a46a17111081e1 100644 (file)
@@ -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="")
index 7565703358e0de9bed3bcc517c92111ad70f42c9..50147149b0c7b78deeebb081155e20845acb73b5 100644 (file)
@@ -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++;
                        }
index f24c6888201fb8db100c5530cf8adc95748321de..9362510a84dc6ac03f0ea50b22120c54d25af4d3 100644 (file)
@@ -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;
 }
 
 
index bd791c9c0060558dba29a0af76206129a1ac8946..3f94a9cfebb12f99ae54df36fb1bef74e5045c72 100644 (file)
@@ -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 {
index 4031c70a7ef5c5341867b13e7720256f2e1d26b4..c395b963d489ed26521f0faf4e297bfbbbae91af 100644 (file)
@@ -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");
 }