From b1e1f86eb7cfe040bd301beb91fb35a1c748667e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Apr 2014 14:30:13 +1000 Subject: [PATCH] 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. --- source/blender/editors/gpencil/gpencil_edit.c | 4 +--- source/blender/editors/interface/view2d.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 4c4926f5ae7..4a688f11767 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 8f501e226e7..9ce21e70eb4 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);