diff options
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 30 | ||||
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 111 |
4 files changed, 59 insertions, 88 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 738fdc229fb..cb52d88f985 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -4589,7 +4589,9 @@ void ED_pose_deselectall(Object *ob, int test) int selectmode = 0; /* we call this from outliner too */ - if (ELEM(NULL, ob, ob->pose)) return; + if (ob->pose == NULL) { + return; + } /* Determine if we're selecting or deselecting */ if (test == 1) { diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 78d3d8dc64d..f3f985fa97d 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -644,7 +644,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in short pval[2]; int pdist; - project_short_noclip(ar, stk->points[i].p, pval); + ED_view3d_project_short_noclip(ar, stk->points[i].p, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -679,7 +679,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, { copy_v3_v3(vec, bone->head); mul_m4_v3(ob->obmat, vec); - project_short_noclip(ar, vec, pval); + ED_view3d_project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -695,7 +695,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, copy_v3_v3(vec, bone->tail); mul_m4_v3(ob->obmat, vec); - project_short_noclip(ar, vec, pval); + ED_view3d_project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -907,7 +907,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p); float pval[2]; - project_float(ar, stk->points[i].p, pval); + ED_view3d_project_float(ar, stk->points[i].p, pval); ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal); mul_v3_fl(ray_normal, distance * progress / length); @@ -934,7 +934,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr initgrabz(ar->regiondata, fp[0], fp[1], fp[2]); /* method taken from editview.c - mouse_cursor() */ - project_short_noclip(ar, fp, cval); + ED_view3d_project_short_noclip(ar, fp, cval); VECSUB2D(mval_f, cval, dd->mval); ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3v3(vec, fp, dvec); @@ -1453,8 +1453,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu float s_p2[3] = {0, 0, 0}; int g_i; - project_float(ar, gesture->points[s_i].p, s_p1); - project_float(ar, gesture->points[s_i + 1].p, s_p2); + ED_view3d_project_float(ar, gesture->points[s_i].p, s_p1); + ED_view3d_project_float(ar, gesture->points[s_i + 1].p, s_p2); /* start checking from second next, because two consecutive cannot intersect */ for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) { @@ -1463,8 +1463,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu float vi[3]; float lambda; - project_float(ar, gesture->points[g_i].p, g_p1); - project_float(ar, gesture->points[g_i + 1].p, g_p2); + ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1); + ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2); if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1531,8 +1531,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S float s_p2[3] = {0, 0, 0}; int g_i; - project_float(ar, stk->points[s_i].p, s_p1); - project_float(ar, stk->points[s_i + 1].p, s_p2); + ED_view3d_project_float(ar, stk->points[s_i].p, s_p1); + ED_view3d_project_float(ar, stk->points[s_i + 1].p, s_p2); for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) { float g_p1[3] = {0, 0, 0}; @@ -1540,8 +1540,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S float vi[3]; float lambda; - project_float(ar, gesture->points[g_i].p, g_p1); - project_float(ar, gesture->points[g_i + 1].p, g_p2); + ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1); + ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2); if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1784,8 +1784,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc short start_val[2], end_val[2]; short dist; - project_short_noclip(ar, gest->stk->points[0].p, start_val); - project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val); + ED_view3d_project_short_noclip(ar, gest->stk->points[0].p, start_val); + ED_view3d_project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val); dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1])); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 6b6d2a1505f..346ed0002bd 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -667,7 +667,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str = NULL; /* count triangles and create mask */ - if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) || (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index e9424a08b0c..2f5eaabc12b 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -74,12 +74,30 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_object.h" +#include "ED_util.h" /* clipboard */ #include "UI_interface.h" #include "UI_resources.h" #include "armature_intern.h" +/* matches logic with ED_operator_posemode_context() */ +Object *ED_pose_object_from_context(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + Object *ob; + + /* since this call may also be used from the buttons window, we need to check for where to get the object */ + if (sa && sa->spacetype == SPACE_BUTS) { + ob = ED_object_context(C); + } + else { + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + } + + return ob; +} + /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { @@ -727,7 +745,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) short changed = 0; /* sanity check */ - if (ELEM(NULL, ob, ob->pose)) + if (ob->pose == NULL) return OPERATOR_CANCELLED; /* selection types @@ -1049,7 +1067,7 @@ static void pose_copy_menu(Scene *scene) /* Global copy/paste buffer for pose - cleared on start/end session + before every copy operation */ static bPose *g_posebuf = NULL; -void free_posebuf(void) +void ED_clipboard_posebuf_free(void) { if (g_posebuf) { bPoseChannel *pchan; @@ -1225,7 +1243,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op) } /* free existing pose buffer */ - free_posebuf(); + ED_clipboard_posebuf_free(); /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); @@ -1330,15 +1348,8 @@ void POSE_OT_paste(wmOperatorType *ot) static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + Object *ob = ED_pose_object_from_context(C); + /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; @@ -1361,7 +1372,7 @@ void POSE_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_add_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1370,14 +1381,7 @@ void POSE_OT_group_add(wmOperatorType *ot) static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object */ if (ob == NULL) @@ -1401,7 +1405,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_remove_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1412,8 +1416,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* invoke callback which presents a list of bone-groups for the user to choose from */ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; uiPopupMenu *pup; @@ -1421,12 +1424,6 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( bActionGroup *grp; int i; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1465,17 +1462,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( /* Assign selected pchans to the bone group that the user selects */ static int pose_group_assign_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; short done = FALSE; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1517,7 +1507,7 @@ void POSE_OT_group_assign(wmOperatorType *ot) /* api callbacks */ ot->invoke = pose_groups_menu_invoke; ot->exec = pose_group_assign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1529,16 +1519,9 @@ void POSE_OT_group_assign(wmOperatorType *ot) static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); short done = FALSE; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1572,7 +1555,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_unassign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1580,7 +1563,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) static int group_move_exec(bContext *C, wmOperator *op) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; bActionGroup *grp; @@ -1653,7 +1636,7 @@ void POSE_OT_group_move(wmOperatorType *ot) /* api callbacks */ ot->exec = group_move_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1678,7 +1661,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; tSortActionGroup *agrp_array; @@ -1737,7 +1720,7 @@ void POSE_OT_group_sort(wmOperatorType *ot) /* api callbacks */ ot->exec = group_sort_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1765,14 +1748,7 @@ static void pose_group_select(bContext *C, Object *ob, int select) static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1795,7 +1771,7 @@ void POSE_OT_group_select(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_select_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1803,14 +1779,7 @@ void POSE_OT_group_select(wmOperatorType *ot) static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1833,7 +1802,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_deselect_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |