[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33931] trunk/blender/source/blender/ blenkernel/intern/anim_sys.c: Consistency cleanups for AnimData stuff:

Joshua Leung aligorith at gmail.com
Wed Dec 29 06:20:21 CET 2010


Revision: 33931
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33931
Author:   aligorith
Date:     2010-12-29 06:20:19 +0100 (Wed, 29 Dec 2010)

Log Message:
-----------
Consistency cleanups for AnimData stuff:
Some AnimData looping functions were not updated to take into account
the addition of AnimData for some additional datatypes (i.e. meshes
and lattices) as well as the changes to make nested nodetrees (i.e.
for Material and Texture nodes).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/anim_sys.c

Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2010-12-28 17:03:09 UTC (rev 33930)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2010-12-29 05:20:19 UTC (rev 33931)
@@ -465,44 +465,73 @@
 /* Whole Database Ops -------------------------------------------- */
 
 /* apply the given callback function on all data in main database */
-void BKE_animdata_main_cb (Main *main, ID_AnimData_Edit_Callback func, void *user_data)
+void BKE_animdata_main_cb (Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data)
 {
 	ID *id;
 
+	/* standard data version */
 #define ANIMDATA_IDS_CB(first) \
 	for (id= first; id; id= id->next) { \
 		AnimData *adt= BKE_animdata_from_id(id); \
 		if (adt) func(id, adt, user_data); \
 	}
-
-	ANIMDATA_IDS_CB(main->nodetree.first);	/* nodes */
-	ANIMDATA_IDS_CB(main->tex.first);		/* textures */
-	ANIMDATA_IDS_CB(main->lamp.first);		/* lamps */
-	ANIMDATA_IDS_CB(main->mat.first);		/* materials */
-	ANIMDATA_IDS_CB(main->camera.first);	/* cameras */
-	ANIMDATA_IDS_CB(main->key.first);		/* shapekeys */
-	ANIMDATA_IDS_CB(main->mball.first);		/* metaballs */
-	ANIMDATA_IDS_CB(main->curve.first);		/* curves */
-	ANIMDATA_IDS_CB(main->armature.first);	/* armatures */
-	ANIMDATA_IDS_CB(main->mesh.first);		/* meshes */
-	ANIMDATA_IDS_CB(main->particle.first);	/* particles */
-	ANIMDATA_IDS_CB(main->object.first);	/* objects */
-	ANIMDATA_IDS_CB(main->world.first);		/* worlds */
-
+	
+	/* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */
+#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \
+	for (id= first; id; id= id->next) { \
+		AnimData *adt= BKE_animdata_from_id(id); \
+		NtId_Type *ntp= (NtId_Type *)id; \
+		if (ntp->nodetree) { \
+			AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
+			if (adt2) func(id, adt2, user_data); \
+		} \
+		if (adt) func(id, adt, user_data); \
+	}
+	
+	/* nodes */
+	ANIMDATA_IDS_CB(mainptr->nodetree.first);
+	
+	/* textures */
+	ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex);
+	
+	/* lamps */
+	ANIMDATA_IDS_CB(mainptr->lamp.first);
+	
+	/* materials */
+	ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material);
+	
+	/* cameras */
+	ANIMDATA_IDS_CB(mainptr->camera.first);
+	
+	/* shapekeys */
+	ANIMDATA_IDS_CB(mainptr->key.first);
+	
+	/* metaballs */
+	ANIMDATA_IDS_CB(mainptr->mball.first);
+	
+	/* curves */
+	ANIMDATA_IDS_CB(mainptr->curve.first);
+	
+	/* armatures */
+	ANIMDATA_IDS_CB(mainptr->armature.first);
+	
+	/* lattices */
+	ANIMDATA_IDS_CB(mainptr->latt.first);
+	
+	/* meshes */
+	ANIMDATA_IDS_CB(mainptr->mesh.first);
+	
+	/* particles */
+	ANIMDATA_IDS_CB(mainptr->particle.first);
+	
+	/* objects */
+	ANIMDATA_IDS_CB(mainptr->object.first);
+	
+	/* worlds */
+	ANIMDATA_IDS_CB(mainptr->world.first);
+	
 	/* scenes */
-	for (id= main->scene.first; id; id= id->next) {
-		AnimData *adt= BKE_animdata_from_id(id);
-		Scene *scene= (Scene *)id;
-		
-		/* do compositing nodes first (since these aren't included in main tree) */
-		if (scene->nodetree) {
-			AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree);
-			if (adt2) func(id, adt2, user_data);
-		}
-		
-		/* now fix scene animation data as per normal */
-		if (adt) func((ID *)id, adt, user_data);
-	}
+	ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
 }
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
@@ -525,17 +554,29 @@
 		BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\
 	}
 	
+	/* another version of this macro for nodetrees */
+#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
+	for (id= first; id; id= id->next) { \
+		AnimData *adt= BKE_animdata_from_id(id); \
+		NtId_Type *ntp= (NtId_Type *)id; \
+		if (ntp->nodetree) { \
+			AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
+			BKE_animdata_fix_paths_rename((ID *)ntp, adt2, prefix, oldName, newName, 0, 0, 1);\
+		} \
+		BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\
+	}
+	
 	/* nodes */
 	RENAMEFIX_ANIM_IDS(mainptr->nodetree.first);
 	
 	/* textures */
-	RENAMEFIX_ANIM_IDS(mainptr->tex.first);
+	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex);
 	
 	/* lamps */
 	RENAMEFIX_ANIM_IDS(mainptr->lamp.first);
 	
 	/* materials */
-	RENAMEFIX_ANIM_IDS(mainptr->mat.first);
+	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->mat.first, Material);
 	
 	/* cameras */
 	RENAMEFIX_ANIM_IDS(mainptr->camera.first);
@@ -552,8 +593,11 @@
 	/* armatures */
 	RENAMEFIX_ANIM_IDS(mainptr->armature.first);
 	
+	/* lattices */
+	RENAMEFIX_ANIM_IDS(mainptr->latt.first);
+	
 	/* meshes */
-	// TODO...
+	RENAMEFIX_ANIM_IDS(mainptr->mesh.first);
 	
 	/* particles */
 	RENAMEFIX_ANIM_IDS(mainptr->particle.first);
@@ -565,19 +609,7 @@
 	RENAMEFIX_ANIM_IDS(mainptr->world.first);
 	
 	/* scenes */
-	for (id= mainptr->scene.first; id; id= id->next) {
-		AnimData *adt= BKE_animdata_from_id(id);
-		Scene *scene= (Scene *)id;
-		
-		/* do compositing nodes first (since these aren't included in main tree) */
-		if (scene->nodetree) {
-			AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree);
-			BKE_animdata_fix_paths_rename((ID *)scene->nodetree, adt2, prefix, oldName, newName, 0, 0, 1);
-		}
-		
-		/* now fix scene animation data as per normal */
-		BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, newName, 0, 0, 1);
-	}
+	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
 }
 
 /* *********************************** */ 
@@ -1901,7 +1933,6 @@
 	EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM);
 	
 	/* shapekeys */
-		// TODO: we probably need the same hack as for curves (ctime-hack)
 	EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM);
 	
 	/* metaballs */





More information about the Bf-blender-cvs mailing list