예제 #1
0
/* texture copy without adding to main dbase */
Tex *localize_texture(Tex *tex)
{
	Tex *texn;
	
	texn= copy_libblock(tex);
	BLI_remlink(&G.main->tex, texn);
	
	/* image texture: free_texture also doesn't decrease */
	
	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);
		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);
	}
	
	texn->preview = NULL;
	
	if(tex->nodetree) {
		texn->nodetree= ntreeLocalize(tex->nodetree);
	}
	
	return texn;
}
예제 #2
0
파일: lamp.c 프로젝트: mik0001/Blender
Lamp *localize_lamp(Lamp *la)
{
	Lamp *lan;
	int a;
	
	lan= copy_libblock(&la->id);
	BLI_remlink(&G.main->lamp, lan);

	for(a=0; a<MAX_MTEX; a++) {
		if(lan->mtex[a]) {
			lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
			memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
			/* free lamp decrements */
			id_us_plus((ID *)lan->mtex[a]->tex);
		}
	}
	
	lan->curfalloff = curvemapping_copy(la->curfalloff);

	if(la->nodetree)
		lan->nodetree= ntreeLocalize(la->nodetree);
	
	lan->preview= NULL;
	
	return lan;
}
예제 #3
0
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;
}
예제 #4
0
파일: lamp.c 프로젝트: mik0001/Blender
Lamp *copy_lamp(Lamp *la)
{
	Lamp *lan;
	int a;
	
	lan= copy_libblock(&la->id);

	for(a=0; a<MAX_MTEX; a++) {
		if(lan->mtex[a]) {
			lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
			memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
			id_us_plus((ID *)lan->mtex[a]->tex);
		}
	}
	
	lan->curfalloff = curvemapping_copy(la->curfalloff);

	if(la->nodetree)
		lan->nodetree= ntreeCopyTree(la->nodetree);
	
	if(la->preview)
		lan->preview = BKE_previewimg_copy(la->preview);
	
	return lan;
}
예제 #5
0
파일: material.c 프로젝트: BHCLL/blendocv
/* XXX (see above) material copy without adding to main dbase */
Material *localize_material(Material *ma)
{
	Material *man;
	int a;
	
	man= copy_libblock(ma);
	BLI_remlink(&G.main->mat, man);

	/* no increment for texture ID users, in previewrender.c it prevents decrement */
	for(a=0; a<MAX_MTEX; a++) {
		if(ma->mtex[a]) {
			man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
			memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
		}
	}
	
	if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
	if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
	
	man->preview = NULL;
	
	if(ma->nodetree)
		man->nodetree= ntreeLocalize(ma->nodetree);
	
	man->gpumaterial.first= man->gpumaterial.last= NULL;
	
	return man;
}
예제 #6
0
파일: material.c 프로젝트: BHCLL/blendocv
/* XXX keep synced with next function */
Material *copy_material(Material *ma)
{
	Material *man;
	int a;
	
	man= copy_libblock(ma);
	
	id_lib_extern((ID *)man->group);
	
	for(a=0; a<MAX_MTEX; a++) {
		if(ma->mtex[a]) {
			man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
			memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
			id_us_plus((ID *)man->mtex[a]->tex);
		}
	}
	
	if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
	if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
	
	if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);

	if(ma->nodetree) {
		man->nodetree= ntreeCopyTree(ma->nodetree);	/* 0 == full new tree */
	}

	man->gpumaterial.first= man->gpumaterial.last= NULL;
	
	return man;
}
예제 #7
0
Camera *copy_camera(Camera *cam)
{
	Camera *camn;
	
	camn= copy_libblock(&cam->id);

	id_lib_extern((ID *)camn->dof_ob);

	return camn;
}
예제 #8
0
파일: speaker.c 프로젝트: BHCLL/blendocv
Speaker *copy_speaker(Speaker *spk)
{
	Speaker *spkn;

	spkn= copy_libblock(spk);
	if(spkn->sound)
		spkn->sound->id.us++;

	return spkn;
}
예제 #9
0
Lattice *copy_lattice(Lattice *lt)
{
	Lattice *ltn;

	ltn= copy_libblock(lt);
	ltn->def= MEM_dupallocN(lt->def);

	ltn->key= copy_key(ltn->key);
	if(ltn->key) ltn->key->from= (ID *)ltn;
	
	if(lt->dvert) {
		int tot= lt->pntsu*lt->pntsv*lt->pntsw;
		ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
		copy_dverts(ltn->dvert, lt->dvert, tot);
	}

	ltn->editlatt= NULL;

	return ltn;
}
예제 #10
0
Mesh *copy_mesh(Mesh *me)
{
	Mesh *men;
	MTFace *tface;
	int a, i;
	
	men= copy_libblock(me);
	
	men->mat= MEM_dupallocN(me->mat);
	for(a=0; a<men->totcol; a++) {
		id_us_plus((ID *)men->mat[a]);
	}
	id_us_plus((ID *)men->texcomesh);

	CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert);
	CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge);
	CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH, CD_DUPLICATE, men->totface);
	mesh_update_customdata_pointers(men);

	/* ensure indirect linked data becomes lib-extern */
	for(i=0; i<me->fdata.totlayer; i++) {
		if(me->fdata.layers[i].type == CD_MTFACE) {
			tface= (MTFace*)me->fdata.layers[i].data;

			for(a=0; a<me->totface; a++, tface++)
				if(tface->tpage)
					id_lib_extern((ID*)tface->tpage);
		}
	}
	
	men->mselect= NULL;
	men->edit_mesh= NULL;
	men->pv= NULL; /* looks like this is no-longer supported but NULL just incase */

	men->bb= MEM_dupallocN(men->bb);
	
	men->key= copy_key(me->key);
	if(men->key) men->key->from= (ID *)men;

	return men;
}
예제 #11
0
bAction *copy_action (bAction *src)
{
	bAction *dst = NULL;
	bActionGroup *dgrp, *sgrp;
	FCurve *dfcu, *sfcu;
	
	if (src == NULL) 
		return NULL;
	dst= copy_libblock(src);
	
	/* duplicate the lists of groups and markers */
	BLI_duplicatelist(&dst->groups, &src->groups);
	BLI_duplicatelist(&dst->markers, &src->markers);
	
	/* copy F-Curves, fixing up the links as we go */
	dst->curves.first= dst->curves.last= NULL;
	
	for (sfcu= src->curves.first; sfcu; sfcu= sfcu->next) {
		/* duplicate F-Curve */
		dfcu= copy_fcurve(sfcu);
		BLI_addtail(&dst->curves, dfcu);
		
		/* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
		for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && sgrp; dgrp=dgrp->next, sgrp=sgrp->next) {
			if (sfcu->grp == sgrp) {
				dfcu->grp= dgrp;
				
				if (dgrp->channels.first == sfcu)
					dgrp->channels.first= dfcu;
				if (dgrp->channels.last == sfcu)
					dgrp->channels.last= dfcu;
					
				break;
			}
		}
	}
	
	return dst;
}
예제 #12
0
파일: world.c 프로젝트: jinjoh/NOOR
World *copy_world(World *wrld)
{
	World *wrldn;
	int a;
	
	wrldn= copy_libblock(wrld);
	
	for(a=0; a<MAX_MTEX; a++) {
		if(wrld->mtex[a]) {
			wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
			memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
			id_us_plus((ID *)wrldn->mtex[a]->tex);
		}
	}
	
	if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview);

#if 0 // XXX old animation system
	id_us_plus((ID *)wrldn->ipo);
#endif // XXX old animation system
	
	return wrldn;
}
예제 #13
0
파일: brush.c 프로젝트: mik0001/Blender
Brush *copy_brush(Brush *brush)
{
	Brush *brushn;
	
	brushn= copy_libblock(&brush->id);

	if (brush->mtex.tex)
		id_us_plus((ID*)brush->mtex.tex);

	if (brush->icon_imbuf)
		brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf);

	brushn->preview = NULL;

	brushn->curve= curvemapping_copy(brush->curve);

	/* enable fake user by default */
	if (!(brushn->id.flag & LIB_FAKEUSER)) {
		brushn->id.flag |= LIB_FAKEUSER;
		brushn->id.us++;
	}
	
	return brushn;
}