Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_relations.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_layer.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| ▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Lines | static void separate_armature_bones(Object *ob, short sel) | ||||
| /* exit editmode (recalculates pchans too) */ | /* exit editmode (recalculates pchans too) */ | ||||
| ED_armature_from_edit(ob->data); | ED_armature_from_edit(ob->data); | ||||
| ED_armature_edit_free(ob->data); | ED_armature_edit_free(ob->data); | ||||
| } | } | ||||
| /* separate selected bones into their armature */ | /* separate selected bones into their armature */ | ||||
| static int separate_armature_exec(bContext *C, wmOperator *op) | static int separate_armature_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| #if 0 /* TODO_LAYER */ | |||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | |||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| Object *oldob, *newob; | Object *oldob, *newob; | ||||
| Base *oldbase, *newbase; | ObjectBase *oldbase, *newbase; | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| if (obedit == NULL) | if (obedit == NULL) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* set wait cursor in case this takes a while */ | /* set wait cursor in case this takes a while */ | ||||
| WM_cursor_wait(1); | WM_cursor_wait(1); | ||||
| Show All 11 Lines | #if 0 /* TODO_LAYER */ | ||||
| { | { | ||||
| if (base->object == obedit) base->flag |= SELECT; | if (base->object == obedit) base->flag |= SELECT; | ||||
| else base->flag &= ~SELECT; | else base->flag &= ~SELECT; | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| /* 1) store starting settings and exit editmode */ | /* 1) store starting settings and exit editmode */ | ||||
| oldob = obedit; | oldob = obedit; | ||||
| oldbase = BASACT; | oldbase = sl->basact; | ||||
| oldob->mode &= ~OB_MODE_POSE; | oldob->mode &= ~OB_MODE_POSE; | ||||
| //oldbase->flag &= ~OB_POSEMODE; | //oldbase->flag &= ~OB_POSEMODE; | ||||
| ED_armature_from_edit(obedit->data); | ED_armature_from_edit(obedit->data); | ||||
| ED_armature_edit_free(obedit->data); | ED_armature_edit_free(obedit->data); | ||||
| /* 2) duplicate base */ | /* 2) duplicate base */ | ||||
| newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ | newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ | ||||
| DAG_relations_tag_update(bmain); | DAG_relations_tag_update(bmain); | ||||
| newob = newbase->object; | newob = newbase->object; | ||||
| newbase->flag &= ~SELECT; | newbase->flag &= ~BASE_SELECTED; | ||||
| /* 3) remove bones that shouldn't still be around on both armatures */ | /* 3) remove bones that shouldn't still be around on both armatures */ | ||||
| separate_armature_bones(oldob, 1); | separate_armature_bones(oldob, 1); | ||||
| separate_armature_bones(newob, 0); | separate_armature_bones(newob, 0); | ||||
| /* 4) fix links before depsgraph flushes */ // err... or after? | /* 4) fix links before depsgraph flushes */ // err... or after? | ||||
| separated_armature_fix_links(oldob, newob); | separated_armature_fix_links(oldob, newob); | ||||
| Show All 13 Lines | #if 0 /* TODO_LAYER */ | ||||
| /* note, notifier might evolve */ | /* note, notifier might evolve */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); | ||||
| /* recalc/redraw + cleanup */ | /* recalc/redraw + cleanup */ | ||||
| WM_cursor_wait(0); | WM_cursor_wait(0); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| #else | |||||
| (void)C; | |||||
| (void)op; | |||||
| (void)separate_armature_bones; | |||||
| (void)separated_armature_fix_links; | |||||
| return OPERATOR_CANCELLED; | |||||
| #endif | |||||
| } | } | ||||
| void ARMATURE_OT_separate(wmOperatorType *ot) | void ARMATURE_OT_separate(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Separate Bones"; | ot->name = "Separate Bones"; | ||||
| ot->idname = "ARMATURE_OT_separate"; | ot->idname = "ARMATURE_OT_separate"; | ||||
| ot->description = "Isolate selected bones into a separate armature"; | ot->description = "Isolate selected bones into a separate armature"; | ||||
| ▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines | |||||