Example #1
0
static int vertex_group_menu_exec(bContext *C, wmOperator *op)
{
	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
	uiPopupMenu *pup;
	uiLayout *layout;

	pup= uiPupMenuBegin(C, "Vertex Groups", 0);
	layout= uiPupMenuLayout(pup);
	uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);

	if(vgroup_object_in_edit_mode(ob)) {
		uiItemBooleanO(layout, "Assign to New Group", 0, "OBJECT_OT_vertex_group_assign", "new", 1);

		if(BLI_countlist(&ob->defbase) && ob->actdef) {
			uiItemO(layout, "Assign to Group", 0, "OBJECT_OT_vertex_group_assign");
			uiItemO(layout, "Remove from Group", 0, "OBJECT_OT_vertex_group_remove_from");
			uiItemBooleanO(layout, "Remove from All", 0, "OBJECT_OT_vertex_group_remove_from", "all", 1);
		}
	}

	if(BLI_countlist(&ob->defbase) && ob->actdef) {
		if(vgroup_object_in_edit_mode(ob))
			uiItemS(layout);

		uiItemO(layout, "Set Active Group", 0, "OBJECT_OT_vertex_group_set_active");
		uiItemO(layout, "Remove Group", 0, "OBJECT_OT_vertex_group_remove");
		uiItemBooleanO(layout, "Remove All Groups", 0, "OBJECT_OT_vertex_group_remove", "all", 1);
	}

	uiPupMenuEnd(C, pup);

	return OPERATOR_FINISHED;
}
Example #2
0
void BME_model_end(BME_Mesh *bm){
	int meshok, totvert, totedge, totpoly;

	totvert = BLI_countlist(&(bm->verts));
	totedge = BLI_countlist(&(bm->edges));
	totpoly = BLI_countlist(&(bm->polys));

	if(bm->vtar) MEM_freeN(bm->vtar);
	if(bm->edar) MEM_freeN(bm->edar);
	if(bm->lpar) MEM_freeN(bm->lpar);
	if(bm->plar) MEM_freeN(bm->plar);
	
	bm->vtar = NULL;
	bm->edar = NULL;
	bm->lpar = NULL;
	bm->plar = NULL;
	bm->vtarlen = bm->edarlen = bm->lparlen = bm->plarlen = 0;
	
	
	if(bm->totvert!=totvert || bm->totedge!=totedge || bm->totpoly!=totpoly)
		BME_error();
	
	meshok = BME_validate_mesh(bm, 1);
	if(!meshok){
		BME_error();
	}
}
Example #3
0
/* return 1: success */
static int mesh_separate_loose(wmOperator *op, Main *bmain, Scene *scene, Base *editbase)
{
	Mesh *me;
	EditMesh *em;
	int doit= 1;
	
	me= editbase->object->data;
	em= BKE_mesh_get_editmesh(me);
	
	if(me->key) {
		error("Can't separate with vertex keys");
		BKE_mesh_end_editmesh(me, em);
		return 0;
	}
	
	EM_clear_flag_all(em, SELECT);

	while(doit) {
		/* Select a random vert to start with */
		EditVert *eve;
		int tot;

		/* check if all verts that are visible have been done */
		for(eve=em->verts.first; eve; eve= eve->next)
			if(!eve->h) break;
		if(eve==NULL) break; /* only hidden verts left, quit early */

		/* first non hidden vert */
		eve->f |= SELECT;
		
		selectconnected_mesh_all(em);
		
		/* don't separate the very last part */
		for(eve=em->verts.first; eve; eve= eve->next)
			if((eve->f & SELECT)==0) break;
		if(eve==NULL) break;

		tot= BLI_countlist(&em->verts);

		/* and now separate */
		doit= mesh_separate_selected(op, bmain, scene, editbase);

		/* with hidden verts this can happen */
		if(tot == BLI_countlist(&em->verts))
			break;
	}

	BKE_mesh_end_editmesh(me, em);
	return 1;
}
Example #4
0
/* note, must be freed */
int *defgroup_flip_map(Object *ob, int use_default)
{
	bDeformGroup *dg;
	int totdg= BLI_countlist(&ob->defbase);

	if(totdg==0) {
		return NULL;
	}
	else {
		char name[sizeof(dg->name)];
		int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), "get_defgroup_flip_map");

		memset(map, -1, totdg * sizeof(int));

		for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) {
			if(map[i] == -1) { /* may be calculated previously */

				/* incase no valid value is found, use this */
				if(use_default)
					map[i]= i;

				flip_side_name(name, dg->name, 0);
				if(strcmp(name, dg->name)) {
					flip_num= defgroup_name_index(ob, name);
					if(flip_num >= 0) {
						map[i]= flip_num;
						map[flip_num]= i; /* save an extra lookup */
					}
				}
			}
		}
		return map;
	}
}
Example #5
0
static void rna_Surface_active_point_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
	DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;

	*min = 0;
	*max = BLI_countlist(&canvas->surfaces) - 1;
}
Example #6
0
/* Recursively iterate over tree, finding and working on selected items */
static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, short mode)
{
	TreeElement *te;
	TreeStoreElem *tselem;
	
	for (te= tree->first; te; te=te->next) {
		tselem= TREESTORE(te);
		
		/* if item is selected, perform operation */
		if (tselem->flag & TSE_SELECTED) {
			ID *id= NULL;
			char *path= NULL;
			int array_index= 0;
			short flag= 0;
			short groupmode= KSP_GROUP_KSNAME;
			
			/* check if RNA-property described by this selected element is an animateable prop */
			if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
				/* get id + path + index info from the selected element */
				tree_element_to_path(soops, te, tselem, 
						&id, &path, &array_index, &flag, &groupmode);
			}
			
			/* only if ID and path were set, should we perform any actions */
			if (id && path) {
				/* action depends on mode */
				switch (mode) {
					case KEYINGSET_EDITMODE_ADD:
					{
						/* add a new path with the information obtained (only if valid) */
						// TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name
						BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode);
						ks->active_path= BLI_countlist(&ks->paths);
					}
						break;
					case KEYINGSET_EDITMODE_REMOVE:
					{
						/* find the relevant path, then remove it from the KeyingSet */
						KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode);
						
						if (ksp) {
							/* free path's data */
							BKE_keyingset_free_path(ks, ksp);

							ks->active_path= 0;
						}
					}
						break;
				}
				
				/* free path, since it had to be generated */
				MEM_freeN(path);
			}
		}
		
		/* go over sub-tree */
		if ((tselem->flag & TSE_CLOSED)==0)
			do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
	}
}
Example #7
0
static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int *min, int *max,
        int *UNUSED(softmin), int *UNUSED(softmax))
{
    BoidSettings *boids = (BoidSettings *)ptr->data;
    *min = 0;
    *max = max_ii(0, BLI_countlist(&boids->states) - 1);
}
Example #8
0
static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min, int *max,
        int *UNUSED(softmin), int *UNUSED(softmax))
{
    BoidState *state = (BoidState *)ptr->data;
    *min = 0;
    *max = max_ii(0, BLI_countlist(&state->rules) - 1);
}
Example #9
0
static int add_default_keyingset_exec (bContext *C, wmOperator *op)
{
	Scene *scene= CTX_data_scene(C);
	short flag=0, keyingflag=0;
	
	/* validate flags 
	 *	- absolute KeyingSets should be created by default
	 */
	flag |= KEYINGSET_ABSOLUTE;
	
	if (IS_AUTOKEY_FLAG(AUTOMATKEY)) 
		keyingflag |= INSERTKEY_MATRIX;
	if (IS_AUTOKEY_FLAG(INSERTNEEDED)) 
		keyingflag |= INSERTKEY_NEEDED;
		
	/* call the API func, and set the active keyingset index */
	BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag);
	
	scene->active_keyingset= BLI_countlist(&scene->keyingsets);
	
	/* send notifiers */
	WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
	
	return OPERATOR_FINISHED;
}
Example #10
0
static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int *min, int *max)
{
	BoidSettings *boids= (BoidSettings*)ptr->data;
	*min= 0;
	*max= BLI_countlist(&boids->states)-1;
	*max= MAX2(0, *max);
}
Example #11
0
/* helper function for add_constriant - sets the last target for the active constraint */
static void set_constraint_nth_target (bConstraint *con, Object *target, char subtarget[], int index)
{
	bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
	ListBase targets = {NULL, NULL};
	bConstraintTarget *ct;
	int num_targets, i;
	
	if (cti && cti->get_constraint_targets) {
		cti->get_constraint_targets(con, &targets);
		num_targets= BLI_countlist(&targets);
		
		if (index < 0) {
			if (abs(index) < num_targets)
				index= num_targets - abs(index);
			else
				index= num_targets - 1;
		}
		else if (index >= num_targets) {
			index= num_targets - 1;
		}
		
		for (ct=targets.first, i=0; ct; ct= ct->next, i++) {
			if (i == index) {
				ct->tar= target;
				strcpy(ct->subtarget, subtarget);
				break;
			}
		}
		
		if (cti->flush_constraint_targets)
			cti->flush_constraint_targets(con, &targets, 0);
	}
}
Example #12
0
static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
{
	void **rnd_data = rnd_pt;
	uiBlock *block = uiLayoutGetBlock(layout);
	RenderResult *rr = rnd_data[0];
	ImageUser *iuser = rnd_data[1];
	RenderLayer *rl;
	RenderLayer rl_fake = {NULL};
	const char *fake_name;
	int nr;

	uiBlockSetCurLayout(block, layout);
	uiLayoutColumn(layout, false);

	uiDefBut(block, LABEL, 0, IFACE_("Layer"),
	         0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
	uiItemS(layout);

	nr = BLI_countlist(&rr->layers) - 1;
	fake_name = ui_imageuser_layer_fake_name(rr);

	if (fake_name) {
		BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name));
		nr += 1;
	}

	for (rl = rr->layers.last; rl; rl = rl->prev, nr--) {
final:
		uiDefButS(block, BUTM, B_NOP, IFACE_(rl->name), 0, 0,
		          UI_UNIT_X * 5, UI_UNIT_X, &iuser->layer, (float) nr, 0.0, 0, -1, "");
	}
