void make_local_mesh(Mesh *me) { Object *ob; Mesh *men; int local=0, lib=0; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ if(me->id.lib==0) return; if(me->id.us==1) { me->id.lib= 0; me->id.flag= LIB_LOCAL; new_id(0, (ID *)me, 0); if(me->mtface) make_local_tface(me); return; } ob= G.main->object.first; while(ob) { if( me==get_mesh(ob) ) { if(ob->id.lib) lib= 1; else local= 1; } ob= ob->id.next; } if(local && lib==0) { me->id.lib= 0; me->id.flag= LIB_LOCAL; new_id(0, (ID *)me, 0); if(me->mtface) make_local_tface(me); } else if(local && lib) { men= copy_mesh(me); men->id.us= 0; ob= G.main->object.first; while(ob) { if( me==get_mesh(ob) ) { if(ob->id.lib==0) { set_mesh(ob, men); } } ob= ob->id.next; } } }
static void expand_local_mesh(Main *bmain, Mesh *me) { id_lib_extern((ID *)me->texcomesh); if(me->mtface) { /* why is this an exception? - should not really make local when extern'ing - campbell */ make_local_tface(bmain, me); } if(me->mat) { extern_local_matarar(me->mat, me->totcol); } }