Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2019-08-18 12:36:04 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-08-18 12:40:23 +0300
commit454b120f48201abe2e1a9ca7e5d25c28cb04013a (patch)
tree788a070683a088aefca0db2127b442b3c4672662
parent8ac40e4163094dd1cddf8103ea1949ae5de179b9 (diff)
GPencil: Interpolate pressure in active Smooth
Now the pressure is interpolated in active smooth and not only position as before.
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5fec9484f10..ee78a947b55 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 */
+ /* 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) */