static void outliner_add_line_styles(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
	SceneRenderLayer *srl;
	FreestyleLineSet *lineset;

	for (srl = sce->r.layers.first; srl; srl = srl->next) {
		for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
			FreestyleLineStyle *linestyle = lineset->linestyle;
			if (linestyle) {
				linestyle->id.flag |= LIB_DOIT;
			}
		}
	}
	for (srl = sce->r.layers.first; srl; srl = srl->next) {
		for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
			FreestyleLineStyle *linestyle = lineset->linestyle;
			if (linestyle) {
				if (!(linestyle->id.flag & LIB_DOIT))
					continue;
				linestyle->id.flag &= ~LIB_DOIT;
				outliner_add_element(soops, lb, linestyle, te, 0, 0);
			}
		}
	}
}
static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
	SceneRenderLayer *srl;
	TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0);
	int a;
	
	tenla->name = IFACE_("RenderLayers");
	for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) {
		TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a);
		tenlay->name = srl->name;
		tenlay->directdata = &srl->layflag;
		
		if (srl->light_override)
			outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0);
		if (srl->mat_override)
			outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0);
		
		outliner_add_passes(soops, tenlay, &sce->id, srl);
	}
	
	// TODO: move this to the front?
	if (outliner_animdata_test(sce->adt))
		outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
	
	outliner_add_element(soops,  lb, sce->world, te, 0, 0);

#ifdef WITH_FREESTYLE
	if (STREQ(sce->r.engine, "BLENDER_RENDER") && (sce->r.mode & R_EDGE_FRS))
		outliner_add_line_styles(soops, lb, sce, te);
#endif
}
Beispiel #3
0
static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
	SceneRenderLayer *srl;
	TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0);
	int a;
	
	tenla->name= "RenderLayers";
	for(a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) {
		TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a);
		tenlay->name= srl->name;
		tenlay->directdata= &srl->passflag;
		
		if(srl->light_override)
			outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0);
		if(srl->mat_override)
			outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0);
		
		outliner_add_passes(soops, tenlay, &sce->id, srl);
	}
	
	// TODO: move this to the front?
	if (sce->adt)
		outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
	
	outliner_add_element(soops,  lb, sce->world, te, 0, 0);
}
/* special handling of hierarchical non-lib data */
static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, 
                              TreeElement *parent, int *a)
{
	TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a);
	
	(*a)++;
	te->name = curBone->name;
	te->directdata = curBone;
	
	for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) {
		outliner_add_bone(soops, &te->subtree, id, curBone, te, a);
	}
}
// TODO: this function needs to be split up! It's getting a bit too large...
// Note: "ID" is not always a real ID
static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, 
                                         TreeElement *parent, short type, short index)
{
	TreeElement *te;
	TreeStoreElem *tselem;
	ID *id = idv;
	
	if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
		id = ((PointerRNA *)idv)->id.data;
		if (!id) id = ((PointerRNA *)idv)->data;
	}

	/* One exception */
	if (type == TSE_ID_BASE) {
		/* pass */
	}
	else if (id == NULL) {
		return NULL;
	}

	te = MEM_callocN(sizeof(TreeElement), "tree elem");
	/* add to the visual tree */
	BLI_addtail(lb, te);
	/* add to the storage */
	check_persistent(soops, te, id, type, index);
	tselem = TREESTORE(te);
	
	/* if we are searching for something expand to see child elements */
	if (SEARCHING_OUTLINER(soops))
		tselem->flag |= TSE_CHILDSEARCH;
	
	te->parent = parent;
	te->index = index;   // for data arays
	if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) {
		/* pass */
	}
	else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
		/* pass */
	}
	else if (type == TSE_ANIM_DATA) {
		/* pass */
	}
	else if (type == TSE_ID_BASE) {
		/* pass */
	}
	else {
		/* do here too, for blend file viewer, own ID_LI then shows file name */
		if (GS(id->name) == ID_LI)
			te->name = ((Library *)id)->name;
		else
			te->name = id->name + 2; // default, can be overridden by Library or non-ID data
		te->idcode = GS(id->name);
	}
	
	if (type == 0) {
		TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
		
		/* ID datablock */
		if (tsepar == NULL || tsepar->type != TSE_ID_BASE)
			outliner_add_id_contents(soops, te, tselem, id);
	}
	else if (type == TSE_ANIM_DATA) {
		IdAdtTemplate *iat = (IdAdtTemplate *)idv;
		AnimData *adt = (AnimData *)iat->adt;
		
		/* this element's info */
		te->name = IFACE_("Animation");
		te->directdata = adt;
		
		/* Action */
		outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0);
		
		/* Drivers */
		if (adt->drivers.first) {
			TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
			ID *lastadded = NULL;
			FCurve *fcu;
			
			ted->name = IFACE_("Drivers");
		
			for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
				if (fcu->driver && fcu->driver->variables.first) {
					ChannelDriver *driver = fcu->driver;
					DriverVar *dvar;
					
					for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
						/* loop over all targets used here */
						DRIVER_TARGETS_USED_LOOPER(dvar) 
						{
							if (lastadded != dtar->id) {
								// XXX this lastadded check is rather lame, and also fails quite badly...
								outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
								lastadded = dtar->id;
							}
						}
						DRIVER_TARGETS_LOOPER_END
					}
				}
			}
