2.5: Various Fixes
[blender.git] / source / blender / editors / armature / editarmature.c
index 2aed96b61c577c62ab42db1cdc342979f40a5662..97bf3492f7c93c2b47fb5c0b83609d4f6a0116e9 100644 (file)
@@ -33,8 +33,6 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BMF_Api.h"
-
 #include "DNA_action_types.h"
 #include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
@@ -75,7 +73,7 @@
 
 #include "BIF_gl.h"
 #include "BIF_transform.h"
-// XXX etch-a-ton #include "BIF_generate.h"
+#include "BIF_generate.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -112,7 +110,7 @@ static void adduplicate() {}
 /* **************** tools on Editmode Armature **************** */
 
 /* Sync selection to parent for connected children */
-static void armature_sync_selection(ListBase *edbo)
+void ED_armature_sync_selection(ListBase *edbo)
 {
        EditBone *ebo;
        
@@ -736,6 +734,7 @@ int join_armature(Scene *scene, View3D *v3d)
                                                VecSubf(delta, curbone->tail, curbone->head);
                                                vec_roll_to_mat3(delta, curbone->roll, temp);
                                                
+                                               Mat4One(premat); /* Mat4MulMat34 only sets 3x3 part */
                                                Mat4MulMat34(premat, temp, mat);
                                                
                                                Mat4MulVecfl(mat, curbone->head);
@@ -1351,11 +1350,11 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev
        return OPERATOR_FINISHED;
 }
 
-void POSE_OT_select_connected(wmOperatorType *ot)
+void POSE_OT_select_linked(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Select Connected";
-       ot->idname= "POSE_OT_select_connected";
+       ot->idname= "POSE_OT_select_linked";
        
        /* api callbacks */
        ot->exec= NULL;
@@ -1373,7 +1372,7 @@ void POSE_OT_select_connected(wmOperatorType *ot)
 
 /* called in space.c */
 /* previously "selectconnected_armature" */
-static int armature_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        bArmature *arm;
        EditBone *bone, *curBone, *next;
@@ -1436,7 +1435,7 @@ static int armature_select_connected_invoke(bContext *C, wmOperator *op, wmEvent
 
        }
 
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
 
        /* BIF_undo_push("Select connected"); */
 
@@ -1445,15 +1444,15 @@ static int armature_select_connected_invoke(bContext *C, wmOperator *op, wmEvent
        return OPERATOR_FINISHED;
 }
 
-void ARMATURE_OT_select_connected(wmOperatorType *ot)
+void ARMATURE_OT_select_linked(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Select Connected";
-       ot->idname= "ARMATURE_OT_select_connected";
+       ot->idname= "ARMATURE_OT_select_linked";
        
        /* api callbacks */
        ot->exec= NULL;
-       ot->invoke= armature_select_connected_invoke;
+       ot->invoke= armature_select_linked_invoke;
        ot->poll= ED_operator_editarmature;
        
        /* flags */
@@ -1669,18 +1668,18 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *op)
        }
        
        
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
 
        WM_event_add_notifier(C, NC_OBJECT, obedit);
 
        return OPERATOR_FINISHED;
 }
 
