diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-02 22:38:00 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-02 22:47:10 +0300 |
commit | ecce4f49bb1c2b114069a5a6ee2df676ed3e3286 (patch) | |
tree | 9a1f5639bdee1a618c9054b559db58e8a17b05be | |
parent | 6b3ff1ec75a7b3f7337fb6669ed5bfd3a414e431 (diff) |
Multi-Objecs: Select similar armature: SIMEDBONE_PREFIX and SIMEDBONE_SUFFIX
-rw-r--r-- | source/blender/editors/armature/armature_select.c | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 393faaa78c5..b4ec133f3ef 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -1087,33 +1087,52 @@ static void select_similar_layer(bArmature *arm, EditBone *ebone_act) } } -static void select_similar_prefix(bArmature *arm, EditBone *ebone_act) +static void select_similar_prefix(bContext *C) { - EditBone *ebone; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob_act = CTX_data_edit_object(C); + EditBone *ebone_act = CTX_data_active_bone(C); char body_tmp[MAXBONENAME]; char prefix_act[MAXBONENAME]; BLI_string_split_prefix(ebone_act->name, prefix_act, body_tmp, sizeof(ebone_act->name)); - if (prefix_act[0] == '\0') + if (prefix_act[0] == '\0') { return; + } - /* Find matches */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - if (EBONE_SELECTABLE(arm, ebone)) { - char prefix_other[MAXBONENAME]; - BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name)); - if (STREQ(prefix_act, prefix_other)) { - ED_armature_ebone_select_set(ebone, true); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object * ob = objects[ob_index]; + bArmature * arm = ob->data; + bool changed = false; + + /* Find matches */ + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_SELECTABLE(arm, ebone)) { + char prefix_other[MAXBONENAME]; + BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name)); + if (STREQ(prefix_act, prefix_other)) { + ED_armature_ebone_select_set(ebone, true); + changed = true; + } } } + + if (changed) { + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + } } + MEM_freeN(objects); } -static void select_similar_suffix(bArmature *arm, EditBone *ebone_act) +static void select_similar_suffix(bContext *C) { - EditBone *ebone; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob_act = CTX_data_edit_object(C); + EditBone *ebone_act = CTX_data_active_bone(C); char body_tmp[MAXBONENAME]; char suffix_act[MAXBONENAME]; @@ -1123,16 +1142,30 @@ static void select_similar_suffix(bArmature *arm, EditBone *ebone_act) if (suffix_act[0] == '\0') return; - /* Find matches */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - if (EBONE_SELECTABLE(arm, ebone)) { - char suffix_other[MAXBONENAME]; - BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name)); - if (STREQ(suffix_act, suffix_other)) { - ED_armature_ebone_select_set(ebone, true); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object * ob = objects[ob_index]; + bArmature * arm = ob->data; + bool changed = false; + + /* Find matches */ + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_SELECTABLE(arm, ebone)) { + char suffix_other[MAXBONENAME]; + BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name)); + if (STREQ(suffix_act, suffix_other)) { + ED_armature_ebone_select_set(ebone, true); + changed = true; + } } } + + if (changed) { + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + } } + MEM_freeN(objects); } /** Use for matching any pose channel data. */ @@ -1236,11 +1269,7 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); float thresh = RNA_float_get(op->ptr, "threshold"); - if (ELEM(type, - SIMEDBONE_PREFIX, - SIMEDBONE_SUFFIX, - SIMEDBONE_LAYER)) - { + if (type == SIMEDBONE_LAYER) { BKE_report(op->reports, RPT_ERROR, "Armature select similar mode not supported at the moment"); return OPERATOR_CANCELLED; } @@ -1271,10 +1300,10 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op) select_similar_direction(C, thresh); break; case SIMEDBONE_PREFIX: - select_similar_prefix(arm, ebone_act); + select_similar_prefix(C); break; case SIMEDBONE_SUFFIX: - select_similar_suffix(arm, ebone_act); + select_similar_suffix(C); break; case SIMEDBONE_LAYER: select_similar_layer(arm, ebone_act); |