diff options
author | Antonioya <blendergit@gmail.com> | 2018-09-09 17:06:10 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-09-09 17:06:10 +0300 |
commit | d69d68621fbc382b5a46c6c9edb191f1f7848aee (patch) | |
tree | 9d4fa65f3d086411f2563aa5c78a9f196c34ee62 /source | |
parent | 84d85f963fc140f42501670527d579e683ab4fb1 (diff) |
GP: Improve smooth interpolation calc
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 45163de559e..08c490252e5 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1334,7 +1334,11 @@ bool BKE_gpencil_smooth_stroke_strength(bGPDstroke *gps, int point_index, float /* the optimal value is the corresponding to the interpolation of the strength * at the distance of point b */ - const float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); + float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); + /* sometimes the factor can be wrong due stroke geometry, so use middle point */ + if ((fac < 0.0f) || (fac > 1.0f)) { + fac = 0.5f; + } const float optimal = (1.0f - fac) * pta->strength + fac * ptc->strength; /* Based on influence factor, blend between original and optimal */ @@ -1369,7 +1373,10 @@ bool BKE_gpencil_smooth_stroke_thickness(bGPDstroke *gps, int point_index, float * at the distance of point b */ float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); - CLAMP(fac, 0.0f, 1.0f); + /* sometimes the factor can be wrong due stroke geometry, so use middle point */ + if ((fac < 0.0f) || (fac > 1.0f)) { + fac = 0.5f; + } float optimal = interpf(ptc->pressure, pta->pressure, fac); /* Based on influence factor, blend between original and optimal */ @@ -1404,6 +1411,10 @@ bool BKE_gpencil_smooth_stroke_uv(bGPDstroke *gps, int point_index, float influe * at the distance of point b */ float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); + /* sometimes the factor can be wrong due stroke geometry, so use middle point */ + if ((fac < 0.0f) || (fac > 1.0f)) { + fac = 0.5f; + } float optimal = interpf(ptc->uv_rot, pta->uv_rot, fac); /* Based on influence factor, blend between original and optimal */ |