-void ARMATURE_OT_delete_selected(wmOperatorType *ot)
+void ARMATURE_OT_delete(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Delete Selected Bone(s)";
-       ot->idname= "ARMATURE_OT_delete_selected";
+       ot->idname= "ARMATURE_OT_delete";
        
        /* api callbacks */
        ot->invoke = WM_operator_confirm;
@@ -1743,7 +1742,7 @@ void deselectall_armature(Object *obedit, int toggle, int doundo)
                }
        }
        
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        if (doundo) {
                if (sel==1) BIF_undo_push("Select All");
                else BIF_undo_push("Deselect All");
@@ -1762,6 +1761,8 @@ void mouse_armature(bContext *C, short mval[2], int extend)
 
        view3d_set_viewcontext(C, &vc);
        
+       BIF_sk_selectStroke(C, mval, extend);
+       
        nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
        if (nearBone) {
 
@@ -1813,7 +1814,7 @@ void mouse_armature(bContext *C, short mval[2], int extend)
                                nearBone->flag |= selmask;
                }
                
-               armature_sync_selection(arm->edbo);
+               ED_armature_sync_selection(arm->edbo);
                
                if(nearBone) {
                        /* then now check for active status */
@@ -1856,7 +1857,7 @@ void ED_armature_to_edit(Object *ob)
        arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature");
        make_boneList(arm->edbo, &arm->bonebase,NULL);
 
-       // XXX etch-a-ton BIF_freeTemplates(); /* force template update when entering editmode */
+//     BIF_freeTemplates(); /* force template update when entering editmode */
 }
 
 
@@ -1956,9 +1957,9 @@ void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone)
 
 
 static EnumPropertyItem prop_calc_roll_types[] = {
-       {0, "GLOBALUP", "Z-Axis Up", ""},
-       {1, "CURSOR", "Z-Axis to Cursor", ""},
-       {0, NULL, NULL, NULL}
+       {0, "GLOBALUP", 0, "Z-Axis Up", ""},
+       {1, "CURSOR", 0, "Z-Axis to Cursor", ""},
+       {0, NULL, 0, NULL, NULL}
 };
 
 static int armature_calc_roll_exec(bContext *C, wmOperator *op) 
@@ -2245,7 +2246,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op)
                
        }
        
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
        
@@ -2507,7 +2508,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
        if (CTX_DATA_COUNT(C, selected_bones) == 0)
          return OPERATOR_CANCELLED;
        
-       armature_sync_selection(arm->edbo); // XXX why is this needed?
+       ED_armature_sync_selection(arm->edbo); // XXX why is this needed?
 
        preEditBoneDuplicate(arm->edbo);
 
@@ -3057,7 +3058,7 @@ void merge_armature(Scene *scene)
        }
        
        /* undo + updates */
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        BIF_undo_push("Merge Bones");
 }
 
@@ -3079,7 +3080,7 @@ void hide_selected_armature_bones(Scene *scene)
                        }
                }
        }
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        BIF_undo_push("Hide Bones");
 }
 
@@ -3099,7 +3100,7 @@ void hide_unselected_armature_bones(Scene *scene)
                        }
                }
        }
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        BIF_undo_push("Hide Unselected Bones");
 }
 
@@ -3117,7 +3118,7 @@ void show_all_armature_bones(Scene *scene)
                        }
                }
        }
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        BIF_undo_push("Reveal Bones");
 }
 
@@ -3250,7 +3251,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
        if (totbone==0) return OPERATOR_CANCELLED;
        
        /* Transform the endpoints */
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
 
        return OPERATOR_FINISHED;
 }
@@ -3458,11 +3459,13 @@ void ARMATURE_OT_subdivide_multi(wmOperatorType *ot)
 
 static int armature_subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       uiMenuItem *head;
+       uiPopupMenu *pup;
+       uiLayout *layout;
 
-       head= uiPupMenuBegin("Subdivision Type", 0);
-       uiMenuItemsEnumO(head, "ARMATURE_OT_subdivs", "type");
-       uiPupMenuEnd(C, head);
+       pup= uiPupMenuBegin(C, "Subdivision Type", 0);
+       layout= uiPupMenuLayout(pup);
+       uiItemsEnumO(layout, "ARMATURE_OT_subdivs", "type");
+       uiPupMenuEnd(C, pup);
        
        return OPERATOR_CANCELLED;
 }
