[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36766] trunk/blender/source/blender/ editors: change window_to_3d to take screen coords as floats.

Campbell Barton ideasman42 at gmail.com
Thu May 19 09:55:48 CEST 2011


Revision: 36766
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36766
Author:   campbellbarton
Date:     2011-05-19 07:55:48 +0000 (Thu, 19 May 2011)
Log Message:
-----------
change window_to_3d to take screen coords as floats.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
    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/gpencil/gpencil_edit.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2011-05-19 07:43:10 UTC (rev 36765)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2011-05-19 07:55:48 UTC (rev 36766)
@@ -377,24 +377,27 @@
 	}
 	else {
 		float *fp= give_cursor(scene, v3d);
-		int mx, my;
+		float mx, my;
 		
 		/* get screen coordinate */
 		if (gps->flag & GP_STROKE_2DSPACE) {
+			int mxi, myi;
 			View2D *v2d= &ar->v2d;
-			UI_view2d_view_to_region(v2d, pt->x, pt->y, &mx, &my);
+			UI_view2d_view_to_region(v2d, pt->x, pt->y, &mxi, &myi);
+			mx= mxi;
+			my= myi;
 		}
 		else {
 			if(subrect) {
-				mx= (int)((pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
-				my= (int)((pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
+				mx= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
+				my= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
 			}
 			else {
-				mx= (int)(pt->x / 100 * ar->winx);
-				my= (int)(pt->y / 100 * ar->winy);
+				mx= (float)pt->x / 100.0f * ar->winx;
+				my= (float)pt->y / 100.0f * ar->winy;
 			}
 		}
-		
+
 		/* convert screen coordinate to 3d coordinates 
 		 *	- method taken from editview.c - mouse_cursor() 
 		 */

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2011-05-19 07:43:10 UTC (rev 36765)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2011-05-19 07:55:48 UTC (rev 36766)
@@ -80,9 +80,9 @@
 float *give_cursor(struct Scene *scene, struct View3D *v3d);
 
 int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my);
-void window_to_3d_delta(struct ARegion *ar, float out[3], const int mx, const int my);
-void window_to_3d_vector(struct ARegion *ar, float out[3], const int mx, const int my);
+void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my);
+void window_to_3d_delta(struct ARegion *ar, float out[3], const float mx, const float my);
+void window_to_3d_vector(struct ARegion *ar, float out[3], const float mx, const float my);
 void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
 
 /* Depth buffer */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2011-05-19 07:43:10 UTC (rev 36765)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2011-05-19 07:55:48 UTC (rev 36766)
@@ -1074,7 +1074,7 @@
 		float tvec[3];
 		float tpos[3];
 		float new_dist;
-		short vb[2], mouseloc[2];
+		int vb[2], mouseloc[2];
 
 		mouseloc[0]= mx - ar->winrct.xmin;
 		mouseloc[1]= my - ar->winrct.ymin;
@@ -1087,7 +1087,7 @@
 
 		/* Project cursor position into 3D space */
 		initgrabz(rv3d, tpos[0], tpos[1], tpos[2]);
-		window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2, mouseloc[1]-vb[1]/2);
+		window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2.0f, mouseloc[1]-vb[1]/2.0f);
 
 		/* Calculate view target position for dolly */
 		add_v3_v3v3(tvec, tpos, dvec);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2011-05-19 07:43:10 UTC (rev 36765)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2011-05-19 07:55:48 UTC (rev 36766)
@@ -598,7 +598,7 @@
 	return flip;
 }
 
-void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my)
+void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my)
 {
 	RegionView3D *rv3d= ar->regiondata;
 	
@@ -630,7 +630,7 @@
 
 /* always call initgrabz */
 /* only to detect delta motion */
-void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my)
+void window_to_3d_delta(ARegion *ar, float out[3], const float mx, const float my)
 {
 	RegionView3D *rv3d= ar->regiondata;
 	float dx, dy;
@@ -646,7 +646,7 @@
 /* doesn't rely on initgrabz */
 /* for perspective view, get the vector direction to
  * the mouse cursor as a normalized vector */
-void window_to_3d_vector(ARegion *ar, float out[3], const int mx, const int my)
+void window_to_3d_vector(ARegion *ar, float out[3], const float mx, const float my)
 {
 	RegionView3D *rv3d= ar->regiondata;
 




More information about the Bf-blender-cvs mailing list