[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31091] trunk/blender/source/blender/ editors: bugfix/functionality fix [#21752] 3D cursor vanished and does not come back

Campbell Barton ideasman42 at gmail.com
Fri Aug 6 05:52:14 CEST 2010


Revision: 31091
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31091
Author:   campbellbarton
Date:     2010-08-06 05:52:13 +0200 (Fri, 06 Aug 2010)

Log Message:
-----------
bugfix/functionality fix [#21752] 3D cursor vanished and does not come back

Setting the 3d cursor in perspective mode would keep the cursor behind the viewport,
now check if the cursor is begind the viewport and use the orbit location to set the cursor depth rather then the existing plane.

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

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2010-08-06 03:11:19 UTC (rev 31090)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2010-08-06 03:52:13 UTC (rev 31091)
@@ -72,7 +72,7 @@
 
 float *give_cursor(struct Scene *scene, struct View3D *v3d);
 
-void initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
+int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
 void window_to_3d(struct ARegion *ar, float *vec, short mx, short my);
 void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my);
 void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2010-08-06 03:11:19 UTC (rev 31090)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2010-08-06 03:52:13 UTC (rev 31091)
@@ -2396,7 +2396,7 @@
 	float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
 	short mx, my, mval[2];
 //	short ctrl= 0; // XXX
-
+	int flip;
 	fp= give_cursor(scene, v3d);
 
 //	if(obedit && ctrl) lr_click= 1;
@@ -2404,9 +2404,18 @@
 
 	mx= event->x - ar->winrct.xmin;
 	my= event->y - ar->winrct.ymin;
+
 	project_short_noclip(ar, fp, mval);
+	flip= initgrabz(rv3d, fp[0], fp[1], fp[2]);
+	
+	/* reset the depth based on the view offset */
+	if(flip) {
+		negate_v3_v3(fp, rv3d->ofs);
 
-	initgrabz(rv3d, fp[0], fp[1], fp[2]);
+		/* re initialize */
+		project_short_noclip(ar, fp, mval);
+		flip= initgrabz(rv3d, fp[0], fp[1], fp[2]);
+	}
 
 	if(mval[0]!=IS_CLIPPED) {
 		short depth_used = 0;

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2010-08-06 03:11:19 UTC (rev 31090)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2010-08-06 03:52:13 UTC (rev 31091)
@@ -588,11 +588,13 @@
 	normalize_v3(vec);
 }
 
-void initgrabz(RegionView3D *rv3d, float x, float y, float z)
+int initgrabz(RegionView3D *rv3d, float x, float y, float z)
 {
-	if(rv3d==NULL) return;
+	int flip= FALSE;
+	if(rv3d==NULL) return flip;
 	rv3d->zfac= rv3d->persmat[0][3]*x+ rv3d->persmat[1][3]*y+ rv3d->persmat[2][3]*z+ rv3d->persmat[3][3];
-	
+	if (rv3d->zfac < 0.0f)
+		flip= TRUE;
 	/* if x,y,z is exactly the viewport offset, zfac is 0 and we don't want that 
 		* (accounting for near zero values)
 		* */
@@ -605,6 +607,8 @@
 	// 	-- Aligorith, 2009Aug31
 	//if (rv3d->zfac < 0.0f) rv3d->zfac = 1.0f;
 	if (rv3d->zfac < 0.0f) rv3d->zfac= -rv3d->zfac;
+	
+	return flip;
 }
 
 /* always call initgrabz */





More information about the Bf-blender-cvs mailing list