static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	uiBlock *block = uiLayoutGetBlock(layout);
	uiBut *but = (uiBut *)but_p;
	uiLayout *split, *column;
	NodeLinkArg *arg = (NodeLinkArg *)but->func_argN;
	bNodeSocket *sock = arg->sock;
	bNodeTreeType *ntreetype = arg->ntree->typeinfo;

	UI_block_flag_enable(block, UI_BLOCK_NO_FLIP);
	UI_block_layout_set_current(block, layout);
	split = uiLayoutSplit(layout, 0.0f, false);

	arg->bmain = bmain;
	arg->scene = scene;
	arg->layout = split;

	if (ntreetype && ntreetype->foreach_nodeclass)
		ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);

	column = uiLayoutColumn(split, false);
	UI_block_layout_set_current(block, column);

	if (sock->link) {
		uiItemL(column, IFACE_("Link"), ICON_NONE);
		but = block->buttons.last;
		but->drawflag = UI_BUT_TEXT_LEFT;

		but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
		               NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input"));
		UI_but_funcN_set(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE));

		but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
		               NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input"));
		UI_but_funcN_set(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT));
	}

	ui_node_menu_column(arg, NODE_CLASS_GROUP, N_("Group"));
}
Exemple #2
0
/**
 * Only copy internal data of Texture ID from source to already allocated/initialized destination.
 * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
 *
 * WARNING! This function will not handle ID user count!
 *
 * \param flag  Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
 */
