Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/include/BIF_editarmature.h2
-rw-r--r--source/blender/src/buttons_editing.c67
-rw-r--r--source/blender/src/editarmature.c28
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