@@ -3486,9 +3489,9 @@ static int armature_subdivs_exec(bContext *C, wmOperator *op)
 void ARMATURE_OT_subdivs(wmOperatorType *ot)
 {
        static EnumPropertyItem type_items[]= {
-               {0, "SIMPLE", "Simple", ""},
-               {1, "MULTI", "Multi", ""},
-               {0, NULL, NULL}};
+               {0, "SIMPLE", 0, "Simple", ""},
+               {1, "MULTI", 0, "Multi", ""},
+               {0, NULL, 0, NULL, NULL}};
 
        /* identifiers */
        ot->name= "subdivs";
@@ -3666,9 +3669,9 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
 }
 
 static EnumPropertyItem prop_editarm_make_parent_types[] = {
-       {ARM_PAR_CONNECT, "CONNECTED", "Connected", ""},
-       {ARM_PAR_OFFSET, "OFFSET", "Keep Offset", ""},
-       {0, NULL, NULL, NULL}
+       {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""},
+       {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""},
+       {0, NULL, 0, NULL, NULL}
 };
 
 static int armature_parent_set_exec(bContext *C, wmOperator *op) 
@@ -3742,7 +3745,8 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
 static int armature_parent_set_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        EditBone *actbone = CTX_data_active_bone(C);
-       uiMenuItem *head= uiPupMenuBegin("Make Parent ", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", 0);
+       uiLayout *layout= uiPupMenuLayout(pup);
        int allchildbones = 0;
        
        CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
@@ -3752,13 +3756,13 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *op, wmEvent *even
        }
        CTX_DATA_END;
 
-       uiMenuItemEnumO(head, "", 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_CONNECT);
+       uiItemEnumO(layout, NULL, 0, "ARMATURE_OT_parent_set", "type", ARM_PAR_CONNECT);
        
        /* ob becomes parent, make the associated menus */
        if (allchildbones)
-               uiMenuItemEnumO(head, "", 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_OFFSET); 
+               uiItemEnumO(layout, NULL, 0, "ARMATURE_OT_parent_set", "type", ARM_PAR_OFFSET); 
                
-       uiPupMenuEnd(C, head);
+       uiPupMenuEnd(C, pup);
        
        return OPERATOR_CANCELLED;
 }
@@ -3767,7 +3771,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Make Parent";
-       ot->idname= "ARMATURE_OT_set_parent";
+       ot->idname= "ARMATURE_OT_parent_set";
        
        /* api callbacks */
        ot->invoke = armature_parent_set_invoke;
@@ -3781,9 +3785,9 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
 }
 
 static EnumPropertyItem prop_editarm_clear_parent_types[] = {
-       {1, "CLEAR", "Clear Parent", ""},
-       {2, "DISCONNECT", "Disconnect Bone", ""},
-       {0, NULL, NULL, NULL}
+       {1, "CLEAR", 0, "Clear Parent", ""},
+       {2, "DISCONNECT", 0, "Disconnect Bone", ""},
+       {0, NULL, 0, NULL, NULL}
 };
 
 static void editbone_clear_parent(EditBone *ebone, int mode)
@@ -3808,7 +3812,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
        
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
 
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT, ob);
@@ -3820,7 +3824,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Clear Parent";
-       ot->idname= "ARMATURE_OT_clear_parent";
+       ot->idname= "ARMATURE_OT_parent_clear";
        
        /* api callbacks */
        ot->invoke = WM_menu_invoke;
@@ -3835,7 +3839,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
 
 /* ****************  Selections  ******************/
 
