当前位置: 首页>>代码示例>>C++>>正文


C++ MEM_dupallocN函数代码示例

本文整理汇总了C++中MEM_dupallocN函数的典型用法代码示例。如果您正苦于以下问题:C++ MEM_dupallocN函数的具体用法?C++ MEM_dupallocN怎么用?C++ MEM_dupallocN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MEM_dupallocN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ui_template_node_link_menu

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"));
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:41,代码来源:node_templates.c

示例2: BKE_texture_copy_data

/**
 * 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;
	}
}
开发者ID:mgschwan,项目名称:blensor,代码行数:49,代码来源:texture.c

示例3: MEM_dupallocN

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;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:12,代码来源:boids.c

示例4: BKE_displist_copy

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;
	}
}
开发者ID:mgschwan,项目名称:blensor,代码行数:21,代码来源:displist.c

示例5: MEM_callocN

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;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:12,代码来源:object_lattice.c

示例6: MEM_dupallocN

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;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:12,代码来源:wm_keymap.c

示例7: copy_libblock

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;
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:39,代码来源:mesh.c

示例8: BKE_paint_brush

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;
}
开发者ID:mcgrathd,项目名称:blender,代码行数:51,代码来源:image_draw.c

示例9: BKE_libblock_copy_nolib

/* 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;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:39,代码来源:texture.c

示例10: make_editLatt

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;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:23,代码来源:object_lattice.c

示例11: IMB_allocImBuf

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;
}
开发者ID:mcgrathd,项目名称:blender,代码行数:23,代码来源:allocimbuf.c

示例12: copyData

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;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:14,代码来源:MOD_correctivesmooth.c

示例13: ED_lattice_editlatt_make

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;
}
开发者ID:pawkoz,项目名称:dyplom,代码行数:23,代码来源:object_lattice.c

示例14: fmodifier_get_typeinfo

/* 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;
}
开发者ID:nttputus,项目名称:blensor,代码行数:24,代码来源:fmodifier.c

示例15: BKE_pose_copy_data

/**
 * 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;
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:55,代码来源:action.c


注:本文中的MEM_dupallocN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。