WIP #104054 Symmetize visible edit bones if nothing has been selected #105385

Closed
Denys Hsu wants to merge 3 commits from cgtinker/blender:104054-symmetrize-armature-nothing-selected into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 8 additions and 2 deletions
Showing only changes of commit 0b8d13ba19 - Show all commits

View File

@ -1100,9 +1100,15 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "direction");
const int axis = 0;
/* cancel if nothing selected */
/* select all visible bones if nothing selected */
if (CTX_DATA_COUNT(C, selected_bones) == 0) {

IMO is_selected doesn't quite cover the purpose. In other code I've used the name is_selection_relevant for this.

IMO `is_selected` doesn't quite cover the purpose. In other code I've used the name `is_selection_relevant` for this.
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) {
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);

The declaration and if can be reduced to:

const bool is_selected = CTX_DATA_COUNT(C, selected_bones) > 0;

This has the added advantage that now the variable can be const.

The declaration and `if` can be reduced to: ```c const bool is_selected = CTX_DATA_COUNT(C, selected_bones) > 0; ``` This has the added advantage that now the variable can be `const`.
if (ebone->parent) {
ebone->parent->flag |= BONE_TIPSEL;
}
}
CTX_DATA_END;
}
uint objects_len = 0;