/* texture copy without adding to main dbase */ Tex *localize_texture(Tex *tex) { Tex *texn; texn = BKE_libblock_copy(&tex->id); BLI_remlink(&G.main->tex, texn); /* image texture: BKE_texture_free also doesn't decrease */ if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); if (texn->env) { texn->env = BKE_copy_envmap(texn->env); id_us_min(&texn->env->ima->id); } if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); if (texn->vd) { texn->vd = MEM_dupallocN(texn->vd); if (texn->vd->dataset) texn->vd->dataset = MEM_dupallocN(texn->vd->dataset); } if (texn->ot) { texn->ot = BKE_copy_oceantex(tex->ot); } texn->preview = NULL; if (tex->nodetree) { texn->nodetree = ntreeLocalize(tex->nodetree); } return texn; }
Tex *copy_texture(Tex *tex) { Tex *texn; texn= copy_libblock(tex); if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); else texn->ima= NULL; if(texn->plugin) { texn->plugin= MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); if(texn->env) texn->env= BKE_copy_envmap(texn->env); if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); if(texn->vd) texn->vd= MEM_dupallocN(texn->vd); if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if(tex->nodetree) { if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata); } texn->nodetree= ntreeCopyTree(tex->nodetree); } return texn; }
Tex *BKE_texture_copy(Tex *tex) { Tex *texn; texn = BKE_libblock_copy(&tex->id); if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima); else texn->ima = NULL; if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); if (texn->env) texn->env = BKE_copy_envmap(texn->env); if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); if (texn->vd) texn->vd = MEM_dupallocN(texn->vd); if (texn->ot) texn->ot = BKE_copy_oceantex(texn->ot); if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if (tex->nodetree) { if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata); } texn->nodetree = ntreeCopyTree(tex->nodetree); } return texn; }