Fix T40388: 2.70a - Blender Render - Texture Stack - persistent checkbox state.
Reset 'use_texture' flag of a material tex slot when creating/assigning a texture to an empty slot.
This commit is contained in:
parent
a6005319a7
commit
4b15a54ede
Notes:
blender-bot
2023-02-14 10:35:17 +01:00
Referenced by issue #40388, 2.70a - Blender Render - Texture Stack - persistent checkbox state
|
@ -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();
|
||||
|
||||
|
@ -1174,8 +1178,11 @@ void set_current_material_texture(Material *ma, Tex *newtex)
|
|||
id_us_min(&tex->id);
|
||||
|
||||
if (newtex) {
|
||||
if (!ma->mtex[act])
|
||||
if (!ma->mtex[act]) {
|
||||
ma->mtex[act] = add_mtex();
|
||||
/* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
|
||||
ma->septex &= ~(1 << act);
|
||||
}
|
||||
|
||||
ma->mtex[act]->tex = newtex;
|
||||
id_us_plus(&newtex->id);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue