diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 18:11:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 18:11:05 +0400 |
commit | b100f9d79de36900e24a21232621d38143f37786 (patch) | |
tree | 03aa3c6dcf601517f28c016b6528de22e5be7c86 /source/blender/editors/gpencil/gpencil_paint.c | |
parent | 363bfdc46a05a5225bd4abc76b14ba2002f414af (diff) |
edit gp_stroke_convertcoords not to modify the mval passed to it & make some mval args const elsewhere too.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index de989a1a292..c13feec5785 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -239,7 +239,7 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth) { bGPdata *gpd= p->gpd; @@ -251,10 +251,10 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo */ } else { - const int mx=mval[0], my=mval[1]; + int mval_prj[2]; float rvec[3], dvec[3]; float mval_f[2]; - + /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. In general, this * works OK, but it could of course be improved. @@ -267,10 +267,9 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo gp_get_3d_reference(p, rvec); /* method taken from editview.c - mouse_cursor() */ - project_int_noclip(p->ar, rvec, mval); + project_int_noclip(p->ar, rvec, mval_prj); - mval_f[0]= mval[0] - mx; - mval_f[0]= mval[1] - my; + VECSUB2D(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec); sub_v3_v3v3(out, rvec, dvec); } @@ -278,12 +277,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo /* 2d - on 'canvas' (assume that p->v2d is set) */ else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) { - float x, y; - - UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &x, &y); - - out[0]= x; - out[1]= y; + UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]); } #if 0 |