void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag)
{
	/* We never handle usercount here for own data. */
	const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;

	if (!BKE_texture_is_image_user(tex_src)) {
		tex_dst->ima = NULL;
	}

	if (tex_dst->coba) {
		tex_dst->coba = MEM_dupallocN(tex_dst->coba);
	}
	if (tex_dst->env) {
		tex_dst->env = BKE_texture_envmap_copy(tex_dst->env, flag_subdata);
	}
	if (tex_dst->pd) {
		tex_dst->pd = BKE_texture_pointdensity_copy(tex_dst->pd, flag_subdata);
	}
	if (tex_dst->vd) {
		tex_dst->vd = MEM_dupallocN(tex_dst->vd);
	}
	if (tex_dst->ot) {
		tex_dst->ot = BKE_texture_ocean_copy(tex_dst->ot, flag_subdata);
	}

	if (tex_src->nodetree) {
		if (tex_src->nodetree->execdata) {
			ntreeTexEndExecTree(tex_src->nodetree->execdata);
		}
		/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
		 *       (see BKE_libblock_copy_ex()). */
		BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag, false);
	}

	if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
		BKE_previewimg_id_copy(&tex_dst->id, &tex_src->id);
	}
	else {
		tex_dst->preview = NULL;
	}
}
Exemple #3
0
BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state)
{
	BoidState *staten = MEM_dupallocN(state);

	BLI_duplicatelist(&staten->rules, &state->rules);
	BLI_duplicatelist(&staten->conditions, &state->conditions);
	BLI_duplicatelist(&staten->actions, &state->actions);

	staten->id = boids->last_state_id++;

	return staten;
}
Exemple #4
0
void BKE_displist_copy(ListBase *lbn, ListBase *lb)
{
	DispList *dln, *dl;

	BKE_displist_free(lbn);

	dl = lb->first;
	while (dl) {
		dln = MEM_dupallocN(dl);
		BLI_addtail(lbn, dln);
		dln->verts = MEM_dupallocN(dl->verts);
		dln->nors = MEM_dupallocN(dl->nors);
		dln->index = MEM_dupallocN(dl->index);

		if (dl->bevel_split) {
			dln->bevel_split = MEM_dupallocN(dl->bevel_split);
		}

		dl = dl->next;
	}
}
Exemple #5
0
static void *editLatt_to_undoLatt(void *edata)
{
	UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice");
	EditLatt *editlatt= (EditLatt *)edata;
	
	ult->def= MEM_dupallocN(editlatt->latt->def);
	ult->pntsu= editlatt->latt->pntsu;
	ult->pntsv= editlatt->latt->pntsv;
	ult->pntsw= editlatt->latt->pntsw;
	
	return ult;
}
Exemple #6
0
static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
{
	wmKeyMapDiffItem *kmdin = MEM_dupallocN(kmdi);

	kmdin->next = kmdin->prev = NULL;
	if(kmdi->add_item)
		kmdin->add_item = wm_keymap_item_copy(kmdi->add_item);
	if(kmdi->remove_item)
		kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item);
	
	return kmdin;
}
Exemple #7
0
EnvMap *BKE_copy_envmap(EnvMap *env)
{
	EnvMap *envn;
	int a;
	
	envn = MEM_dupallocN(env);
	envn->ok = 0;
	for (a = 0; a < 6; a++) envn->cube[a] = NULL;
	if (envn->ima) id_us_plus((ID *)envn->ima);
	
	return envn;
}
Exemple #8
0
static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p)
{
	Main *bmain= CTX_data_main(C);
	Scene *scene= CTX_data_scene(C);
	uiBlock *block = uiLayoutGetBlock(layout);
	uiBut *but = (uiBut*)but_p;
	uiLayout *split, *column;
	NodeLinkArg *arg = (NodeLinkArg*)but->func_argN;
	bNodeSocket *sock = arg->sock;
	bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type);

	uiBlockSetCurLayout(block, layout);
	split= uiLayoutSplit(layout, 0, 0);

	arg->bmain= bmain;
	arg->scene= scene;
	arg->layout= split;
	
	if (ntreetype && ntreetype->foreach_nodeclass)
		ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);

	column= uiLayoutColumn(split, 0);
	uiBlockSetCurLayout(block, column);

	if (sock->link) {
		uiItemL(column, "Link", ICON_NONE);
		but= block->buttons.last;
		but->flag= UI_TEXT_LEFT;

		but = uiDefBut(block, BUT, 0, "Remove", 0, 0, UI_UNIT_X*4, UI_UNIT_Y,
			NULL, 0.0, 0.0, 0.0, 0.0, "Remove nodes connected to the input");
		uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE));

		but = uiDefBut(block, BUT, 0, "Disconnect", 0, 0, UI_UNIT_X*4, UI_UNIT_Y,
			NULL, 0.0, 0.0, 0.0, 0.0, "Disconnect nodes connected to the input");
		uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT));
	}

	ui_node_menu_column(arg, NODE_CLASS_GROUP, IFACE_("Group"));
}
Exemple #9
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->bb= MEM_dupallocN(men->bb);
	
	men->key= copy_key(me->key);
	if(men->key) men->key->from= (ID *)men;

	return men;
}
Exemple #10
0
static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height)
{
	Brush *brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
	ImBuf *ibuf;
	unsigned int size, alpha;
	unsigned char *display_buffer;
	unsigned char *rect, *cp;
	void *cache_handle;

	if (!brush || !brush->clone.image)
		return NULL;
	
	ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL);

	if (!ibuf)
		return NULL;

	display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);

	if (!display_buffer) {
		BKE_image_release_ibuf(brush->clone.image, ibuf, NULL);
		IMB_display_buffer_release(cache_handle);

		return NULL;
	}

	rect = MEM_dupallocN(display_buffer);

	IMB_display_buffer_release(cache_handle);

	if (!rect) {
		BKE_image_release_ibuf(brush->clone.image, ibuf, NULL);
		return NULL;
	}

	*width = ibuf->x;
	*height = ibuf->y;

	size = (*width) * (*height);
	alpha = (unsigned char)255 * brush->clone.alpha;
	cp = rect;

	while (size-- > 0) {
		cp[3] = alpha;
		cp += 4;
	}

	BKE_image_release_ibuf(brush->clone.image, ibuf, NULL);

	return rect;
}
Exemple #11
0
/* texture copy without adding to main dbase */
Tex *BKE_texture_localize(Tex *tex)
{
	/* TODO replace with something like
	 * 	Tex *tex_copy;
	 * 	BKE_id_copy_ex(bmain, &tex->id, (ID **)&tex_copy, LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, false);
	 * 	return tex_copy;
	 *
	 * ... Once f*** nodes are fully converted to that too :( */

	Tex *texn;
	
	texn = BKE_libblock_copy_nolib(&tex->id, false);
	
	/* image texture: BKE_texture_free also doesn't decrease */
	
	if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
	if (texn->env) {
		texn->env = BKE_texture_envmap_copy(texn->env, LIB_ID_CREATE_NO_USER_REFCOUNT);
		id_us_min(&texn->env->ima->id);
	}
	if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd, LIB_ID_CREATE_NO_USER_REFCOUNT);
	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_texture_ocean_copy(tex->ot, LIB_ID_CREATE_NO_USER_REFCOUNT);
	}
	
	texn->preview = NULL;
	
	if (tex->nodetree) {
		texn->nodetree = ntreeLocalize(tex->nodetree);
	}
	
	return texn;
}
Exemple #12
0
void make_editLatt(Object *obedit)
{
	Lattice *lt= obedit->data;
	KeyBlock *actkey;

	free_editLatt(obedit);

	actkey= ob_get_keyblock(obedit);
	if(actkey)
		key_to_latt(actkey, lt);

	lt->editlatt= MEM_callocN(sizeof(EditLatt), "editlatt");
	lt->editlatt->latt= MEM_dupallocN(lt);
	lt->editlatt->latt->def= MEM_dupallocN(lt->def);

	if(lt->dvert) {
		int tot= lt->pntsu*lt->pntsv*lt->pntsw;
		lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
		copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot);
	}

	if(lt->key) lt->editlatt->shapenr= obedit->shapenr;
}
Exemple #13
0
struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *rectf,
                                  unsigned int w, unsigned int h)
{
    ImBuf *ibuf = NULL;

    if (!(rect || rectf))
        return NULL;

    ibuf = IMB_allocImBuf(w, h, 32, 0);

    if (rectf) {
        ibuf->rect_float = MEM_dupallocN(rectf);
        ibuf->flags |= IB_rectfloat;
        ibuf->mall |= IB_rectfloat;
    }
    if (rect) {
        ibuf->rect = MEM_dupallocN(rect);
        ibuf->flags |= IB_rect;
        ibuf->mall |= IB_rect;
    }

    return ibuf;
}
static void copyData(ModifierData *md, ModifierData *target)
{
	CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
	CorrectiveSmoothModifierData *tcsmd = (CorrectiveSmoothModifierData *)target;

	modifier_copyData_generic(md, target);

	if (csmd->bind_coords) {
		tcsmd->bind_coords = MEM_dupallocN(csmd->bind_coords);
	}

	tcsmd->delta_cache = NULL;
	tcsmd->delta_cache_num = 0;
}
Exemple #15
0
void ED_lattice_editlatt_make(Object *obedit)
{
	Lattice *lt = obedit->data;
	KeyBlock *actkey;

	ED_lattice_editlatt_free(obedit);

	actkey = BKE_keyblock_from_object(obedit);
	if (actkey)
		BKE_keyblock_convert_to_lattice(actkey, lt);

	lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt");
	lt->editlatt->latt = MEM_dupallocN(lt);
	lt->editlatt->latt->def = MEM_dupallocN(lt->def);

	if (lt->dvert) {
		int tot = lt->pntsu * lt->pntsv * lt->pntsw;
		lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
		BKE_defvert_array_copy(lt->editlatt->latt->dvert, lt->dvert, tot);
	}

	if (lt->key) lt->editlatt->shapenr = obedit->shapenr;
}
Exemple #16
0
/* Make a copy of the specified F-Modifier */
FModifier *copy_fmodifier(FModifier *src)
{
	FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src);
	FModifier *dst;
	
	/* sanity check */
	if (src == NULL)
		return NULL;
		
	/* copy the base data, clearing the links */
	dst = MEM_dupallocN(src);
	dst->next = dst->prev = NULL;
	
	/* make a new copy of the F-Modifier's data */
	dst->data = MEM_dupallocN(src->data);
	
	/* only do specific constraints if required */
	if (fmi && fmi->copy_data)
		fmi->copy_data(dst, src);
		
	/* return the new modifier */
	return dst;
}
Exemple #17
0
/**
 * Allocate a new pose on the heap, and copy the src pose and it's channels
 * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
 *
 * \param dst  Should be freed already, makes entire duplicate.
 */
