[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55586] trunk/blender/source/blender/ editors: replace view3d_get_view_aligned_coordinate with ED_view3d_win_to_3d_int()
Campbell Barton
ideasman42 at gmail.com
Tue Mar 26 03:37:31 CET 2013
Revision: 55586
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55586
Author: campbellbarton
Date: 2013-03-26 02:37:29 +0000 (Tue, 26 Mar 2013)
Log Message:
-----------
replace view3d_get_view_aligned_coordinate with ED_view3d_win_to_3d_int()
Modified Paths:
--------------
trunk/blender/source/blender/editors/curve/editcurve.c
trunk/blender/source/blender/editors/include/ED_view3d.h
trunk/blender/source/blender/editors/mesh/editmesh_tools.c
trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
trunk/blender/source/blender/editors/space_view3d/view3d_project.c
trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c
trunk/blender/source/blender/editors/space_view3d/view3d_select.c
Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/curve/editcurve.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -4644,7 +4644,7 @@
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);
}
Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h 2013-03-26 02:37:29 UTC (rev 55586)
@@ -199,6 +199,7 @@
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 @@
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);
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -861,7 +861,7 @@
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 @@
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
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -2683,7 +2683,7 @@
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);
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_project.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_project.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_project.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -347,6 +347,39 @@
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_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_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
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -653,7 +653,7 @@
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 */
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_select.c 2013-03-26 01:49:55 UTC (rev 55585)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_select.c 2013-03-26 02:37:29 UTC (rev 55586)
@@ -108,39 +108,6 @@
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
* */
More information about the Bf-blender-cvs
mailing list