Bugfix #23575: Hook modifier don't update name of bone acting as the controller when...
authorJoshua Leung <aligorith@gmail.com>
Mon, 30 Aug 2010 01:07:45 +0000 (01:07 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 30 Aug 2010 01:07:45 +0000 (01:07 +0000)
source/blender/editors/armature/editarmature.c

index 174aadab68749361392e12b7f6bb876f201da863..8f19bb82b5cb2951fcade3b9a273cce825ce2486 100644 (file)
@@ -5460,6 +5460,8 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
                
                /* do entire dbase - objects */
                for (ob= G.main->object.first; ob; ob= ob->id.next) {
+                       ModifierData *md;
+                       
                        /* we have the object using the armature */
                        if (arm==ob->data) {
                                Object *cob;
@@ -5509,6 +5511,19 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
                                }
                        }
                        
+                       /* fix modifiers that might be using this name */
+                       for (md= ob->modifiers.first; md; md= md->next) {
+                               if (md->type == eModifierType_Hook) {
+                                       HookModifierData *hmd = (HookModifierData *)md;
+                                       
+                                       /* uses armature, so may use the affected bone name */
+                                       if (hmd->object && (hmd->object->data == arm)) {
+                                               if (!strcmp(hmd->subtarget, oldname))
+                                                       BLI_strncpy(hmd->subtarget, newname, MAXBONENAME);
+                                       }
+                               }
+                       }
+                       
                        /* Fix animation data attached to this object */
                        // TODO: should we be using the database wide version instead (since drivers may break)
                        if (ob->adt) {