-static int armature_selection_invert_exec(bContext *C, wmOperator *op)
+static int armature_select_invert_exec(bContext *C, wmOperator *op)
 {
        /*      Set the flags */
        CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) {
@@ -3850,15 +3854,15 @@ static int armature_selection_invert_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void ARMATURE_OT_selection_invert(wmOperatorType *ot)
+void ARMATURE_OT_select_invert(wmOperatorType *ot)
 {
        
        /* identifiers */
        ot->name= "Invert Selection";
-       ot->idname= "ARMATURE_OT_selection_invert";
+       ot->idname= "ARMATURE_OT_select_invert";
        
        /* api callbacks */
-       ot->exec= armature_selection_invert_exec;
+       ot->exec= armature_select_invert_exec;
        ot->poll= ED_operator_editarmature;
        
        /* flags */
@@ -3893,12 +3897,12 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void ARMATURE_OT_de_select_all(wmOperatorType *ot)
+void ARMATURE_OT_select_all_toggle(wmOperatorType *ot)
 {
        
        /* identifiers */
        ot->name= "deselect all editbone";
-       ot->idname= "ARMATURE_OT_de_select_all";
+       ot->idname= "ARMATURE_OT_select_all_toggle";
        
        /* api callbacks */
        ot->exec= armature_de_select_all_exec;
@@ -3918,7 +3922,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
        bArmature *arm;
        EditBone *curbone, *pabone, *chbone;
        int direction = RNA_enum_get(op->ptr, "direction");
-       int add_to_sel = RNA_boolean_get(op->ptr, "add_to_sel");
+       int add_to_sel = RNA_boolean_get(op->ptr, "extend");
        
        ob= obedit;
        arm= (bArmature *)ob->data;
@@ -3959,7 +3963,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
                }
        }
        
-       armature_sync_selection(arm->edbo);
+       ED_armature_sync_selection(arm->edbo);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
        
@@ -3969,9 +3973,9 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
 void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
 {
        static EnumPropertyItem direction_items[]= {
-       {BONE_SELECT_PARENT, "PARENT", "Select Parent", ""},
-       {BONE_SELECT_CHILD, "CHILD", "Select Child", ""},
-       {0, NULL, NULL, NULL}
+       {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
+       {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
+       {0, NULL, 0, NULL, NULL}
        };
        
        /* identifiers */
@@ -3988,7 +3992,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
        /* props */
        RNA_def_enum(ot->srna, "direction", direction_items,
                     BONE_SELECT_PARENT, "Direction", "");
-       RNA_def_boolean(ot->srna, "add_to_sel", 0, "Add to Selection", "");
+       RNA_def_boolean(ot->srna, "extend", 0, "Add to Selection", "");
 }
 
 /* ***************** EditBone Alignment ********************* */
@@ -4110,11 +4114,11 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void ARMATURE_OT_align_bones(wmOperatorType *ot)
+void ARMATURE_OT_bones_align(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Align Bones";
-       ot->idname= "ARMATURE_OT_align_bones";
+       ot->idname= "ARMATURE_OT_bones_align";
        
        /* api callbacks */
        ot->invoke = WM_operator_confirm;
@@ -4819,7 +4823,7 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
 
 /* ***************** selections ********************** */
 
-static int pose_selection_invert_exec(bContext *C, wmOperator *op)
+static int pose_select_invert_exec(bContext *C, wmOperator *op)
 {
        
        /*      Set the flags */
@@ -4834,15 +4838,15 @@ static int pose_selection_invert_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void POSE_OT_selection_invert(wmOperatorType *ot)
+void POSE_OT_select_invert(wmOperatorType *ot)
 {
        
        /* identifiers */
        ot->name= "Invert Selection";
-       ot->idname= "POSE_OT_selection_invert";
+       ot->idname= "POSE_OT_select_invert";
        
        /* api callbacks */
-       ot->exec= pose_selection_invert_exec;
+       ot->exec= pose_select_invert_exec;
        ot->poll= ED_operator_posemode;
        
        /* flags */
@@ -4870,12 +4874,12 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void POSE_OT_de_select_all(wmOperatorType *ot)
+void POSE_OT_select_all_toggle(wmOperatorType *ot)
 {
        
        /* identifiers */
        ot->name= "deselect all bones";
-       ot->idname= "POSE_OT_de_select_all";
+       ot->idname= "POSE_OT_select_all_toggle";
        
        /* api callbacks */
        ot->exec= pose_de_select_all_exec;