diff options
Diffstat (limited to 'source/blender/editors/armature/armature_edit.c')
-rw-r--r-- | source/blender/editors/armature/armature_edit.c | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 47e73f9b777..4562329706f 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -66,7 +66,7 @@ /* ************************** Object Tools Exports ******************************* */ /* NOTE: these functions are exported to the Object module to be called from the tools there */ -void ED_armature_apply_transform(Object *ob, float mat[4][4]) +void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_props) { bArmature *arm = ob->data; @@ -74,14 +74,14 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) ED_armature_to_edit(arm); /* Transform the bones */ - ED_armature_transform_bones(arm, mat); + ED_armature_transform_bones(arm, mat, do_props); /* Turn the list into an armature */ ED_armature_from_edit(arm); ED_armature_edit_free(arm); } -void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4]) +void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props) { EditBone *ebone; float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ @@ -106,27 +106,29 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4]) /* apply the transformed roll back */ mat3_to_vec_roll(tmat, NULL, &ebone->roll); - ebone->rad_head *= scale; - ebone->rad_tail *= scale; - ebone->dist *= scale; - - /* we could be smarter and scale by the matrix along the x & z axis */ - ebone->xwidth *= scale; - ebone->zwidth *= scale; + if (do_props) { + ebone->rad_head *= scale; + ebone->rad_tail *= scale; + ebone->dist *= scale; + + /* we could be smarter and scale by the matrix along the x & z axis */ + ebone->xwidth *= scale; + ebone->zwidth *= scale; + } } } -void ED_armature_transform(struct bArmature *arm, float mat[4][4]) +void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props) { if (arm->edbo) { - ED_armature_transform_bones(arm, mat); + ED_armature_transform_bones(arm, mat, do_props); } else { /* Put the armature into editmode */ ED_armature_to_edit(arm); /* Transform the bones */ - ED_armature_transform_bones(arm, mat); + ED_armature_transform_bones(arm, mat, do_props); /* Go back to object mode*/ ED_armature_from_edit(arm); @@ -203,7 +205,7 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente /* adjust bone roll to align Z axis with vector * vec is in local space and is normalized */ -float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool axis_only) +float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only) { float mat[3][3], nor[3]; float vec[3], align_axis_proj[3], roll = 0.0f; @@ -220,7 +222,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool vec_roll_to_mat3_normalized(nor, 0.0f, mat); /* project the new_up_axis along the normal */ - project_v3_v3v3(vec, align_axis, nor); + project_v3_v3v3_normalized(vec, align_axis, nor); sub_v3_v3v3(align_axis_proj, align_axis, vec); if (axis_only) { @@ -263,7 +265,7 @@ typedef enum eCalcRollTypes { CALC_ROLL_CURSOR, } eCalcRollTypes; -static EnumPropertyItem prop_calc_roll_types[] = { +static const EnumPropertyItem prop_calc_roll_types[] = { {0, "", 0, N_("Positive"), ""}, {CALC_ROLL_TAN_POS_X, "POS_X", 0, "Local +X Tangent", ""}, {CALC_ROLL_TAN_POS_Z, "POS_Z", 0, "Local +Z Tangent", ""}, @@ -329,7 +331,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); if (axis_flip) negate_v3(cursor_rel); if (normalize_v3(cursor_rel) != 0.0f) { - ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only); } } } @@ -368,13 +370,13 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) if (axis_flip) negate_v3(vec); if (is_edit) { - ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only); } /* parentless bones use cross product with child */ if (is_edit_parent) { if (ebone->parent->parent == NULL) { - ebone->parent->roll = ED_rollBoneToVector(ebone->parent, vec, axis_only); + ebone->parent->roll = ED_armature_ebone_roll_to_vector(ebone->parent, vec, axis_only); } } } @@ -418,7 +420,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ - ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only); } } } @@ -426,7 +428,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) if (arm->flag & ARM_MIRROR_EDIT) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { ebone->roll = -ebone_mirr->roll; } @@ -480,7 +482,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op) if (arm->flag & ARM_MIRROR_EDIT) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { ebone->roll = -ebone_mirr->roll; } @@ -769,7 +771,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) } if (newbone) { - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); arm->act_edbone = newbone; newbone->flag |= BONE_TIPSEL; } @@ -881,7 +883,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone } newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); } @@ -957,7 +959,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) } /* updates */ - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); return OPERATOR_FINISHED; @@ -965,7 +967,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) void ARMATURE_OT_merge(wmOperatorType *ot) { - static EnumPropertyItem merge_types[] = { + static const EnumPropertyItem merge_types[] = { {1, "WITHIN_CHAIN", 0, "Within Chains", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1179,7 +1181,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) actmirb = actbone; } @@ -1291,7 +1293,7 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p) bArmature *arm = arm_p; EditBone *ebone; - ebone = ED_armature_bone_find_name(arm->edbo, bone_name); + ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); return (ebone && (ebone->flag & BONE_SELECTED) && (arm->layer & ebone->layer)); } @@ -1301,7 +1303,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; EditBone *curBone, *ebone_next; - Object *obedit = CTX_data_edit_object(C); // XXX get from context + Object *obedit = CTX_data_edit_object(C); bool changed = false; arm = obedit->data; @@ -1318,7 +1320,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { if (curBone == arm->act_edbone) arm->act_edbone = NULL; - ED_armature_edit_bone_remove(arm, curBone); + ED_armature_ebone_remove(arm, curBone); changed = true; } } @@ -1327,7 +1329,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) if (!changed) return OPERATOR_CANCELLED; - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1356,7 +1358,7 @@ static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p) bArmature *arm = arm_p; EditBone *ebone; - ebone = ED_armature_bone_find_name(arm->edbo, bone_name); + ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); return (ebone && (ebone->flag & BONE_DONE)); } @@ -1456,8 +1458,9 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) if (ebone->flag & BONE_DONE) { copy_v3_v3(ebone->parent->tail, ebone->tail); ebone->parent->rad_tail = ebone->rad_tail; + SET_FLAG_FROM_TEST(ebone->parent->flag, ebone->flag & BONE_TIPSEL, BONE_TIPSEL); - ED_armature_edit_bone_remove(arm, ebone); + ED_armature_ebone_remove_ex(arm, ebone, false); changed = true; } } @@ -1466,10 +1469,9 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (ebone->parent && ebone->parent->temp.ebone && - (ebone->flag & BONE_CONNECTED) == 0) + (ebone->flag & BONE_CONNECTED)) { - ebone->flag |= BONE_CONNECTED; - ebone->rad_head = ebone->parent->rad_head; + ebone->rad_head = ebone->parent->rad_tail; } } @@ -1491,7 +1493,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1536,8 +1538,8 @@ static int armature_hide_exec(bContext *C, wmOperator *op) } } } - ED_armature_validate_active(arm); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1562,24 +1564,25 @@ void ARMATURE_OT_hide(wmOperatorType *ot) RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); } -static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_reveal_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; EditBone *ebone; + const bool select = RNA_boolean_get(op->ptr, "select"); for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { if (!(ebone->flag & BONE_UNSELECTABLE)) { - ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + SET_FLAG_FROM_TEST(ebone->flag, select, (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)); } ebone->flag &= ~BONE_HIDDEN_A; } } } - ED_armature_validate_active(arm); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1591,7 +1594,7 @@ void ARMATURE_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name = "Reveal Bones"; ot->idname = "ARMATURE_OT_reveal"; - ot->description = "Unhide all bones that have been tagged to be hidden in Edit Mode"; + ot->description = "Reveal all bones hidden in Edit Mode"; /* api callbacks */ ot->exec = armature_reveal_exec; @@ -1600,4 +1603,5 @@ void ARMATURE_OT_reveal(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + RNA_def_boolean(ot->srna, "select", true, "Select", ""); } |