[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28800] trunk/blender/source/blender/ blenkernel/intern/anim_sys.c: Drivers Bugfix:

Joshua Leung aligorith at gmail.com
Mon May 17 06:22:43 CEST 2010


Revision: 28800
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28800
Author:   aligorith
Date:     2010-05-17 06:22:41 +0200 (Mon, 17 May 2010)

Log Message:
-----------
Drivers Bugfix:

Renaming bones now correctly fixes drivers referencing those bones. This includes driver paths and driver variables.

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-05-17 00:10:16 UTC (rev 28799)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2010-05-17 04:22:41 UTC (rev 28800)
@@ -339,6 +339,19 @@
 		/* firstly, handle the F-Curve's own path */
 		if (fcu->rna_path)
 			fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths);
+	}
+}
+
+/* Check RNA-Paths for a list of Drivers */
+static void drivers_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths)
+{
+	FCurve *fcu;
+	
+	/* we need to check every curve - drivers are F-Curves too! */
+	for (fcu= curves->first; fcu; fcu= fcu->next) {
+		/* firstly, handle the F-Curve's own path */
+		if (fcu->rna_path)
+			fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
 		
 		/* driver? */
 		if (fcu->driver) {
@@ -352,15 +365,16 @@
 				{
 					/* rename RNA path */
 					if (dtar->rna_path)
-						dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path, verify_paths);
+						dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
 					
 					/* also fix the bone-name (if applicable) */
-					// XXX this has been disabled because the old/new names have padding which means this check will fail
-					//if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) &&
-					//	 (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) )
-					//{
-					//	BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
-					//}
+					if (strstr(prefix, "bones")) {
+						if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) &&
+							 (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) )
+						{
+							BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
+						}
+					}
 				}
 				DRIVER_TARGETS_LOOPER_END
 			}
@@ -398,11 +412,12 @@
 	if (ELEM(NULL, owner_id, adt))
 		return;
 	
-	if (oldName != NULL && newName != NULL) {
+	if ((oldName != NULL) && (newName != NULL)) {
 		/* pad the names with [" "] so that only exact matches are made */
 		oldN= BLI_sprintfN("[\"%s\"]", oldName);
 		newN= BLI_sprintfN("[\"%s\"]", newName);
-	} else {
+	} 
+	else {
 		oldN= BLI_sprintfN("[%d]", oldSubscript);
 		newN= BLI_sprintfN("[%d]", newSubscript);
 	}
@@ -414,7 +429,7 @@
 		fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves, verify_paths);
 		
 	/* Drivers - Drivers are really F-Curves */
-	fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers, verify_paths);
+	drivers_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths);
 	
 	/* NLA Data - Animation Data for Strips */
 	for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next)





More information about the Bf-blender-cvs mailing list