Multi-Objects: ARMATURE_OT_select_hierarchy

This commit is contained in:
Dalai Felinto
2018-10-02 17:35:07 +00:00
parent 27f2108e8a
commit dcc623e7e7

View File

@@ -1238,20 +1238,26 @@ void ARMATURE_OT_select_similar(wmOperatorType *ot)
static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Object *ob;
bArmature *arm;
EditBone *ebone_active;
int direction = RNA_enum_get(op->ptr, "direction");
ViewLayer *view_layer = CTX_data_view_layer(C);
const int direction = RNA_enum_get(op->ptr, "direction");
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
bool multi_changed = false;
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;
EditBone *ebone_active;
bool changed = false;
ob = obedit;
arm = (bArmature *)ob->data;
ebone_active = arm->act_edbone;
if (ebone_active == NULL) {
return OPERATOR_CANCELLED;
continue;
}
if (direction == BONE_SELECT_PARENT) {
@@ -1277,10 +1283,10 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
EditBone *ebone_iter, *ebone_child = NULL;
int pass;
/* first pass, only connected bones (the logical direct child) */
/* First pass, only connected bones (the logical direct child)/ */
for (pass = 0; pass < 2 && (ebone_child == NULL); pass++) {
for (ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
/* possible we have multiple children, some invisible */
/* Possible we have multiple children, some invisible. */
if (EBONE_SELECTABLE(arm, ebone_iter)) {
if (ebone_iter->parent == ebone_active) {
if ((pass == 1) || (ebone_iter->flag & BONE_CONNECTED)) {
@@ -1305,14 +1311,16 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
}
if (changed == false) {
return OPERATOR_CANCELLED;
continue;
}
multi_changed = true;
ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
return multi_changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)