diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-03-14 13:27:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-03-14 13:29:24 +0300 |
commit | a12d42712bae8906e289ebe2200c7189f68a5db3 (patch) | |
tree | 0d7f0cf921024bd6b14c265a129cf7eaae8b04ec /source/blender | |
parent | e509e911a3629cdd8f3f7c5f0a644b2dffe85d5d (diff) |
Fix T47772: Randomize stroke has direction bias
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index efbb117ebe2..5360f07fed7 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -659,7 +659,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in * and then project these to get the points/distances in * viewspace as needed */ - float mvec[2], svec[2], nco[2]; + float mvec[2], svec[2]; /* mouse movement in ints -> floats */ mvec[0] = (float)(gso->mval[0] - gso->mval_prev[0]); @@ -679,16 +679,20 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in mul_v2_fl(svec, fac); } - nco[0] = (float)co[0] + svec[0]; - nco[1] = (float)co[1] + svec[1]; - //printf("%f %f (%f), nco = {%f %f}, co = %d %d\n", svec[0], svec[1], fac, nco[0], nco[1], co[0], co[1]); /* convert to dataspace */ if (gps->flag & GP_STROKE_3DSPACE) { /* 3D: Project to 3D space */ if (gso->sa->spacetype == SPACE_VIEW3D) { - gp_point_xy_to_3d(&gso->gsc, gso->scene, nco, &pt->x); + bool flip; + RegionView3D *rv3d = gso->ar->regiondata; + float zfac = ED_view3d_calc_zfac(rv3d, &pt->x, &flip); + if (flip == false) { + float dvec[3]; + ED_view3d_win_to_delta(gso->gsc.ar, svec, dvec, zfac); + add_v3_v3(&pt->x, dvec); + } } else { /* ERROR */ @@ -698,6 +702,10 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in else { /* 2D: As-is */ // XXX: v2d scaling/offset? + float nco[2]; + nco[0] = (float)co[0] + svec[0]; + nco[1] = (float)co[1] + svec[1]; + copy_v2_v2(&pt->x, nco); } |