Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_edit.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| #include "armature_intern.h" | #include "armature_intern.h" | ||||
| /* ************************** Object Tools Exports ******************************* */ | /* ************************** Object Tools Exports ******************************* */ | ||||
| /* NOTE: these functions are exported to the Object module to be called from the tools there */ | /* NOTE: these functions are exported to the Object module to be called from the tools there */ | ||||
| /** | /** | ||||
| * See #BKE_armature_transform for object-mode transform. | * See #BKE_armature_transform for object-mode transform. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | if (arm->flag & ARM_MIRROR_EDIT) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| } | } | ||||
| cleanup: | cleanup: | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (arm->flag & ARM_MIRROR_EDIT) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| /* Note, notifier might evolve. */ | /* Note, notifier might evolve. */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_roll_clear(wmOperatorType *ot) | void ARMATURE_OT_roll_clear(wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Lines | if (newbone) { | ||||
| ED_armature_edit_deselect_all(obedit); | ED_armature_edit_deselect_all(obedit); | ||||
| arm->act_edbone = newbone; | arm->act_edbone = newbone; | ||||
| newbone->flag |= BONE_TIPSEL; | newbone->flag |= BONE_TIPSEL; | ||||
| } | } | ||||
| /* updates */ | /* updates */ | ||||
| ED_armature_edit_refresh_layer_used(arm); | ED_armature_edit_refresh_layer_used(arm); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE); | |||||
| /* free points */ | /* free points */ | ||||
| BLI_freelistN(&points); | BLI_freelistN(&points); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_fill(wmOperatorType *ot) | void ARMATURE_OT_fill(wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | if (type == 1) { | ||||
| BLI_freelistN(&chains); | BLI_freelistN(&chains); | ||||
| } | } | ||||
| /* updates */ | /* updates */ | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| ED_armature_edit_refresh_layer_used(arm); | ED_armature_edit_refresh_layer_used(arm); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_merge(wmOperatorType *ot) | void ARMATURE_OT_merge(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| BLI_freelistN(&chains); | BLI_freelistN(&chains); | ||||
| /* clear temp flags */ | /* clear temp flags */ | ||||
| armature_clear_swap_done_flags(arm); | armature_clear_swap_done_flags(arm); | ||||
| armature_tag_unselect(arm); | armature_tag_unselect(arm); | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_switch_direction(wmOperatorType *ot) | void ARMATURE_OT_switch_direction(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | else { | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| BKE_reportf( | BKE_reportf( | ||||
| op->reports, RPT_INFO, "%d bones aligned to bone '%s'", num_selected_bones, actbone->name); | op->reports, RPT_INFO, "%d bones aligned to bone '%s'", num_selected_bones, actbone->name); | ||||
| } | } | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_align(wmOperatorType *ot) | void ARMATURE_OT_align(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Align Bones"; | ot->name = "Align Bones"; | ||||
| Show All 27 Lines | for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) { | ||||
| bone->flag &= ~BONE_CONNECTED; | bone->flag &= ~BONE_CONNECTED; | ||||
| } | } | ||||
| } | } | ||||
| for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) { | for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) { | ||||
| ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0); | ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_split(wmOperatorType *ot) | void ARMATURE_OT_split(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| if (changed) { | if (changed) { | ||||
| changed_multi = true; | changed_multi = true; | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| ED_armature_edit_refresh_layer_used(arm); | ED_armature_edit_refresh_layer_used(arm); | ||||
| BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose); | BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| if (!changed_multi) { | if (!changed_multi) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | if (arm->flag & ARM_MIRROR_EDIT) { | ||||
| BLI_ghash_free(ebone_flag_orig, NULL, NULL); | BLI_ghash_free(ebone_flag_orig, NULL, NULL); | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| changed_multi = true; | changed_multi = true; | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| ED_armature_edit_refresh_layer_used(arm); | ED_armature_edit_refresh_layer_used(arm); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| if (!changed_multi) { | if (!changed_multi) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| if (!changed) { | if (!changed) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ED_armature_edit_validate_active(arm); | ED_armature_edit_validate_active(arm); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_hide(wmOperatorType *ot) | void ARMATURE_OT_hide(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| Show All 36 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| ED_armature_edit_validate_active(arm); | ED_armature_edit_validate_active(arm); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_reveal(wmOperatorType *ot) | void ARMATURE_OT_reveal(wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 14 Lines | |||||