Example #13
0
/* rl==NULL means composite result */
static char *pass_menu(RenderLayer *rl, short *curpass)
{
	RenderPass *rpass;
	int len = 64 + 32 * (rl ? BLI_countlist(&rl->passes) : 1);
	short a, nr = 0;
	char *str = MEM_callocN(len, "menu layers");
	
	strcpy(str, IFACE_("Pass %t"));
	a = strlen(str);
	
	/* rendered results don't have a Combined pass */
	if (rl == NULL || rl->rectf) {
		a += sprintf(str + a, "|%s %%x0", IFACE_("Combined"));
		nr = 1;
	}
	
	if (rl)
		for (rpass = rl->passes.first; rpass; rpass = rpass->next, nr++)
			a += sprintf(str + a, "|%s %%x%d", IFACE_(rpass->name), nr);
	
	if (*curpass >= nr)
		*curpass = 0;
	
	return str;
}
Example #14
0
/* NOTE: this needs to be called before frame update to work correctly */
void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
{
	RigidBodyWorld *rbw = scene->rigidbody_world;
	PointCache *cache;
	PTCacheID pid;
	int startframe, endframe;

	BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw);
	BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
	cache = rbw->pointcache;

	/* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */
	if (rbw->physics_world == NULL || rbw->numbodies != BLI_countlist(&rbw->group->gobject)) {
		cache->flag |= PTCACHE_OUTDATED;
	}

	if (ctime == startframe + 1 && rbw->ltime == startframe) {
		if (cache->flag & PTCACHE_OUTDATED) {
			BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
			rigidbody_update_simulation(scene, rbw, true);
			BKE_ptcache_validate(cache, (int)ctime);
			cache->last_exact = 0;
			cache->flag &= ~PTCACHE_REDO_NEEDED;
		}
	}
}
Example #15
0
/* TODO, curlay should be removed? */
static char *layer_menu(RenderResult *rr, short *UNUSED(curlay))
{
	RenderLayer *rl;
	int len = 64 + RE_MAXNAME * BLI_countlist(&rr->layers);
	short a, nr = 0;
	char *str = MEM_callocN(len, "menu layers");
	
	strcpy(str, IFACE_("Layer %t"));
	a = strlen(str);
	
	/* compo result */
	if (rr->rectf) {
		a += sprintf(str + a, "|%s %%x0", IFACE_("Composite"));
		nr = 1;
	}
	else if (rr->rect32) {
		a += sprintf(str + a, "|%s %%x0", IFACE_("Sequence"));
		nr = 1;
	}
	for (rl = rr->layers.first; rl; rl = rl->next, nr++) {
		a += sprintf(str + a, "|%s %%x%d", rl->name, nr);
	}
	
	/* no curlay clip here, on render (redraws) the amount of layers can be 1 fir single-layer render */
	
	return str;
}
Example #16
0
/* note, must be freed */
int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_default, int defgroup)
{
	int defbase_tot = *flip_map_len = BLI_countlist(&ob->defbase);

	if (defbase_tot == 0) {
		return NULL;
	}
	else {
		bDeformGroup *dg;
		char name[sizeof(dg->name)];
		int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);

		for (i = 0; i < defbase_tot; i++) {
			map[i] = use_default ? i : -1;
		}

		dg = BLI_findlink(&ob->defbase, defgroup);

		flip_side_name(name, dg->name, FALSE);
		if (strcmp(name, dg->name)) {
			flip_num = defgroup_name_index(ob, name);

			if (flip_num != -1) {
				map[defgroup] = flip_num;
				map[flip_num] = defgroup;
			}
		}

		return map;
	}
}
Example #17
0
static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
{
	Scene *scene = CTX_data_scene(C);
	KeyingSet *ks;
	KS_Path *ksp;
	
	/* verify the Keying Set to use:
	 *	- use the active one
	 *	- return error if it doesn't exist
	 */
	if (scene->active_keyingset == 0) {
		BKE_report(op->reports, RPT_ERROR, "No active keying set to add empty path to");
		return OPERATOR_CANCELLED;
	}
	else
		ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
	
	/* don't use the API method for this, since that checks on values... */
	ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
	BLI_addtail(&ks->paths, ksp);
	ks->active_path = BLI_countlist(&ks->paths);
	
	ksp->groupmode = KSP_GROUP_KSNAME; // XXX?
	ksp->idtype = ID_OB;
	ksp->flag = KSP_FLAG_WHOLE_ARRAY;
	
	return OPERATOR_FINISHED;
}
Example #18
0
static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min, int *max)
{
	BoidState *state= (BoidState*)ptr->data;
	*min= 0;
	*max= BLI_countlist(&state->rules)-1;
	*max= MAX2(0, *max);
}
Example #19
0
static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
	KeyingSet *ks = (KeyingSet *)ptr->data;

	*min = 0;
	*max = max_ii(0, BLI_countlist(&ks->paths) - 1);
}
Example #20
0
static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min, int *max,
        int *UNUSED(softmin), int *UNUSED(softmax))
{
    bAction *act = (bAction *)ptr->data;

    *min = 0;
    *max = max_ii(0, BLI_countlist(&act->markers) - 1);
}
Example #21
0
static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min, int *max)
{
	bAction *act= (bAction*)ptr->data;

	*min= 0;
	*max= BLI_countlist(&act->markers)-1;
	*max= MAX2(0, *max);
}
Example #22
0
static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix)
{
	if(object_insert_shape_key(scene, ob, NULL, from_mix)) {
		Key *key= ob_get_key(ob);
		ob->shapenr= BLI_countlist(&key->block);

		WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
	}
}
Example #23
0
static void console_scrollback_limit(SpaceConsole *sc)
{
	int tot;
	
	if (U.scrollback < 32) U.scrollback= 128; // XXX - save in user defaults
	
	for(tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--)
		console_scrollback_free(sc, sc->scrollback.first);
}
Example #24
0
std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id)
{
	std::string source_id = controller_id + BIND_POSES_SOURCE_ID_SUFFIX;

	COLLADASW::FloatSourceF source(mSW);
	source.setId(source_id);
	source.setArrayId(source_id + ARRAY_ID_SUFFIX);
	source.setAccessorCount(BLI_countlist(defbase));
	source.setAccessorStride(16);
	
	source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
	COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
	param.push_back("TRANSFORM");

	source.prepareToAppendValues();

	bPose *pose = ob_arm->pose;
	bArmature *arm = (bArmature*)ob_arm->data;

	int flag = arm->flag;

	// put armature in rest position
	if (!(arm->flag & ARM_RESTPOS)) {
		arm->flag |= ARM_RESTPOS;
		where_is_pose(scene, ob_arm);
	}

	for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
		if (is_bone_defgroup(ob_arm, def)) {

			bPoseChannel *pchan = get_pose_channel(pose, def->name);

			float mat[4][4];
			float world[4][4];
			float inv_bind_mat[4][4];

			// make world-space matrix, arm_mat is armature-space
			mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat);
			
			invert_m4_m4(mat, world);
			converter.mat4_to_dae(inv_bind_mat, mat);

			source.appendValues(inv_bind_mat);
		}
	}

	// back from rest positon
	if (!(flag & ARM_RESTPOS)) {
		arm->flag = flag;
		where_is_pose(scene, ob_arm);
	}

	source.finish();

	return source_id;
}
Example #25
0
static void text_drawcache_init(SpaceText *st)
{
	DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache");

	drawcache->winx = -1;
	drawcache->nlines = BLI_countlist(&st->text->lines);
	drawcache->text_id[0] = '\0';

	st->drawcache = drawcache;
}
Example #26
0
static void console_lb_debug__internal(ListBase *lb)
{
	ConsoleLine *cl;

	printf("%d: ", BLI_countlist(lb));
	for(cl= lb->first; cl; cl= cl->next)
		printf("<%s> ", cl->line);
	printf("\n");

}
Example #27
0
int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*))
{
	ListBase list;

	if(func(C, &list)) {
		int tot= BLI_countlist(&list);
		BLI_freelistN(&list);
		return tot;
	}
	else
		return 0;
}
Example #28
0
static void vgroup_duplicate(Object *ob)
{
	bDeformGroup *dg, *cdg;
	char name[32], s[32];
	MDeformWeight *org, *cpy;
	MDeformVert *dvert, *dvert_array=NULL;
	int i, idg, icdg, dvert_tot=0;

	dg = BLI_findlink(&ob->defbase, (ob->actdef-1));
	if(!dg)
		return;
	
	if(strstr(dg->name, "_copy")) {
		BLI_strncpy(name, dg->name, 32); /* will be renamed _copy.001... etc */
	}
	else {
		BLI_snprintf(name, 32, "%s_copy", dg->name);
		while(get_named_vertexgroup(ob, name)) {
			if((strlen(name) + 6) > 32) {
				printf("Internal error: the name for the new vertex group is > 32 characters");
				return;
			}
			strcpy(s, name);
			BLI_snprintf(name, 32, "%s_copy", s);
		}
	}		

	cdg = copy_defgroup(dg);
	strcpy(cdg->name, name);
	unique_vertexgroup_name(cdg, ob);
	
	BLI_addtail(&ob->defbase, cdg);

	idg = (ob->actdef-1);
	ob->actdef = BLI_countlist(&ob->defbase);
	icdg = (ob->actdef-1);

	ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot);
	
	if(!dvert_array)
		return;

	for(i = 0; i < dvert_tot; i++) {
		dvert = dvert_array+i;
		org = ED_vgroup_weight_get(dvert, idg);
		if(org) {
			float weight = org->weight;
			/* ED_vgroup_weight_verify re-allocs org so need to store the weight first */
			cpy = ED_vgroup_weight_verify(dvert, icdg);
			cpy->weight = weight;
		}
	}
}
Example #29
0
void EM_init_index_arrays(EditMesh *em, int forVert, int forEdge, int forFace)
{
	EditVert *eve;
	EditEdge *eed;
	EditFace *efa;
	int i;

	if (forVert) {
		em->totvert= BLI_countlist(&em->verts);

		if(em->totvert) {
			g_em_vert_array = MEM_mallocN(sizeof(*g_em_vert_array)*em->totvert, "em_v_arr");

			for (i=0,eve=em->verts.first; eve; i++,eve=eve->next)
				g_em_vert_array[i] = eve;
		}
	}

	if (forEdge) {
		em->totedge= BLI_countlist(&em->edges);

		if(em->totedge) {
			g_em_edge_array = MEM_mallocN(sizeof(*g_em_edge_array)*em->totedge, "em_e_arr");

			for (i=0,eed=em->edges.first; eed; i++,eed=eed->next)
				g_em_edge_array[i] = eed;
		}
	}

	if (forFace) {
		em->totface= BLI_countlist(&em->faces);

		if(em->totface) {
			g_em_face_array = MEM_mallocN(sizeof(*g_em_face_array)*em->totface, "em_f_arr");

			for (i=0,efa=em->faces.first; efa; i++,efa=efa->next)
				g_em_face_array[i] = efa;
		}
	}
}
Example #30
0
static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag)
{
	int i, nids= BLI_countlist(lb);
		
	if (nr) *nr= -1;
	
	if (nr && nids>MAX_IDPUP) {
		BLI_dynstr_append(pupds, "DataBrowse %x-2");
		*nr= -2;
	} else {
		ID *id;
		
		for (i=0, id= lb->first; id; id= id->next, i++) {
			char buf[32];
			
			if (nr && id==link) *nr= i+1;

			if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
				continue;
			if (hideflag & IDPUP_NO_VIEWER)
				if (GS(id->name)==ID_IM)
					if ( ((Image *)id)->source==IMA_SRC_VIEWER )
						continue;
			
			get_flags_for_id(id, buf);
				
			BLI_dynstr_append(pupds, buf);
			BLI_dynstr_append(pupds, id->name+2);
			BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
			BLI_dynstr_append(pupds, buf);
			
			/* icon */
			switch(GS(id->name))
			{
			case ID_MA: /* fall through */
			case ID_TE: /* fall through */
			case ID_IM: /* fall through */
			case ID_WO: /* fall through */
			case ID_LA: /* fall through */
				BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
				BLI_dynstr_append(pupds, buf);
				break;
			default:
				break;
			}
			
			if(id->next)
				BLI_dynstr_append(pupds, "|");
		}
	}
}