[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57221] trunk/blender/source/blender/ editors/object/object_relations.c: Fix #35378: Shape Key Animation Data still linked when creating full copy of scene

Sergey Sharybin sergey.vfx at gmail.com
Mon Jun 3 14:28:46 CEST 2013


Revision: 57221
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57221
Author:   nazgul
Date:     2013-06-03 12:28:46 +0000 (Mon, 03 Jun 2013)
Log Message:
-----------
Fix #35378: Shape Key Animation Data still linked when creating full copy of scene

Two issues were found:

- Mesh/Curve/Lattice kay blocks weren't copying their actions
  when making object data local. This lead to object data using
  diffrent AnimData structures which were using the same action.

- Copying actions shall happen after object object data was
  localized. This is so because otherwise we'll copy actions
  for original AnimData, not for copied one.

Reviewed by Joshua, thanks!

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

Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c	2013-06-03 08:26:12 UTC (rev 57220)
+++ trunk/blender/source/blender/editors/object/object_relations.c	2013-06-03 12:28:46 UTC (rev 57221)
@@ -1712,6 +1712,7 @@
 	//Camera *cam;
 	Base *base;
 	Mesh *me;
+	Lattice *lat;
 	ID *id;
 	int a;
 
@@ -1722,9 +1723,7 @@
 			
 			if (id && id->us > 1 && id->lib == NULL) {
 				DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-				
-				BKE_copy_animdata_id_action(id);
-				
+
 				switch (ob->type) {
 					case OB_LAMP:
 						ob->data = la = BKE_lamp_copy(ob->data);
@@ -1738,10 +1737,9 @@
 						ob->data = BKE_camera_copy(ob->data);
 						break;
 					case OB_MESH:
-						ob->data = BKE_mesh_copy(ob->data);
-						//me = ob->data;
-						//if (me && me->key)
-						//	ipo_idnew(me->key->ipo);	/* drivers */
+						ob->data = me = BKE_mesh_copy(ob->data);
+						if (me->key)
+							BKE_copy_animdata_id_action((ID*)me->key);
 						break;
 					case OB_MBALL:
 						ob->data = BKE_mball_copy(ob->data);
@@ -1752,9 +1750,13 @@
 						ob->data = cu = BKE_curve_copy(ob->data);
 						ID_NEW(cu->bevobj);
 						ID_NEW(cu->taperobj);
+						if (cu->key)
+							BKE_copy_animdata_id_action((ID*)cu->key);
 						break;
 					case OB_LATTICE:
-						ob->data = BKE_lattice_copy(ob->data);
+						ob->data = lat = BKE_lattice_copy(ob->data);
+						if (lat->key)
+							BKE_copy_animdata_id_action((ID*)lat->key);
 						break;
 					case OB_ARMATURE:
 						DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1769,7 +1771,14 @@
 							printf("ERROR %s: can't copy %s\n", __func__, id->name);
 						return;
 				}
-				
+
+				/* Copy animation data after object data became local,
+				 * otherwise old and new object data will share the same
+				 * AnimData structure, which is not what we want.
+				 *                                             (sergey)
+				 */
+				BKE_copy_animdata_id_action((ID*)ob->data);
+
 				id->us--;
 				id->newid = ob->data;
 				




More information about the Bf-blender-cvs mailing list