// can be inlined if necessary
static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id)
{
	/* tuck pointer back in object, to construct hierarchy */
	if (GS(id->name) == ID_OB) id->newid = (ID *)te;
	
	/* expand specific data always */
	switch (GS(id->name)) {
		case ID_LI:
		{
			te->name = ((Library *)id)->name;
			break;
		}
		case ID_SCE:
		{
			outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te);
			break;
		}
		case ID_OB:
		{
			outliner_add_object_contents(soops, te, tselem, (Object *)id);
			break;
		}
		case ID_ME:
		{
			Mesh *me = (Mesh *)id;
			int a;
			
			if (outliner_animdata_test(me->adt))
				outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0);
			
			outliner_add_element(soops, &te->subtree, me->key, te, 0, 0);
			for (a = 0; a < me->totcol; a++)
				outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a);
			/* could do tfaces with image links, but the images are not grouped nicely.
			 * would require going over all tfaces, sort images in use. etc... */
			break;
		}
		case ID_CU:
		{
			Curve *cu = (Curve *)id;
			int a;
			
			if (outliner_animdata_test(cu->adt))
				outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
			
			for (a = 0; a < cu->totcol; a++)
				outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a);
			break;
		}
		case ID_MB:
		{
			MetaBall *mb = (MetaBall *)id;
			int a;
			
			if (outliner_animdata_test(mb->adt))
				outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
			
			for (a = 0; a < mb->totcol; a++)
				outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a);
			break;
		}
		case ID_MA:
		{
			Material *ma = (Material *)id;
			int a;
			
			if (outliner_animdata_test(ma->adt))
				outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
			
			for (a = 0; a < MAX_MTEX; a++) {
				if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a);
			}
			break;
		}
		case ID_TE:
		{
			Tex *tex = (Tex *)id;
			
			if (outliner_animdata_test(tex->adt))
				outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
			
			outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0);
			break;
		}
		case ID_CA:
		{
			Camera *ca = (Camera *)id;
			
			if (outliner_animdata_test(ca->adt))
				outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
			break;
		}
		case ID_LA:
		{
			Lamp *la = (Lamp *)id;
			int a;
			
			if (outliner_animdata_test(la->adt))
				outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
			
			for (a = 0; a < MAX_MTEX; a++) {
				if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a);
			}
			break;
		}
		case ID_SPK:
		{
			Speaker *spk = (Speaker *)id;

			if (outliner_animdata_test(spk->adt))
				outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
			break;
		}
		case ID_WO:
		{
			World *wrld = (World *)id;
			int a;
			
			if (outliner_animdata_test(wrld->adt))
				outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
			
			for (a = 0; a < MAX_MTEX; a++) {
				if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a);
			}
			break;
		}
		case ID_KE:
		{
			Key *key = (Key *)id;
			
			if (outliner_animdata_test(key->adt))
				outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0);
			break;
		}
		case ID_AC:
		{
			// XXX do we want to be exposing the F-Curves here?
			//bAction *act = (bAction *)id;
			break;
		}
		case ID_AR:
		{
			bArmature *arm = (bArmature *)id;
			int a = 0;
			
			if (outliner_animdata_test(arm->adt))
				outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
			
			if (arm->edbo) {
				EditBone *ebone;
				TreeElement *ten;
				
				for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) {
					ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a);
					ten->directdata = ebone;
					ten->name = ebone->name;
					ebone->temp = ten;
				}
				/* make hierarchy */
				ten = arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL;
				while (ten) {
					TreeElement *nten = ten->next, *par;
					ebone = (EditBone *)ten->directdata;
					if (ebone->parent) {
						BLI_remlink(&te->subtree, ten);
						par = ebone->parent->temp;
						BLI_addtail(&par->subtree, ten);
						ten->parent = par;
					}
					ten = nten;
				}
			}
			else {
				/* do not extend Armature when we have posemode */
				tselem = TREESTORE(te->parent);
				if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) {
					/* pass */
				}
				else {
					Bone *curBone;
					for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
						outliner_add_bone(soops, &te->subtree, id, curBone, te, &a);
					}
				}
			}
			break;
		}
		case ID_LS:
		{
			FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
			int a;
			
			if (outliner_animdata_test(linestyle->adt))
				outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);

			for (a = 0; a < MAX_MTEX; a++) {
				if (linestyle->mtex[a])
					outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
			}
			break;
		}
	}
}
// can be inlined if necessary
static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob)
{
	int a = 0;
	
	if (outliner_animdata_test(ob->adt))
		outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
	
	outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
	
	if (ob->proxy && ob->id.lib == NULL)
		outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
	
	outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
	
	if (ob->pose) {
		bArmature *arm = ob->data;
		bPoseChannel *pchan;
		TreeElement *ten;
		TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
		
		tenla->name = IFACE_("Pose");
		
		/* channels undefined in editmode, but we want the 'tenla' pose icon itself */
		if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) {
			int a = 0, const_index = 1000;    /* ensure unique id for bone constraints */
			
			for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) {
				ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
				ten->name = pchan->name;
				ten->directdata = pchan;
				pchan->temp = (void *)ten;
				
				if (pchan->constraints.first) {
					//Object *target;
					bConstraint *con;
					TreeElement *ten1;
					TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
					//char *str;
					
					tenla1->name = IFACE_("Constraints");
					for (con = pchan->constraints.first; con; con = con->next, const_index++) {
						ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
#if 0 /* disabled as it needs to be reworked for recoded constraints system */
						target = get_constraint_target(con, &str);
						if (str && str[0]) ten1->name = str;
						else if (target) ten1->name = target->id.name + 2;
						else ten1->name = con->name;
#endif
						ten1->name = con->name;
						ten1->directdata = con;
						/* possible add all other types links? */
					}
				}
			}
			/* make hierarchy */
			ten = tenla->subtree.first;
			while (ten) {
				TreeElement *nten = ten->next, *par;
				tselem = TREESTORE(ten);
				if (tselem->type == TSE_POSE_CHANNEL) {
					pchan = (bPoseChannel *)ten->directdata;
					if (pchan->parent) {
						BLI_remlink(&tenla->subtree, ten);
						par = (TreeElement *)pchan->parent->temp;
						BLI_addtail(&par->subtree, ten);
						ten->parent = par;
					}
				}
				ten = nten;
			}
		}
		
		/* Pose Groups */
		if (ob->pose->agroups.first) {
			bActionGroup *agrp;
			TreeElement *ten;
			TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0);
			int a = 0;
			
			tenla->name = IFACE_("Bone Groups");
			for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) {
				ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a);
				ten->name = agrp->name;
				ten->directdata = agrp;
			}
		}
	}
	
	for (a = 0; a < ob->totcol; a++)
		outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a);
	
	if (ob->constraints.first) {
		//Object *target;
		bConstraint *con;
		TreeElement *ten;
		TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
		//char *str;
		
		tenla->name = IFACE_("Constraints");
		for (con = ob->constraints.first, a = 0; con; con = con->next, a++) {
			ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
#if 0 /* disabled due to constraints system targets recode... code here needs review */
			target = get_constraint_target(con, &str);
			if (str && str[0]) ten->name = str;
			else if (target) ten->name = target->id.name + 2;
			else ten->name = con->name;
#endif
			ten->name = con->name;
			ten->directdata = con;
			/* possible add all other types links? */
		}
	}
	
	if (ob->modifiers.first) {
		ModifierData *md;
		TreeElement *temod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
		int index;
		
		temod->name = IFACE_("Modifiers");
		for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) {
			TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index);
			te->name = md->name;
			te->directdata = md;
			
			if (md->type == eModifierType_Lattice) {
				outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0);
			}
			else if (md->type == eModifierType_Curve) {
				outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0);
			}
			else if (md->type == eModifierType_Armature) {
				outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0);
			}
			else if (md->type == eModifierType_Hook) {
				outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0);
			}
			else if (md->type == eModifierType_ParticleSystem) {
				TreeElement *ten;
				ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys;
				
				ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0);
				ten->directdata = psys;
				ten->name = psys->part->id.name + 2;
			}
		}
	}
	
	/* vertex groups */
	if (ob->defbase.first) {
		bDeformGroup *defgroup;
		TreeElement *ten;
		TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
		
		tenla->name = IFACE_("Vertex Groups");
		for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) {
			ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
			ten->name = defgroup->name;
			ten->directdata = defgroup;
		}
	}
	
	/* duplicated group */
	if (ob->dup_group)
		outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0);
}
static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl)
{
	TreeStoreElem *tselem = NULL;
	TreeElement *te = NULL;

	/* log stuff is to convert bitflags (powers of 2) to small integers,
	 * in order to not overflow short tselem->nr */
	
	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED));
	te->name = IFACE_("Combined");
	te->directdata = &srl->passflag;
	
	/* save cpu cycles, but we add the first to invoke an open/close triangle */
	tselem = TREESTORE(tenla);
	if (tselem->flag & TSE_CLOSED)
		return;
	
	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z));
	te->name = IFACE_("Z");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR));
	te->name = IFACE_("Vector");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL));
	te->name = IFACE_("Normal");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV));
	te->name = IFACE_("UV");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST));
	te->name = IFACE_("Mist");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB));
	te->name = IFACE_("Index Object");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA));
	te->name = IFACE_("Index Material");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA));
	te->name = IFACE_("Color");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE));
	te->name = IFACE_("Diffuse");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC));
	te->name = IFACE_("Specular");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW));
	te->name = IFACE_("Shadow");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO));
	te->name = IFACE_("AO");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT));
	te->name = IFACE_("Reflection");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT));
	te->name = IFACE_("Refraction");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT));
	te->name = IFACE_("Indirect");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT));
	te->name = IFACE_("Environment");
	te->directdata = &srl->passflag;

	te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT));
	te->name = IFACE_("Emit");
	te->directdata = &srl->passflag;
}
Beispiel #9
0
// TODO: this function needs to be split up! It's getting a bit too large...
static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, 
										 TreeElement *parent, short type, short index)
{
	TreeElement *te;
	TreeStoreElem *tselem;
	ID *id= idv;
	int a = 0;
	
	if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
		id= ((PointerRNA*)idv)->id.data;
		if(!id) id= ((PointerRNA*)idv)->data;
	}

	if(id==NULL) return NULL;

	te= MEM_callocN(sizeof(TreeElement), "tree elem");
	/* add to the visual tree */
	BLI_addtail(lb, te);
	/* add to the storage */
	check_persistant(soops, te, id, type, index);
	tselem= TREESTORE(te);	
	
	te->parent= parent;
	te->index= index;	// for data arays
	if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP));
	else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM));
	else if(type==TSE_ANIM_DATA);
	else {
		te->name= id->name+2; // default, can be overridden by Library or non-ID data
		te->idcode= GS(id->name);
	}
	
	if(type==0) {
		/* ID datablock */
		outliner_add_id_contents(soops, te, tselem, id);
	}
	else if(type==TSE_ANIM_DATA) {
		IdAdtTemplate *iat = (IdAdtTemplate *)idv;
		AnimData *adt= (AnimData *)iat->adt;
		
		/* this element's info */
		te->name= "Animation";
		te->directdata= adt;
		
		/* Action */
		outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0);
		
		/* Drivers */
		if (adt->drivers.first) {
			TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
			ID *lastadded= NULL;
			FCurve *fcu;
			
			ted->name= "Drivers";
		
			for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
				if (fcu->driver && fcu->driver->variables.first)  {
					ChannelDriver *driver= fcu->driver;
					DriverVar *dvar;
					
					for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
						/* loop over all targets used here */
						DRIVER_TARGETS_USED_LOOPER(dvar) 
						{
							if (lastadded != dtar->id) {
								// XXX this lastadded check is rather lame, and also fails quite badly...
								outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
								lastadded= dtar->id;
							}
						}
						DRIVER_TARGETS_LOOPER_END
					}
				}
			}