void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
{
	bPose *outPose;
	bPoseChannel *pchan;
	ListBase listb;

	if (!src) {
		*dst = NULL;
		return;
	}
	
	outPose = MEM_callocN(sizeof(bPose), "pose");
	
	BLI_duplicatelist(&outPose->chanbase, &src->chanbase);

	outPose->iksolver = src->iksolver;
	outPose->ikdata = NULL;
	outPose->ikparam = MEM_dupallocN(src->ikparam);
	outPose->avs = src->avs;
	
	for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {

		if (pchan->custom) {
			id_us_plus(&pchan->custom->id);
		}

		/* warning, O(n2) here, but it's a rarely used feature. */
		if (pchan->custom_tx) {
			pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
		}

		if (copy_constraints) {
			BKE_constraints_copy(&listb, &pchan->constraints, true);  // BKE_constraints_copy NULLs listb
			pchan->constraints = listb;
			pchan->mpath = NULL; /* motion paths should not get copied yet... */
		}
		
		if (pchan->prop) {
			pchan->prop = IDP_CopyProperty(pchan->prop);
		}
	}

	/* for now, duplicate Bone Groups too when doing this */
	if (copy_constraints) {
		BLI_duplicatelist(&outPose->agroups, &src->agroups);
	}
	
	*dst = outPose;
}
Exemple #18
0
void BLI_duplicatelist(ListBase *list1, ListBase *list2)  /* copy from 2 to 1 */
{
    struct Link *link1, *link2;

    /* in this order, to ensure it works if list1 == list2 */
    link2= list2->first;
    list1->first= list1->last= 0;

    while(link2) {
        link1= MEM_dupallocN(link2);
        BLI_addtail(list1, link1);

        link2= link2->next;
    }
}
Exemple #19
0
/**
 * Sets dst to a duplicate of the entire contents of src. dst may be the same as src.
 */
