[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38306] branches/soc-2011-pepper/source/ blender/editors/space_outliner/outliner_tree.c: Further Outliner code cleanup - Split out tree building stuff for ID

Joshua Leung aligorith at gmail.com
Mon Jul 11 15:36:39 CEST 2011


Revision: 38306
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38306
Author:   aligorith
Date:     2011-07-11 13:36:38 +0000 (Mon, 11 Jul 2011)
Log Message:
-----------
Further Outliner code cleanup - Split out tree building stuff for ID
blocks and Objects from add_element

These two chunks were significantly large that they really needed to
be placed into their own functions to allow for easier source
navigation.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/space_outliner/outliner_tree.c

Modified: branches/soc-2011-pepper/source/blender/editors/space_outliner/outliner_tree.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_outliner/outliner_tree.c	2011-07-11 12:38:44 UTC (rev 38305)
+++ branches/soc-2011-pepper/source/blender/editors/space_outliner/outliner_tree.c	2011-07-11 13:36:38 UTC (rev 38306)
@@ -299,6 +299,25 @@
 static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, 
 										 TreeElement *parent, short type, short index);
 
+/* -------------------------------------------------------- */
+
+/* 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);
+	}
+}
+
+/* -------------------------------------------------------- */
+
 #define LOG2I(x) (int)(log(x)/M_LN2)
 
 static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl)
@@ -389,21 +408,6 @@
 
 #undef LOG2I
 
-/* 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);
-	}
-}
-
 static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
 {
 	SceneRenderLayer *srl;
@@ -431,372 +435,397 @@
 	outliner_add_element(soops,  lb, sce->world, te, 0, 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)
+// can be inlined if necessary
+static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob)
 {
-	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);	
+	if (ob->adt)
+		outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
 	
-	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);
-	}
+	outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
 	
-	if(type==0) {
-		/* tuck pointer back in object, to construct hierarchy */
-		if(GS(id->name)==ID_OB) id->newid= (ID *)te;
+	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);
 		
-		/* 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:
-			{
-				Object *ob= (Object *)id;
+		tenla->name= "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->prev= (bPoseChannel *)ten;
 				
-				if (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= "Pose";
-					
-					if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) {	// channels undefined in editmode, but we want the 'tenla' pose icon itself
-						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->prev= (bPoseChannel *)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= "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->prev;
-									BLI_addtail(&par->subtree, ten);
-									ten->parent= par;
-								}
-							}
-							ten= nten;
-						}
-						/* restore prev pointers */
-						pchan= ob->pose->chanbase.first;
-						if(pchan) pchan->prev= NULL;
-						for(; pchan; pchan= pchan->next) {
-							if(pchan->next) pchan->next->prev= pchan;
-						}
-					}
-					
-					/* 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= "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) {
+				if(pchan->constraints.first) {
 					//Object *target;
 					bConstraint *con;
-					TreeElement *ten;
-					TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
-					int a= 0;
+					TreeElement *ten1;
+					TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
 					//char *str;
 					
-					tenla->name= "Constraints";
-					for(con= ob->constraints.first; 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 */
+					tenla1->name= "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]) ten->name= str;
-						else if(target) ten->name= target->id.name+2;
-						else ten->name= con->name;
+						if(str && str[0]) ten1->name= str;
+						else if(target) ten1->name= target->id.name+2;
+						else ten1->name= con->name;
 #endif
-						ten->name= con->name;
-						ten->directdata= con;
+						ten1->name= con->name;
+						ten1->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 = "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) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list