From 512b7383525d7b9ccdca93816a08a579db148f23 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 28 Aug 2014 15:48:26 +0200 Subject: Texture paint system: * Add ability to choose blend type and enable/disable toggle for each slot for blender internal. --- source/blender/blenkernel/intern/material.c | 2 +- .../editors/sculpt_paint/paint_image_proj.c | 28 ++++++++-------------- source/blender/makesdna/DNA_material_types.h | 5 ++-- source/blender/makesrna/intern/rna_material.c | 5 ++-- 4 files changed, 17 insertions(+), 23 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 7565703358e..50147149b0c 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 f24c6888201..9362510a84d 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 bd791c9c006..3f94a9cfebb 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 4031c70a7ef..c395b963d48 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"); } -- cgit v1.2.3