[Bf-blender-cvs] [28f5573] master: Fix for inexact 3d cursor placement especially when zoomed out.

Campbell Barton noreply at git.blender.org
Sun Dec 29 03:40:57 CET 2013


Commit: 28f55731976caeee154be39f994c50cae954003b
Author: Campbell Barton
Date:   Sun Dec 29 13:35:00 2013 +1100
https://developer.blender.org/rB28f55731976caeee154be39f994c50cae954003b

Fix for inexact 3d cursor placement especially when zoomed out.

Even with the startup scene clicking multiple times in the corner of the
view without moving the mouse would move the cursor a little each time.

===================================================================

M	source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index ab9a222..dcd841f 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4136,9 +4136,9 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
 	ARegion *ar = CTX_wm_region(C);
 	View3D *v3d = CTX_wm_view3d(C);
 	RegionView3D *rv3d = CTX_wm_region_view3d(C);
-	float mval_fl[2];
 	float zfac;
 	bool flip;
+	bool depth_used = false;
 	
 	/* normally the caller should ensure this,
 	 * but this is called from areas that aren't already dealing with the viewport */
@@ -4154,36 +4154,17 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
 		zfac = ED_view3d_calc_zfac(rv3d, fp, NULL /* &flip */ );
 	}
 
-	if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
-		bool depth_used = false;
-
-		if (U.uiflag & USER_ZBUF_CURSOR) {  /* maybe this should be accessed some other way */
-			view3d_operator_needs_opengl(C);
-			if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true, NULL))
-				depth_used = true;
-		}
-
-		if (depth_used == false) {
-			float dvec[3];
-			VECSUB2D(mval_fl, mval_fl, mval);
-			ED_view3d_win_to_delta(ar, mval_fl, dvec, zfac);
-			sub_v3_v3(fp, dvec);
-		}
+	if (U.uiflag & USER_ZBUF_CURSOR) {  /* maybe this should be accessed some other way */
+		view3d_operator_needs_opengl(C);
+		if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true, NULL))
+			depth_used = true;
 	}
-	else {
-		float tvec[3];
 
-		tvec[0] = ((float)(mval[0] - (ar->winx / 2))) * zfac / (ar->winx / 2);
-		tvec[1] = ((float)(mval[1] - (ar->winy / 2))) * zfac / (ar->winy / 2);
-		tvec[2] = (rv3d->persmat[0][3] * fp[0] +
-		           rv3d->persmat[1][3] * fp[1] +
-		           rv3d->persmat[2][3] * fp[2] +
-		           rv3d->persmat[3][3]) / zfac;
-
-		mul_mat3_m4_v3(rv3d->persinv, tvec);
-		sub_v3_v3v3(fp, tvec, rv3d->ofs);
+	if (depth_used == false) {
+		float depth_pt[3];
+		copy_v3_v3(depth_pt, fp);
+		ED_view3d_win_to_3d_int(ar, depth_pt, mval, fp);
 	}
-
 }
 
 static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)




More information about the Bf-blender-cvs mailing list