[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33788] trunk/blender/source/blender: Option "Make Single user" now also makes animations local.

Ton Roosendaal ton at blender.org
Sun Dec 19 14:50:32 CET 2010


Revision: 33788
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33788
Author:   ton
Date:     2010-12-19 14:50:31 +0100 (Sun, 19 Dec 2010)

Log Message:
-----------
Option "Make Single user" now also makes animations local.
Note that the menu option "Animation" only was working for
Object level animations, so I've changed the many name
accordingly.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/material.c
    trunk/blender/source/blender/editors/object/object_relations.c

Modified: trunk/blender/source/blender/blenkernel/intern/material.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/material.c	2010-12-19 13:48:45 UTC (rev 33787)
+++ trunk/blender/source/blender/blenkernel/intern/material.c	2010-12-19 13:50:31 UTC (rev 33788)
@@ -203,9 +203,6 @@
 	
 	man= copy_libblock(ma);
 	
-#if 0 // XXX old animation system
-	id_us_plus((ID *)man->ipo);
-#endif // XXX old animation system
 	id_lib_extern((ID *)man->group);
 	
 	for(a=0; a<MAX_MTEX; a++) {

Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c	2010-12-19 13:48:45 UTC (rev 33787)
+++ trunk/blender/source/blender/editors/object/object_relations.c	2010-12-19 13:50:31 UTC (rev 33788)
@@ -1444,17 +1444,17 @@
 		if(ob->id.lib==NULL && (base->flag & flag)==flag ) {
 			id= ob->data;
 			
-			if(id && id->us>1 && id->lib==0) {
+			if(id && id->us>1 && id->lib==NULL) {
 				ob->recalc= OB_RECALC_DATA;
 				
+				BKE_copy_animdata_id_action(id);
+				
 				switch(ob->type) {
 				case OB_LAMP:
-					if(id && id->us>1 && id->lib==NULL) {
-						ob->data= la= copy_lamp(ob->data);
-						for(a=0; a<MAX_MTEX; a++) {
-							if(la->mtex[a]) {
-								ID_NEW(la->mtex[a]->object);
-							}
+					ob->data= la= copy_lamp(ob->data);
+					for(a=0; a<MAX_MTEX; a++) {
+						if(la->mtex[a]) {
+							ID_NEW(la->mtex[a]->object);
 						}
 					}
 					break;
@@ -1495,52 +1495,6 @@
 				
 			}
 			
-#if 0 // XXX old animation system
-			id= (ID *)ob->action;
-			if (id && id->us>1 && id->lib==NULL){
-				if(id->newid){
-					ob->action= (bAction *)id->newid;
-					id_us_plus(id->newid);
-				}
-				else {
-					ob->action= copy_action(ob->action);
-					id->us--;
-					id->newid=(ID *)ob->action;
-				}
-			}
-			id= (ID *)ob->ipo;
-			if(id && id->us>1 && id->lib==NULL) {
-				if(id->newid) {
-					ob->ipo= (Ipo *)id->newid;
-					id_us_plus(id->newid);
-				}
-				else {
-					ob->ipo= copy_ipo(ob->ipo);
-					id->us--;
-					id->newid= (ID *)ob->ipo;
-				}
-				ipo_idnew(ob->ipo);	/* drivers */
-			}
-			/* other ipos */
-			switch(ob->type) {
-			case OB_LAMP:
-				la= ob->data;
-				if(la->ipo && la->ipo->id.us>1) {
-					la->ipo->id.us--;
-					la->ipo= copy_ipo(la->ipo);
-					ipo_idnew(la->ipo);	/* drivers */
-				}
-				break;
-			case OB_CAMERA:
-				cam= ob->data;
-				if(cam->ipo && cam->ipo->id.us>1) {
-					cam->ipo->id.us--;
-					cam->ipo= copy_ipo(cam->ipo);
-					ipo_idnew(cam->ipo);	/* drivers */
-				}
-				break;
-			}
-#endif // XXX old animation system
 		}
 	}
 	
@@ -1551,29 +1505,18 @@
 	}
 }
 
-void single_ipo_users(Scene *UNUSED(scene), int UNUSED(flag))
+static void single_object_action_users(Scene *scene, int flag)
 {
-#if 0 // XXX old animation system
 	Object *ob;
 	Base *base;
-	ID *id;
 	
 	for(base= FIRSTBASE; base; base= base->next) {
 		ob= base->object;
 		if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
 			ob->recalc= OB_RECALC_DATA;
-			
-			id= (ID *)ob->ipo;
-			if(id && id->us>1 && id->lib==NULL) {
-				ob->ipo= copy_ipo(ob->ipo);
-				id->us--;
-				ipo_idnew(ob->ipo);	/* drivers */
-			}
+			BKE_copy_animdata_id_action(&ob->id);
 		}
 	}
-#endif // XXX old animation system
-	// TODO, something like this but must check users first.
-	// BKE_copy_animdata_id_action((ID *)obn->data);
 }
 
 static void single_mat_users(Scene *scene, int flag, int do_textures)
@@ -1595,17 +1538,11 @@
 					
 					if(ma->id.us>1) {
 						man= copy_material(ma);
-					
+						BKE_copy_animdata_id_action(&man->id);
+						
 						man->id.us= 0;
 						assign_material(ob, man, a);
-	
-#if 0 // XXX old animation system						
-						if(ma->ipo) {
-							man->ipo= copy_ipo(ma->ipo);
-							ma->ipo->id.us--;
-							ipo_idnew(ma->ipo);	/* drivers */
-						}
-#endif // XXX old animation system
+
 						if(do_textures) {
 							for(b=0; b<MAX_MTEX; b++) {
 								if(ma->mtex[b] && ma->mtex[b]->tex) {
@@ -1638,6 +1575,7 @@
 	}
 	else if(tex->id.us>1) {
 		texn= copy_texture(tex);
+		BKE_copy_animdata_id_action(&texn->id);
 		tex->id.newid= (ID *)texn;
 		tex->id.us--;
 		*from= texn;
@@ -1878,7 +1816,7 @@
 		single_mat_users(scene, flag, TRUE);
 
 	if(RNA_boolean_get(op->ptr, "animation"))
-		single_ipo_users(scene, flag);
+		single_object_action_users(scene, flag);
 
 	clear_id_newpoins();
 
@@ -1913,7 +1851,7 @@
 	RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data");
 	RNA_def_boolean(ot->srna, "material", 0, "Materials", "Make materials local to each datablock");
 	RNA_def_boolean(ot->srna, "texture", 0, "Textures", "Make textures local to each material");
-	RNA_def_boolean(ot->srna, "animation", 0, "Animation Data", "Make animation data local to each object");
+	RNA_def_boolean(ot->srna, "animation", 0, "Object Animation", "Make animation data local to each object");
 }
 
 static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event)





More information about the Bf-blender-cvs mailing list