diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-26 06:37:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-26 06:37:29 +0400 |
commit | 09721bffc066fdc1f9352a00eeb30c1a3ddd6d77 (patch) | |
tree | fd58e8f5d58774302d8f9ecad7cebd108547af43 /source | |
parent | ae0e356de65ce9ce77fa71695e325846c623db21 (diff) |
replace view3d_get_view_aligned_coordinate with ED_view3d_win_to_3d_int()
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_project.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 33 |
7 files changed, 46 insertions, 40 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index c001c17a279..314967d4426 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4644,7 +4644,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) copy_v3_v3(location, give_cursor(vc.scene, vc.v3d)); } - view3d_get_view_aligned_coordinate(vc.ar, location, event->mval, true); + ED_view3d_win_to_3d_int(vc.ar, location, event->mval, location); RNA_float_set_array(op->ptr, "location", location); } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 81f49b4e1f8..ee0946be620 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -199,6 +199,7 @@ float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bo void ED_view3d_win_to_ray(const struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]); void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3]); void ED_view3d_win_to_3d(const struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); +void ED_view3d_win_to_3d_int(const struct ARegion *ar, const float depth_pt[3], const int mval[2], float out[3]); void ED_view3d_win_to_delta(const struct ARegion *ar, const float mval[2], float out[3], const float zfac); void ED_view3d_win_to_vector(const struct ARegion *ar, const float mval[2], float out[3]); void ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2], @@ -261,7 +262,6 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); -bool view3d_get_view_aligned_coordinate(struct ARegion *ar, float fp[3], const int mval[2], const bool do_fallback); void view3d_opengl_read_pixels(struct ARegion *ar, int x, int y, int w, int h, int format, int type, void *data); void view3d_get_transformation(const struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index feb65be098d..3feb8f921dc 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -861,7 +861,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w copy_v3_v3(min, cent); mul_m4_v3(vc.obedit->obmat, min); /* view space */ - view3d_get_view_aligned_coordinate(vc.ar, min, event->mval, true); + ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min); mul_m4_v3(vc.obedit->imat, min); // back in object space sub_v3_v3(min, cent); @@ -910,7 +910,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w BMOIter oiter; copy_v3_v3(min, curs); - view3d_get_view_aligned_coordinate(vc.ar, min, event->mval, false); + ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min); invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); mul_m4_v3(vc.obedit->imat, min); // back in object space diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 1e03fb3378c..9dbdd8a9789 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2683,7 +2683,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *UNUSED(op), const wmE else { /* fallback to simple pan */ negate_v3_v3(new_ofs, rv3d->ofs); - view3d_get_view_aligned_coordinate(ar, new_ofs, event->mval, true); + ED_view3d_win_to_3d_int(ar, new_ofs, event->mval, new_ofs); } negate_v3(new_ofs); view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 7d728234c92..ccfbf964d36 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -347,6 +347,39 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], normalize_v3(vec); } +/* very similar to ED_view3d_win_to_3d() but has no advantage, de-duplicating */ +#if 0 +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; + + ret = ED_view3d_project_int_global(ar, fp, mval_cpy, V3D_PROJ_TEST_NOP); + + if (ret == V3D_PROJ_RET_OK) { + const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), + (float)(mval_cpy[1] - mval[1])}; + const float zfac = ED_view3d_calc_zfac(rv3d, fp, NULL); + ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + sub_v3_v3(fp, dvec); + + return true; + } + else { + /* fallback to the view center */ + if (do_fallback) { + negate_v3_v3(fp, rv3d->ofs); + return view3d_get_view_aligned_coordinate(ar, fp, mval, false); + } + else { + return false; + } + } +} +#endif + /** * Calculate a 3d location from 2d window coordinates. * \param ar The region (used for the window width and height). @@ -357,7 +390,7 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], void ED_view3d_win_to_3d(const ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]) { RegionView3D *rv3d = ar->regiondata; - + float line_sta[3]; float line_end[3]; @@ -384,6 +417,12 @@ void ED_view3d_win_to_3d(const ARegion *ar, const float depth_pt[3], const float } } +void ED_view3d_win_to_3d_int(const ARegion *ar, const float depth_pt[3], const int mval[2], float out[3]) +{ + const float mval_fl[2] = {mval[0], mval[1]}; + ED_view3d_win_to_3d(ar, depth_pt, mval_fl, out); +} + /** * Calculate a 3d difference vector from 2d window offset. * note that ED_view3d_calc_zfac() must be called first to determine diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index d6cc218e266..ef8c2b5eff6 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -653,7 +653,7 @@ static void view3d_ruler_free(RulerInfo *ruler_info) static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], const int xy[2]) { - view3d_get_view_aligned_coordinate(ruler_info->ar, r_co, xy, true); + ED_view3d_win_to_3d_int(ruler_info->ar, r_co, xy, r_co); } /* use for mousemove events */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index a84075fb60e..209bb76df91 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -108,39 +108,6 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit = CTX_data_edit_object(C); } -/** - * 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; - - ret = ED_view3d_project_int_global(ar, fp, mval_cpy, V3D_PROJ_TEST_NOP); - - if (ret == V3D_PROJ_RET_OK) { - const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), - (float)(mval_cpy[1] - mval[1])}; - const float zfac = ED_view3d_calc_zfac(rv3d, fp, NULL); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); - sub_v3_v3(fp, dvec); - - return true; - } - else { - /* fallback to the view center */ - if (do_fallback) { - negate_v3_v3(fp, rv3d->ofs); - return view3d_get_view_aligned_coordinate(ar, fp, mval, false); - } - else { - return false; - } - } -} - /* * ob == NULL if you want global matrices * */ |