Fix T37359: Dynamic Paint deletes inactive texture from smoke domain when using a material as brush color

This commit is contained in:
Miika Hamalainen 2013-11-22 15:25:19 +02:00
parent 885354daec
commit 5feb0d2bfe
Notes: blender-bot 2023-02-14 11:38:05 +01:00
Referenced by issue #37359, Dynamic Paint delete texture from smoke domain
1 changed files with 8 additions and 4 deletions

View File

@ -3558,12 +3558,15 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
/* strip material copy from unsupported flags */
for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
if (mat->septex & (1<<tex_nr)) continue;
if (mat->mtex[tex_nr]) {
MTex *mtex = mat->mtex[tex_nr];
if (!mtex->tex) continue;
/* just in case make all non-used mtexes empty*/
Tex *cur_tex = mtex->tex;
mtex->tex = NULL;
if (mat->septex & (1<<tex_nr) || !cur_tex) continue;
/* only keep compatible texflags */
mtex->texflag = mtex->texflag & (MTEX_RGBTOINT | MTEX_STENCIL | MTEX_NEGATIVE | MTEX_ALPHAMIX);
@ -3598,7 +3601,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
}
/* copy texture */
tex= mtex->tex = localize_texture(mtex->tex);
tex= mtex->tex = localize_texture(cur_tex);
/* update texture anims */
BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
@ -3646,7 +3649,8 @@ void RE_free_sample_material(Material *mat)
}
}
BKE_material_free(mat);
/* don't update user counts as we are freeing a duplicate */
BKE_material_free_ex(mat, false);
MEM_freeN(mat);
}