diff options
author | Chris Want <cwant@ualberta.ca> | 2004-01-03 09:27:53 +0300 |
---|---|---|
committer | Chris Want <cwant@ualberta.ca> | 2004-01-03 09:27:53 +0300 |
commit | d2787f13722bf5fbfe4c006e7c839b18f8a752ba (patch) | |
tree | 0cecac8e6838bb6cdf09c681ec069c4e179ab310 /source | |
parent | 9f0123d0c793ae4289dcd9906ced8e832cadce64 (diff) |
When a bone is renamed, all constraints that point to it are
updated with the new name.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_editarmature.h | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 67 | ||||
-rw-r--r-- | source/blender/src/editarmature.c | 28 |
3 files changed, 68 insertions, 29 deletions
diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h index 8e059159dde..5d40f71b851 100644 --- a/source/blender/include/BIF_editarmature.h +++ b/source/blender/include/BIF_editarmature.h @@ -106,6 +106,8 @@ void selectconnected_armature(void); void selectconnected_posearmature(void); void select_bone_by_name (struct bArmature *arm, char *name, int select); void unique_editbone_name (char* name); +void attach_bone_to_parent(EditBone *bone); +void attach_bone_to_parent_cb(void *bonev, void *arg2_unused); struct Bone *get_first_selected_bone (void); void auto_align_armature(void); diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 915f4ef456e..4197a80d1f8 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1188,34 +1188,6 @@ static int editbone_to_parnr (EditBone *bone) return -1; } - - -static void attach_bone_to_parent(EditBone *bone) -{ - EditBone *curbone; - - if (bone->flag & BONE_IK_TOPARENT) { - - /* See if there are any other bones that refer to the same parent and disconnect them */ - for (curbone = G.edbo.first; curbone; curbone=curbone->next){ - if (curbone!=bone){ - if (curbone->parent && (curbone->parent == bone->parent) && (curbone->flag & BONE_IK_TOPARENT)) - curbone->flag &= ~BONE_IK_TOPARENT; - } - } - - /* Attach this bone to its parent */ - VECCOPY(bone->head, bone->parent->tail); - } - -} - -static void attach_bone_to_parent_cb(void *bonev, void *arg2_unused) -{ - EditBone *curBone= bonev; - attach_bone_to_parent(curBone); -} - static void parnr_to_editbone(EditBone *bone) { if (bone->parNr == -1){ @@ -1262,6 +1234,20 @@ static void build_bonestring (char *string, EditBone *bone){ } } +static void constraint_ebone_name_fix(ListBase *conlist, EditBone *eBone) +{ + + bConstraint *curcon; + char *subtarget; + + for (curcon = conlist->first; curcon; curcon=curcon->next){ + subtarget = get_con_subtarget_name(curcon, G.obedit); + if (subtarget) + if (!strcmp(subtarget,eBone->oldname) ) + strcpy(subtarget, eBone->name); + } +} + static void validate_editbonebutton(EditBone *eBone){ EditBone *prev; bAction *act=NULL; @@ -1300,12 +1286,35 @@ static void validate_editbonebutton(EditBone *eBone){ for (base = G.scene->base.first; base; base=base->next){ Object *ob = base->object; + ListBase *conlist; /* See if an object is parented to this armature */ - if (ob->parent && ob->partype==PARBONE && (ob->parent->type==OB_ARMATURE) && (ob->parent->data == G.obedit->data)){ + if (ob->parent && ob->partype==PARBONE && + (ob->parent->type==OB_ARMATURE) && + (ob->parent->data == G.obedit->data)){ if (!strcmp(ob->parsubstr, eBone->oldname)) strcpy(ob->parsubstr, eBone->name); } + + /* Update any constraints to use the new bone name */ + conlist = &ob->constraints; + constraint_ebone_name_fix(conlist, eBone); + + switch (ob->type){ + case OB_ARMATURE: + if (ob->pose){ + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; pchan; + pchan=pchan->next){ + conlist = &pchan->constraints; + constraint_ebone_name_fix(conlist, eBone); + } + } + break; + default: + break; + } + } exit_editmode(0); /* To ensure new names make it to the edit armature */ diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 85602d58178..f23ced64694 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1705,6 +1705,34 @@ static void add_bone_input (Object *ob) } +void attach_bone_to_parent_cb(void *bonev, void *arg2_unused) +{ + EditBone *curBone= bonev; + attach_bone_to_parent(curBone); +} + +void attach_bone_to_parent(EditBone *bone) +{ + EditBone *curbone; + + if (bone->flag & BONE_IK_TOPARENT) { + + /* See if there are any other bones that refer to the same + * parent and disconnect them + */ + for (curbone = G.edbo.first; curbone; curbone=curbone->next){ + if (curbone!=bone){ + if (curbone->parent && + (curbone->parent == bone->parent) && + (curbone->flag & BONE_IK_TOPARENT)) + curbone->flag &= ~BONE_IK_TOPARENT; + } + } + + /* Attach this bone to its parent */ + VECCOPY(bone->head, bone->parent->tail); + } +} void deselectall_armature(void) /* Actually, it toggles selection, deselecting |