Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_add.c
| Show First 20 Lines • Show All 45 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" | ||||
| /* *************** Adding stuff in editmode *************** */ | /* *************** Adding stuff in editmode *************** */ | ||||
| /* default bone add, returns it selected, but without tail set */ | /* default bone add, returns it selected, but without tail set */ | ||||
| /* XXX should be used everywhere, now it mallocs bones still locally in functions */ | /* XXX should be used everywhere, now it mallocs bones still locally in functions */ | ||||
| EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) | EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | for (a = 0; a < 2; a++) { | ||||
| newbone->length = len_v3v3(newbone->head, newbone->tail); | newbone->length = len_v3v3(newbone->head, newbone->tail); | ||||
| newbone->rad_tail = newbone->length * 0.05f; | newbone->rad_tail = newbone->length * 0.05f; | ||||
| newbone->dist = newbone->length * 0.25f; | newbone->dist = newbone->length * 0.25f; | ||||
| } | } | ||||
| 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(&obedit->id, ID_RECALC_SELECT); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| /* TODO most of this code is copied from set3dcursor_invoke, | /* TODO most of this code is copied from set3dcursor_invoke, | ||||
| * it would be better to reuse code in set3dcursor_invoke */ | * it would be better to reuse code in set3dcursor_invoke */ | ||||
| ▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; | ||||
| } | } | ||||
| } | } | ||||
| postEditBoneDuplicate(arm->edbo, ob); | postEditBoneDuplicate(arm->edbo, ob); | ||||
| ED_armature_edit_validate_active(arm); | ED_armature_edit_validate_active(arm); | ||||
| 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(&ob->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_duplicate(wmOperatorType *ot) | void ARMATURE_OT_duplicate(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | if (arm->act_edbone && arm->act_edbone->temp.ebone) { | ||||
| arm->act_edbone = arm->act_edbone->temp.ebone; | arm->act_edbone = arm->act_edbone->temp.ebone; | ||||
| } | } | ||||
| postEditBoneDuplicate(arm->edbo, obedit); | postEditBoneDuplicate(arm->edbo, obedit); | ||||
| ED_armature_edit_validate_active(arm); | ED_armature_edit_validate_active(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(&obedit->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| /* following conventions from #MESH_OT_symmetrize */ | /* following conventions from #MESH_OT_symmetrize */ | ||||
| void ARMATURE_OT_symmetrize(wmOperatorType *ot) | void ARMATURE_OT_symmetrize(wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| } | } | ||||
| changed_multi = true; | changed_multi = true; | ||||
| /* Transform the endpoints */ | /* Transform the endpoints */ | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| 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(&ob->id, ID_RECALC_SELECT); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; | return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; | ||||
| } | } | ||||
| void ARMATURE_OT_extrude(wmOperatorType *ot) | void ARMATURE_OT_extrude(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) | ||||
| else { | else { | ||||
| add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z | add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z | ||||
| } | } | ||||
| ED_armature_edit_refresh_layer_used(obedit->data); | ED_armature_edit_refresh_layer_used(obedit->data); | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| 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(&obedit->id, ID_RECALC_SELECT); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) | void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add Bone"; | ot->name = "Add Bone"; | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | for (i = cuts + 1; i > 1; i--) { | ||||
| } | } | ||||
| newbone->parent = ebone; | newbone->parent = ebone; | ||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| 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(&obedit->id, ID_RECALC_SELECT); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_subdivide(wmOperatorType *ot) | void ARMATURE_OT_subdivide(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 18 Lines | |||||