diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-02-24 01:05:44 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-02-24 01:06:06 +0300 |
commit | 4d9d87d2bf1eb36168f54f94d353d804a6978ed5 (patch) | |
tree | 54da18e56267c1c418622fc04eb822d8307d06ae /source/blender | |
parent | b67b1d59c31ff65be11035ff2d4d31d6f6dc32f0 (diff) |
GPencil: Improve Flip algorithm for Interpolate
If the lines cross, but the angle is very sharp, check the distance between the extremes.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_interpolate.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 1823a962926..c242d3a73c1 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -198,6 +198,20 @@ static bool gpencil_stroke_need_flip(Depsgraph *depsgraph, gpencil_point_to_xy_fl(gsc, gps_from, &pt_dummy_ps, &v2b[0], &v2b[1]); if (isect_seg_seg_v2(v1a, v1b, v2a, v2b) == ISECT_LINE_LINE_CROSS) { + float v1[2], v2[2]; + sub_v2_v2v2(v1, v1b, v1a); + sub_v2_v2v2(v2, v2b, v2a); + float angle = angle_v2v2(v1, v2); + /* For very sharp angles, check distance between extremes. */ + if (angle < DEG2RADF(15.0f)) { + float dist_start = len_squared_v2v2(v1a, v1a); + float dist_end = len_squared_v2v2(v1a, v1b); + if (dist_end < dist_start) { + return true; + } + return false; + } + return true; } |