GPencil: Restore ability for Smooth brush to affect pressure values of strokes

This commit is contained in:
Joshua Leung
2016-03-28 02:55:59 +13:00
parent 00cfbeef11
commit a7538b19c6
4 changed files with 28 additions and 16 deletions

View File

@@ -223,9 +223,10 @@ static bool gp_brush_smooth_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i
GP_EditBrush_Data *brush = gso->brush; GP_EditBrush_Data *brush = gso->brush;
bGPDspoint *pt = &gps->points[i]; bGPDspoint *pt = &gps->points[i];
float inf = gp_brush_influence_calc(gso, radius, co); float inf = gp_brush_influence_calc(gso, radius, co);
bool affect_pressure = (brush->flag & GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE) != 0;
/* perform smoothing */ /* perform smoothing */
return gp_smooth_stroke(gps, i, inf); return gp_smooth_stroke(gps, i, inf, affect_pressure);
} }
/* ----------------------------------------------- */ /* ----------------------------------------------- */

View File

@@ -128,19 +128,19 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
/** /**
* Apply smooth to stroke * Apply smooth to stroke point
* * \param gps Stroke to smooth
* \param gps Stroke to smooth * \param i Point index
* \param i Point index * \param inf Amount of smoothing to apply
* \param inf Smooth factor * \param affect_pressure Apply smoothing to pressure values too?
*/ */
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf); bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure);
/** /**
* Subdivide a stroke * Subdivide a stroke
* \param gps Stroke data * \param gps Stroke data
* \param new_totpoints Total number of points * \param new_totpoints Total number of points
*/ */
void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints); void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints);
/* Layers Enums -------------------------------------- */ /* Layers Enums -------------------------------------- */

View File

@@ -751,10 +751,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gp_subdivide_stroke(gps, sub); gp_subdivide_stroke(gps, sub);
} }
} }
/* smooth stroke - only if there's somethign to do */ /* smooth stroke - only if there's something to do */
if (gpl->smooth_drawfac > 0.0f) { if (gpl->smooth_drawfac > 0.0f) {
for (i = 0; i < gps->totpoints; i++) { for (i = 0; i < gps->totpoints; i++) {
gp_smooth_stroke(gps, i, gpl->smooth_drawfac); gp_smooth_stroke(gps, i, gpl->smooth_drawfac, true);
} }
} }

View File

@@ -535,13 +535,15 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
/** /**
* Apply smooth to stroke point * Apply smooth to stroke point
* \param gps Stroke to smooth * \param gps Stroke to smooth
* \param i Point index * \param i Point index
* \param inf Smooth factor * \param inf Amount of smoothing to apply
*/ * \param affect_pressure Apply smoothing to pressure values too?
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf) */
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure)
{ {
bGPDspoint *pt = &gps->points[i]; bGPDspoint *pt = &gps->points[i];
float pressure = 0.0f;
float sco[3] = {0.0f}; float sco[3] = {0.0f};
/* Do nothing if not enough points to smooth out */ /* Do nothing if not enough points to smooth out */
@@ -585,12 +587,21 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf)
madd_v3_v3fl(sco, &pt1->x, average_fac); madd_v3_v3fl(sco, &pt1->x, average_fac);
madd_v3_v3fl(sco, &pt2->x, average_fac); madd_v3_v3fl(sco, &pt2->x, average_fac);
/* do pressure too? */
if (affect_pressure) {
pressure += pt1->pressure * average_fac;
pressure += pt2->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_v3_v3v3(&pt->x, &pt->x, sco, inf); interp_v3_v3v3(&pt->x, &pt->x, sco, inf);
if (affect_pressure) {
pt->pressure = pressure;
}
return true; return true;
} }