Page MenuHome

T40388
ActivePublic

Authored by Bastien Montagne (mont29) on May 27 2014, 5:15 PM.
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 4fff501..37bd5fe 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -705,6 +705,10 @@ MTex *add_mtex_id(ID *id, int slot)
MEM_freeN(mtex_ar[slot]);
mtex_ar[slot] = NULL;
}
+ else if (GS(id->name) == ID_MA) {
+ /* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
+ ((Material *)id)->septex |= (1 << slot);
+ }
mtex_ar[slot] = add_mtex();
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 4166a52..79ab300 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -449,6 +449,13 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
* pointer se also increases user, so this compensates it */
tex->id.us--;
+ if (ptr.id.data && GS(((ID *)ptr.id.data)->name) == ID_MA &&
+ RNA_property_pointer_get(&ptr, prop).id.data == NULL) {
+ /* In case we are assigning new texture to a material, and active slot was empty, reset 'use' flag. */
+ Material *ma = (Material *)ptr.id.data;
+ ma->septex &= ~(1 << ma->texact);
+ }
+
RNA_id_pointer_create(&tex->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);

Event Timeline

Bastien Montagne (mont29) changed the title of this paste from untitled to T40388.
Bastien Montagne (mont29) updated the paste's language from autodetect to diff.