diff options
-rw-r--r-- | source/blender/blenkernel/BKE_action.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 17 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_naming.c | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_relations.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_utils.c | 27 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_transform.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 3 |
9 files changed, 44 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 5c155a46182..3ac5c8c9a76 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -146,6 +146,7 @@ void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, cons struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name); struct bPoseChannel *BKE_pose_channel_active(struct Object *ob); struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name); +struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name); #ifndef NDEBUG bool BKE_pose_channels_is_valid(const struct bPose *pose); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 94da2a330c1..fe0e3da605f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -53,6 +53,7 @@ #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_constraint.h" +#include "BKE_deform.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -539,6 +540,22 @@ bPoseChannel *BKE_pose_channel_active(Object *ob) return NULL; } +/** + * \see #ED_armature_bone_get_mirrored (edit-mode, matching function) + */ +bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name) +{ + char name_flip[MAXBONENAME]; + + BKE_deform_flip_side_name(name_flip, name, false); + + if (!STREQ(name_flip, name)) { + return BKE_pose_channel_find_name(pose, name_flip); + } + + return NULL; +} + const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 29eebe86afa..1bc5bf0fd74 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -1127,7 +1127,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan, *pchan_next; for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) { pchan_next = pchan->next; - curBone = editbone_name_exists(arm->edbo, pchan->name); + curBone = ED_armature_bone_find_name(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { BKE_pose_channel_free(pchan); @@ -1146,7 +1146,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == obedit) { if (ct->subtarget[0]) { - curBone = editbone_name_exists(arm->edbo, ct->subtarget); + curBone = ED_armature_bone_find_name(arm->edbo, ct->subtarget); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { con->flag |= CONSTRAINT_DISABLE; ct->subtarget[0] = 0; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 83800e598ba..3707e13095b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -229,9 +229,6 @@ struct EditBone *duplicateEditBoneObjects(struct EditBone *curBone, const char * /* editbones is the source list */ void updateDuplicateSubtargetObjects(struct EditBone *dupBone, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob); - -EditBone *editbone_name_exists(struct ListBase *edbo, const char *name); - EditBone *add_points_bone(struct Object *obedit, float head[3], float tail[3]); void bone_free(struct bArmature *arm, struct EditBone *bone); diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 10e97240898..c574fc6a297 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -67,17 +67,11 @@ /* ************************************************** */ /* EditBone Names */ -/* checks if an EditBone with a matching name already, returning the matching bone if it exists */ -EditBone *editbone_name_exists(ListBase *edbo, const char *name) -{ - return BLI_findstring(edbo, name, offsetof(EditBone, name)); -} - /* note: there's a unique_bone_name() too! */ static bool editbone_unique_check(void *arg, const char *name) { struct {ListBase *lb; void *bone; } *data = arg; - EditBone *dupli = editbone_name_exists(data->lb, name); + EditBone *dupli = ED_armature_bone_find_name(data->lb, name); return dupli && dupli != data->bone; } @@ -155,7 +149,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { - EditBone *eBone = editbone_name_exists(arm->edbo, oldname); + EditBone *eBone = ED_armature_bone_find_name(arm->edbo, oldname); if (eBone) { unique_editbone_name(arm->edbo, newname, NULL); diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 79d75c9fcda..cd24e94f9e9 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -230,7 +230,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Copy bones and posechannels from the object to the edit armature */ for (pchan = opose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = editbone_name_exists(curarm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(curarm->edbo, pchan->name); /* Get new name */ unique_editbone_name(arm->edbo, curbone->name, NULL); @@ -414,7 +414,7 @@ static void separate_armature_bones(Object *ob, short sel) /* go through pose-channels, checking if a bone should be removed */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = editbone_name_exists(arm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 7efeeebcf1d..2cbfb52db91 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -175,28 +175,35 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]) copy_v3_v3(mat[3], ebone->head); } +/** + * Return a pointer to the bone of the given name + */ +EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name) +{ + return BLI_findstring(edbo, name, offsetof(EditBone, name)); +} + + /* *************************************************************** */ /* Mirroring */ -/* context: editmode armature */ -EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) +/** + * \see #BKE_pose_channel_get_mirrored (pose-mode, matching function) + */ +EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo) { - EditBone *eboflip = NULL; char name_flip[MAXBONENAME]; - + if (ebo == NULL) return NULL; BKE_deform_flip_side_name(name_flip, ebo->name, false); - for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) { - if (ebo != eboflip) { - if (!strcmp(name_flip, eboflip->name)) - break; - } + if (!STREQ(name_flip, ebo->name)) { + return ED_armature_bone_find_name(edbo, name_flip); } - return eboflip; + return NULL; } /* ------------------------------------- */ diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 4e66c329088..578f048cb15 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -118,7 +118,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) pose = ob->pose; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - curbone = editbone_name_exists(arm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index bb4640949c1..455378fc2ce 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -128,7 +128,8 @@ bool mouse_armature(struct bContext *C, const int mval[2], bool extend, bool des int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone(struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); -EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators +EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name); +EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo); void ED_armature_sync_selection(struct ListBase *edbo); void ED_armature_validate_active(struct bArmature *arm); |