void BLI_duplicatelist(ListBase *dst, const ListBase *src)
{
	struct Link *dst_link, *src_link;

	/* in this order, to ensure it works if dst == src */
	src_link = src->first;
	dst->first = dst->last = NULL;

	while (src_link) {
		dst_link = MEM_dupallocN(src_link);
		BLI_addtail(dst, dst_link);

		src_link = src_link->next;
	}
}
void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata)
{
	MovieTrackingTrack new_track = *track;

	new_track.markers = MEM_dupallocN(new_track.markers);

	map->tracks[map->ptr] = new_track;

	if (customdata)
		memcpy(&map->customdata[map->ptr * map->customdata_size], customdata, map->customdata_size);

	BLI_ghash_insert(map->hash, &map->tracks[map->ptr], track);

	map->ptr++;
}
Exemple #21
0
static void undomball_to_editmball(UndoMBall *umb, MetaBall *mb)
{
  freeMetaElemlist(mb->editelems);
  mb->lastelem = NULL;

  /* copy 'undo' MetaElems to 'edit' MetaElems */
  int index = 0;
  for (MetaElem *ml_undo = umb->editelems.first; ml_undo; ml_undo = ml_undo->next, index += 1) {
    MetaElem *ml_edit = MEM_dupallocN(ml_undo);
    BLI_addtail(mb->editelems, ml_edit);
    if (index == umb->lastelem_index) {
      mb->lastelem = ml_edit;
    }
  }
}
Exemple #22
0
static void copyData(ModifierData *md, ModifierData *target)
{
	ClothModifierData *clmd = (ClothModifierData *) md;
	ClothModifierData *tclmd = (ClothModifierData *) target;

	if (tclmd->sim_parms) {
		if (tclmd->sim_parms->effector_weights)
			MEM_freeN(tclmd->sim_parms->effector_weights);
		MEM_freeN(tclmd->sim_parms);
	}

	if (tclmd->coll_parms)
		MEM_freeN(tclmd->coll_parms);
	
	BKE_ptcache_free_list(&tclmd->ptcaches);
	tclmd->point_cache = NULL;

	tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms);
	if (clmd->sim_parms->effector_weights)
		tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights);
	tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms);
	tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches);
	tclmd->clothObject = NULL;
}
Exemple #23
0
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;
}
Exemple #24
0
static void copyData(ModifierData *md, ModifierData *target)
{
	HookModifierData *hmd = (HookModifierData*) md;
	HookModifierData *thmd = (HookModifierData*) target;

	copy_v3_v3(thmd->cent, hmd->cent);
	thmd->falloff = hmd->falloff;
	thmd->force = hmd->force;
	thmd->object = hmd->object;
	thmd->totindex = hmd->totindex;
	thmd->indexar = MEM_dupallocN(hmd->indexar);
	memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv));
	strncpy(thmd->name, hmd->name, 32);
	strncpy(thmd->subtarget, hmd->subtarget, 32);
}
Exemple #25
0
EnvMap *BKE_texture_envmap_copy(const EnvMap *env, const int flag)
{
	EnvMap *envn;
	int a;
	
	envn = MEM_dupallocN(env);
	envn->ok = 0;
	for (a = 0; a < 6; a++) {
		envn->cube[a] = NULL;
	}
	if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
		id_us_plus((ID *)envn->ima);
	}

	return envn;
}
Exemple #26
0
void BLI_duplicatelist(ListBase *dst, const ListBase *src)
/* sets dst to a duplicate of the entire contents of src. dst may be the same as src. */
{
	struct Link *dst_link, *src_link;

	/* in this order, to ensure it works if dst == src */
	src_link = src->first;
	dst->first = dst->last = NULL;

	while (src_link) {
		dst_link = MEM_dupallocN(src_link);
		BLI_addtail(dst, dst_link);

		src_link = src_link->next;
	}
}
Exemple #27
0
/**
 * Only copy internal data of Lattice ID from source
 * to already allocated/initialized destination.
 * You probably never want to use that directly,
 * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
 *
 * WARNING! This function will not handle ID user count!
 *
 * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
 */
