[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60159] trunk/blender/source/blender/ editors: fix [#36732] Auto depth feature misbehaves on orbit with mouse cursor outside the model .

Campbell Barton ideasman42 at gmail.com
Mon Sep 16 10:59:55 CEST 2013


Revision: 60159
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60159
Author:   campbellbarton
Date:     2013-09-16 08:59:54 +0000 (Mon, 16 Sep 2013)
Log Message:
-----------
fix [#36732] Auto depth feature misbehaves on orbit with mouse cursor outside the model.

ortho mode didn't store the depth for re-use when the cursor had no depth.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2013-09-16 06:00:25 UTC (rev 60158)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2013-09-16 08:59:54 UTC (rev 60159)
@@ -248,7 +248,9 @@
 unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
 
 /* draws and does a 4x4 sample */
-bool ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride);
+bool ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
+                        const int mval[2], float mouse_worldloc[3],
+                        bool alphaoverride, const float fallback_depth_pt[3]);
 
 /* only draw so ED_view3d_autodist_simple can be called many times after */
 void ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-16 06:00:25 UTC (rev 60158)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-16 08:59:54 UTC (rev 60159)
@@ -4164,7 +4164,7 @@
 
 		view3d_operator_needs_opengl(C);
 
-		if (!ED_view3d_autodist(scene, ps->ar, v3d, mval_i, cursor, false))
+		if (!ED_view3d_autodist(scene, ps->ar, v3d, mval_i, cursor, false, NULL))
 			return;
 
 		ED_region_tag_redraw(ps->ar);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2013-09-16 06:00:25 UTC (rev 60158)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2013-09-16 08:59:54 UTC (rev 60159)
@@ -489,10 +489,15 @@
 	}
 	else if (U.uiflag & USER_ZBUF_ORBIT) {
 		Scene *scene = CTX_data_scene(C);
+		float fallback_depth_pt[3];
 
 		view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
 
-		if ((vod->use_dyn_ofs = ED_view3d_autodist(scene, vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true))) {
+		negate_v3_v3(fallback_depth_pt, rv3d->ofs);
+
+		if ((vod->use_dyn_ofs = ED_view3d_autodist(scene, vod->ar, vod->v3d,
+		                                           event->mval, vod->dyn_ofs, true, fallback_depth_pt)))
+		{
 			if (rv3d->is_persp) {
 				float my_origin[3]; /* original G.vd->ofs */
 				float my_pivot[3]; /* view */
@@ -522,6 +527,14 @@
 
 				negate_v3_v3(rv3d->ofs, dvec);
 			}
+			else {
+				float mval_ar_mid[2] = {
+				    (float)vod->ar->winx / 2.0f,
+				    (float)vod->ar->winy / 2.0f};
+
+				ED_view3d_win_to_3d(vod->ar, vod->dyn_ofs, mval_ar_mid, rv3d->ofs);
+				negate_v3(rv3d->ofs);
+			}
 			negate_v3(vod->dyn_ofs);
 			copy_v3_v3(vod->ofs, rv3d->ofs);
 		}
@@ -2310,8 +2323,8 @@
 }
 
 static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
-                                          const float min[3], const float max[3],
-                                          bool ok_dist, const int smooth_viewtx)
+                               const float min[3], const float max[3],
+                               bool ok_dist, const int smooth_viewtx)
 {
 	RegionView3D *rv3d = ar->regiondata;
 	float afm[3];
@@ -2744,7 +2757,7 @@
 
 		view3d_operator_needs_opengl(C);
 
-		if (ED_view3d_autodist(scene, ar, v3d, event->mval, new_ofs, false)) {
+		if (ED_view3d_autodist(scene, ar, v3d, event->mval, new_ofs, false, NULL)) {
 			/* pass */
 		}
 		else {
@@ -4083,7 +4096,7 @@
 
 		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))
+			if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true, NULL))
 				depth_used = true;
 		}
 
@@ -4255,7 +4268,9 @@
 }
 
 /* XXX todo Zooms in on a border drawn by the user */
-bool ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride)
+bool ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d,
+                        const int mval[2], float mouse_worldloc[3],
+                        const bool alphaoverride, const float fallback_depth_pt[3])
 {
 	bglMats mats; /* ZBuffer depth vars */
 	float depth_close;
@@ -4267,22 +4282,27 @@
 
 	depth_close = view_autodist_depth_margin(ar, mval, 4);
 
-	if (depth_close == FLT_MAX)
-		return false;
+	if (depth_close != FLT_MAX) {
+		cent[0] = (double)mval[0];
+		cent[1] = (double)mval[1];
 
-	cent[0] = (double)mval[0];
-	cent[1] = (double)mval[1];
+		if (gluUnProject(cent[0], cent[1], depth_close,
+		                 mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+		{
+			mouse_worldloc[0] = (float)p[0];
+			mouse_worldloc[1] = (float)p[1];
+			mouse_worldloc[2] = (float)p[2];
+			return true;
+		}
+	}
 
-	if (!gluUnProject(cent[0], cent[1], depth_close,
-	                  mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
-	{
+	if (fallback_depth_pt) {
+		ED_view3d_win_to_3d_int(ar, fallback_depth_pt, mval, mouse_worldloc);
+		return true;
+	}
+	else {
 		return false;
 	}
-
-	mouse_worldloc[0] = (float)p[0];
-	mouse_worldloc[1] = (float)p[1];
-	mouse_worldloc[2] = (float)p[2];
-	return true;
 }
 
 void ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode)




More information about the Bf-blender-cvs mailing list