diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 14:28:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 14:28:28 +0400 |
commit | 4a01ba4ba57bb26d1cf885e472e2ee4115ecb805 (patch) | |
tree | db8b0fe95ab30b438544eb562edb6086c7f83341 /source/blender/editors/space_view3d | |
parent | 35b9fcb8718d96af9b5c6292ea19bdd64b4b8406 (diff) |
ruler3d: replace ED_view3d_cursor3d_position() with lower level function view3d_get_view_aligned_coordinate()
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 21 |
2 files changed, 15 insertions, 14 deletions
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index b74d47ac600..fdc4c69022b 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -657,10 +657,10 @@ static void view3d_ruler_free(RulerInfo *ruler_info) MEM_freeN(ruler_info); } -static void view3d_ruler_item_project(bContext *C, RulerInfo *UNUSED(ruler_info), float r_co[3], +static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], const int xy[2]) { - ED_view3d_cursor3d_position(C, r_co, xy); + view3d_get_view_aligned_coordinate(ruler_info->ar, r_co, xy, true); } /* use for mousemove events */ @@ -670,7 +670,7 @@ static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, cons if (ruler_item) { float *co = ruler_item->co[ruler_item->co_index]; - view3d_ruler_item_project(C, ruler_info, co, event->mval); + view3d_ruler_item_project(ruler_info, co, event->mval); if (event->ctrl) { const float mval_fl[2] = {UNPACK2(event->mval)}; ED_view3d_snap_co(C, co, mval_fl, true, true, true); @@ -761,7 +761,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, wmEvent *event) ruler_item->co_index = 2; negate_v3_v3(ruler_item->co[0], rv3d->ofs); - view3d_ruler_item_project(C, ruler_info, ruler_item->co[0], event->mval); + view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval); copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); do_draw = true; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 24260898066..065354a4575 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -108,23 +108,24 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit = CTX_data_edit_object(C); } -int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int mval[2], const short do_fallback) +/** + * Re-project \a fp so it stays on the same view-plane but is under \a mval (normally the cursor location). + */ +bool view3d_get_view_aligned_coordinate(ARegion *ar, float fp[3], const int mval[2], const bool do_fallback) { + RegionView3D *rv3d = ar->regiondata; float dvec[3]; int mval_cpy[2]; eV3DProjStatus ret; - mval_cpy[0] = mval[0]; - mval_cpy[1] = mval[1]; - - ret = ED_view3d_project_int_global(vc->ar, fp, mval_cpy, V3D_PROJ_TEST_NOP); + ret = ED_view3d_project_int_global(ar, fp, mval_cpy, V3D_PROJ_TEST_NOP); - initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); + initgrabz(rv3d, fp[0], fp[1], fp[2]); if (ret == V3D_PROJ_RET_OK) { const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), (float)(mval_cpy[1] - mval[1])}; - ED_view3d_win_to_delta(vc->ar, mval_f, dvec); + ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3(fp, dvec); return TRUE; @@ -132,11 +133,11 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m else { /* fallback to the view center */ if (do_fallback) { - negate_v3_v3(fp, vc->rv3d->ofs); - return view3d_get_view_aligned_coordinate(vc, fp, mval, FALSE); + negate_v3_v3(fp, rv3d->ofs); + return view3d_get_view_aligned_coordinate(ar, fp, mval, false); } else { - return FALSE; + return false; } } } |