void BKE_lattice_copy_data(Main *bmain, Lattice *lt_dst, const Lattice *lt_src, const int flag)
{
  lt_dst->def = MEM_dupallocN(lt_src->def);

  if (lt_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
    BKE_id_copy_ex(bmain, &lt_src->key->id, (ID **)&lt_dst->key, flag);
  }

  if (lt_src->dvert) {
    int tot = lt_src->pntsu * lt_src->pntsv * lt_src->pntsw;
    lt_dst->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
    BKE_defvert_array_copy(lt_dst->dvert, lt_src->dvert, tot);
  }

  lt_dst->editlatt = NULL;
}
Exemple #28
0
ListBase *folderlist_duplicate(ListBase* folderlist)
{
	
	if (folderlist) {
		ListBase *folderlistn= MEM_callocN(sizeof(ListBase), "copy folderlist");
		FolderList *folder;
		
		BLI_duplicatelist(folderlistn, folderlist);
		
		for (folder= folderlistn->first; folder; folder= folder->next) {
			folder->foldername= MEM_dupallocN(folder->foldername);
		}
		return folderlistn;
	}
	return NULL;
}
Exemple #29
0
static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe))
{
	ListBase *lb = lbu;
	ListBase *editelems = lbe;
	MetaElem *ml, *newml;
	
	freeMetaElemlist(editelems);

	/* copy 'undo' MetaElems to 'edit' MetaElems */
	ml = lb->first;
	while (ml) {
		newml = MEM_dupallocN(ml);
		BLI_addtail(editelems, newml);
		ml = ml->next;
	}
	
}
Exemple #30
0
static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
{
	wmKeyMapItem *kmin = MEM_dupallocN(kmi);

	kmin->prev= kmin->next= NULL;
	kmin->flag &= ~KMI_UPDATE;

	if(kmin->properties) {
		kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
		WM_operator_properties_create(kmin->ptr, kmin->idname);

		kmin->properties= IDP_CopyProperty(kmin->properties);
		kmin->ptr->data= kmin->properties;
	}

	return kmin;
}