diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-11-18 05:52:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-11-18 05:56:35 +0300 |
commit | cd1d9950aba1f4c759769e4896f2a9953d982eec (patch) | |
tree | a6dee8e6ea6d9274fed8c11eaacc2841dc0700ec /source/blender/editors/armature | |
parent | 119846a6bb366f5ae13db18d965083d7927ff11e (diff) |
Add select similar custom bone shape
D2820 by @col-one w/ edits
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/armature_select.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 93185971492..f9819887094 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -38,7 +38,7 @@ #include "BLI_string_utils.h" #include "BKE_context.h" -//#include "BKE_deform.h" +#include "BKE_action.h" #include "BKE_report.h" #include "BIF_gl.h" @@ -801,6 +801,7 @@ enum { SIMEDBONE_PREFIX, SIMEDBONE_SUFFIX, SIMEDBONE_LAYER, + SIMEDBONE_SHAPE, }; static const EnumPropertyItem prop_similar_types[] = { @@ -812,6 +813,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMEDBONE_PREFIX, "PREFIX", 0, "Prefix", ""}, {SIMEDBONE_SUFFIX, "SUFFIX", 0, "Suffix", ""}, {SIMEDBONE_LAYER, "LAYER", 0, "Layer", ""}, + {SIMEDBONE_SHAPE, "SHAPE", 0, "Shape", ""}, {0, NULL, 0, NULL, NULL} }; @@ -914,6 +916,26 @@ static void select_similar_suffix(bArmature *arm, EditBone *ebone_act) } } +/** Use for matching any pose channel data. */ +static void select_similar_data_pchan( + bArmature *arm, Object *obj, EditBone *ebone_active, + const size_t bytes_size, const int offset) +{ + const bPoseChannel *pchan_active = BKE_pose_channel_find_name(obj->pose, ebone_active->name); + const char *data_active = (const char *)POINTER_OFFSET(pchan_active, offset); + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_SELECTABLE(arm, ebone)) { + const bPoseChannel *pchan = BKE_pose_channel_find_name(obj->pose, ebone->name); + if (pchan) { + const char *data_test = (const char *)POINTER_OFFSET(pchan, offset); + if (memcmp(data_active, data_test, bytes_size) == 0) { + ED_armature_ebone_select_set(ebone, true); + } + } + } + } +} + static void is_ancestor(EditBone * bone, EditBone * ancestor) { if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) @@ -1006,6 +1028,11 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op) case SIMEDBONE_LAYER: select_similar_layer(arm, ebone_act); break; + case SIMEDBONE_SHAPE: + select_similar_data_pchan( + arm, obedit, ebone_act, + sizeof(void *), offsetof(bPoseChannel, custom)); + break; } WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); |