diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:47:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:59:40 +0400 |
commit | 9ae0e585b0aab466c978ec1a55c824d902faa3b4 (patch) | |
tree | 6a99d63651f1b66ffacac2582b5f03d58898ad99 /source/blender/editors/uvedit/uvedit_ops.c | |
parent | 6ee8670fca946d146332e80ceff29e459cd91ed5 (diff) |
View2d: API Cleanup for view<->region conversion
View2D had some inconsistencies making it error prone in some cases.
- Inconstant checking for NULL x/y args.
Disallow NULL args for x/y destination pointers, instead add:
- UI_view2d_region_to_view_x/y
- UI_view2d_view_to_region_x/y
- '_no_clip' suffix wasn't always used for non-clipping conversion,
switch it around and use a '_clip' suffix for all funcs that clip.
- UI_view2d_text_cache_add now clips before adding cache.
- '_clip' funcs return a bool to quickly check if its in the view.
- add conversion for rectangles, since this is a common task:
- UI_view2d_view_to_region_rcti
- UI_view2d_region_to_view_rctf
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_ops.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 0706ac3278b..3a5c1335dd9 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2796,7 +2796,6 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) BMIter iter, liter; MTexPoly *tf; MLoopUV *luv; - rcti rect; rctf rectf; bool changed, pinned, select, extend; const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ? @@ -2807,10 +2806,8 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); /* get rectangle from operator */ - WM_operator_properties_border_to_rcti(op, &rect); - - UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + WM_operator_properties_border_to_rctf(op, &rectf); + UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); /* figure out what to select/deselect */ select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); @@ -3071,7 +3068,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { float cent[2]; uv_poly_center(efa, cent, cd_loop_uv_offset); - UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); + UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { @@ -3093,7 +3090,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); + UI_view2d_view_to_region_clip(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { |