Beispiel #1
0
void make_local_speaker(Speaker *spk)
{
	Main *bmain= G.main;
	Object *ob;
	int local=0, lib=0;

	/* - only lib users: do nothing
		* - only local users: set flag
		* - mixed: make copy
		*/

	if(spk->id.lib==NULL) return;
	if(spk->id.us==1) {
		spk->id.lib= NULL;
		spk->id.flag= LIB_LOCAL;
		new_id(&bmain->speaker, (ID *)spk, NULL);
		return;
	}

	ob= bmain->object.first;
	while(ob) {
		if(ob->data==spk) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
		ob= ob->id.next;
	}

	if(local && lib==0) {
		spk->id.lib= NULL;
		spk->id.flag= LIB_LOCAL;
		new_id(&bmain->speaker, (ID *)spk, NULL);
	}
	else if(local && lib) {
		Speaker *spkn= copy_speaker(spk);
		spkn->id.us= 0;

		ob= bmain->object.first;
		while(ob) {
			if(ob->data==spk) {

				if(ob->id.lib==NULL) {
					ob->data= spkn;
					spkn->id.us++;
					spk->id.us--;
				}
			}
			ob= ob->id.next;
		}
	}
}
Beispiel #2
0
void make_local_speaker(Speaker *spk)
{
	Main *bmain= G.main;
	Object *ob;
	int is_local= FALSE, is_lib= FALSE;

	/* - only lib users: do nothing
		* - only local users: set flag
		* - mixed: make copy
		*/

	if(spk->id.lib==NULL) return;
	if(spk->id.us==1) {
		id_clear_lib_data(bmain, &spk->id);
		return;
	}

	ob= bmain->object.first;
	while(ob) {
		if(ob->data==spk) {
			if(ob->id.lib) is_lib= TRUE;
			else is_local= TRUE;
		}
		ob= ob->id.next;
	}

	if(is_local && is_lib == FALSE) {
		id_clear_lib_data(bmain, &spk->id);
	}
	else if(is_local && is_lib) {
		Speaker *spk_new= copy_speaker(spk);
		spk_new->id.us= 0;

		/* Remap paths of new ID using old library as base. */
		BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id);

		ob= bmain->object.first;
		while(ob) {
			if(ob->data==spk) {

				if(ob->id.lib==NULL) {
					ob->data= spk_new;
					spk_new->id.us++;
					spk->id.us--;
				}
			}
			ob= ob->id.next;
		}
	}
}
Beispiel #3
0
int id_copy(ID *id, ID **newid, int test)
{
	if(!test) *newid= NULL;

	/* conventions:
	 * - make shallow copy, only this ID block
	 * - id.us of the new ID is set to 1 */
	switch(GS(id->name)) {
		case ID_SCE:
			return 0; /* can't be copied from here */
		case ID_LI:
			return 0; /* can't be copied from here */
		case ID_OB:
			if(!test) *newid= (ID*)copy_object((Object*)id);
			return 1;
		case ID_ME:
			if(!test) *newid= (ID*)copy_mesh((Mesh*)id);
			return 1;
		case ID_CU:
			if(!test) *newid= (ID*)copy_curve((Curve*)id);
			return 1;
		case ID_MB:
			if(!test) *newid= (ID*)copy_mball((MetaBall*)id);
			return 1;
		case ID_MA:
			if(!test) *newid= (ID*)copy_material((Material*)id);
			return 1;
		case ID_TE:
			if(!test) *newid= (ID*)copy_texture((Tex*)id);
			return 1;
		case ID_IM:
			if(!test) *newid= (ID*)copy_image((Image*)id);
			return 1;
		case ID_LT:
			if(!test) *newid= (ID*)copy_lattice((Lattice*)id);
			return 1;
		case ID_LA:
			if(!test) *newid= (ID*)copy_lamp((Lamp*)id);
			return 1;
		case ID_SPK:
			if(!test) *newid= (ID*)copy_speaker((Speaker*)id);
			return 1;
		case ID_CA:
			if(!test) *newid= (ID*)copy_camera((Camera*)id);
			return 1;
		case ID_IP:
			return 0; /* deprecated */
		case ID_KE:
			if(!test) *newid= (ID*)copy_key((Key*)id);
			return 1;
		case ID_WO:
			if(!test) *newid= (ID*)copy_world((World*)id);
			return 1;
		case ID_SCR:
			return 0; /* can't be copied from here */
		case ID_VF:
			return 0; /* not implemented */
		case ID_TXT:
			if(!test) *newid= (ID*)copy_text((Text*)id);
			return 1;
		case ID_SCRIPT:
			return 0; /* deprecated */
		case ID_SO:
			return 0; /* not implemented */
		case ID_GR:
			if(!test) *newid= (ID*)copy_group((Group*)id);
			return 1;
		case ID_AR:
			if(!test) *newid= (ID*)copy_armature((bArmature*)id);
			return 1;
		case ID_AC:
			if(!test) *newid= (ID*)copy_action((bAction*)id);
			return 1;
		case ID_NT:
			if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id);
			return 1;
		case ID_BR:
			if(!test) *newid= (ID*)copy_brush((Brush*)id);
			return 1;
		case ID_PA:
			if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id);
			return 1;
		case ID_WM:
			return 0; /* can't be copied from here */
		case ID_GD:
			return 0; /* not implemented */
	}
	
	return 0;
}