Commit: 90183d7d5ca731b50b31e9940f39e6b758886a15 Author: Antonio Vazquez Date: Wed Aug 14 10:23:35 2019 +0200 Branches: greasepencil-object https://developer.blender.org/rB90183d7d5ca731b50b31e9940f39e6b758886a15
GPencil: Smooth pressure in Active Smooth This smooth is applied while drawing. =================================================================== M source/blender/editors/gpencil/gpencil_paint.c =================================================================== diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 60c104dd4e5..d0fd3770950 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -563,7 +563,7 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa static void gp_smooth_buffer(tGPsdata *p, float inf, int idx) { bGPdata *gpd = p->gpd; - short num_points = gpd->runtime.sbuffer_used; + const short num_points = gpd->runtime.sbuffer_used; /* Do nothing if not enough points to smooth out */ if ((num_points < 3) || (idx < 3) || (inf == 0.0f)) { @@ -571,10 +571,7 @@ static void gp_smooth_buffer(tGPsdata *p, float inf, int idx) } tGPspoint *points = (tGPspoint *)gpd->runtime.sbuffer; - float steps = 4.0f; - if (idx < 4) { - steps--; - } + const float steps = (idx < 4) ? 3.0f : 4.0f; tGPspoint *pta = idx >= 4 ? &points[idx - 4] : NULL; tGPspoint *ptb = idx >= 3 ? &points[idx - 3] : NULL; @@ -583,29 +580,36 @@ static void gp_smooth_buffer(tGPsdata *p, float inf, int idx) float sco[2] = {0.0f}; float a[2], b[2], c[2], d[2]; + float pressure = 0.0f; const float average_fac = 1.0f / steps; /* Compute smoothed coordinate by taking the ones nearby */ if (pta) { copy_v2_v2(a, &pta->x); madd_v2_v2fl(sco, a, average_fac); + pressure += pta->pressure * average_fac; } if (ptb) { copy_v2_v2(b, &ptb->x); madd_v2_v2fl(sco, b, average_fac); + pressure += ptb->pressure * average_fac; } if (ptc) { copy_v2_v2(c, &ptc->x); madd_v2_v2fl(sco, c, average_fac); + pressure += ptc->pressure * average_fac; } if (ptd) { copy_v2_v2(d, &ptd->x); madd_v2_v2fl(sco, d, average_fac); + pressure += ptd->pressure * average_fac; } /* Based on influence factor, blend between original and optimal smoothed coordinate */ interp_v2_v2v2(c, c, sco, inf); copy_v2_v2(&ptc->x, c); + /* Interpolate pressure */ + ptc->pressure = interpf(ptc->pressure, pressure, inf); } /* add current stroke-point to buffer (returns whether point was successfully added) */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs