[Bf-blender-cvs] [b1e1f86e] master: Fix for UI_view2d_to_region_float (was ignoring x, y args)

Campbell Barton noreply at git.blender.org
Mon Apr 21 06:31:28 CEST 2014


Commit: b1e1f86eb7cfe040bd301beb91fb35a1c748667e
Author: Campbell Barton
Date:   Mon Apr 21 14:30:13 2014 +1000
https://developer.blender.org/rBb1e1f86eb7cfe040bd301beb91fb35a1c748667e

Fix for UI_view2d_to_region_float (was ignoring x,y args)

use this for grease pencil stroke conversion to avoid float->int->float conversion.

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

M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/interface/view2d.c

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 4c4926f..4a688f1 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -456,10 +456,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
 
 		/* get screen coordinate */
 		if (gps->flag & GP_STROKE_2DSPACE) {
-			int mvali[2];
 			View2D *v2d = &ar->v2d;
-			UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1);
-			VECCOPY2D(mvalf, mvali);
+			UI_view2d_to_region_float(v2d, pt->x, pt->y, &mvalf[0], &mvalf[1]);
 		}
 		else {
 			if (subrect) {
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 8f501e2..9ce21e7 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2045,8 +2045,8 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, in
 void UI_view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
 {
 	/* express given coordinates as proportional values */
-	x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur);
-	y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur);
+	x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+	y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
 
 	/* convert proportional distances to screen coordinates */
 	*regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);




More information about the Bf-blender-cvs mailing list