GPencil: Restore ability for Smooth brush to affect pressure values of strokes
This commit is contained in:
@@ -223,9 +223,10 @@ static bool gp_brush_smooth_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i
|
||||
GP_EditBrush_Data *brush = gso->brush;
|
||||
bGPDspoint *pt = &gps->points[i];
|
||||
float inf = gp_brush_influence_calc(gso, radius, co);
|
||||
bool affect_pressure = (brush->flag & GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE) != 0;
|
||||
|
||||
/* perform smoothing */
|
||||
return gp_smooth_stroke(gps, i, inf);
|
||||
return gp_smooth_stroke(gps, i, inf, affect_pressure);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
|
@@ -128,19 +128,19 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
|
||||
|
||||
|
||||
/**
|
||||
* Apply smooth to stroke
|
||||
*
|
||||
* \param gps Stroke to smooth
|
||||
* \param i Point index
|
||||
* \param inf Smooth factor
|
||||
*/
|
||||
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf);
|
||||
* Apply smooth to stroke point
|
||||
* \param gps Stroke to smooth
|
||||
* \param i Point index
|
||||
* \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 affect_pressure);
|
||||
|
||||
/**
|
||||
* Subdivide a stroke
|
||||
* \param gps Stroke data
|
||||
* \param new_totpoints Total number of points
|
||||
*/
|
||||
*/
|
||||
void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints);
|
||||
|
||||
/* Layers Enums -------------------------------------- */
|
||||
|
@@ -751,10 +751,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
|
||||
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) {
|
||||
for (i = 0; i < gps->totpoints; i++) {
|
||||
gp_smooth_stroke(gps, i, gpl->smooth_drawfac);
|
||||
gp_smooth_stroke(gps, i, gpl->smooth_drawfac, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -535,13 +535,15 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
|
||||
|
||||
/**
|
||||
* Apply smooth to stroke point
|
||||
* \param gps Stroke to smooth
|
||||
* \param i Point index
|
||||
* \param inf Smooth factor
|
||||
*/
|
||||
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf)
|
||||
* \param gps Stroke to smooth
|
||||
* \param i Point index
|
||||
* \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 affect_pressure)
|
||||
{
|
||||
bGPDspoint *pt = &gps->points[i];
|
||||
float pressure = 0.0f;
|
||||
float sco[3] = {0.0f};
|
||||
|
||||
/* 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, &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 */
|
||||
interp_v3_v3v3(&pt->x, &pt->x, sco, inf);
|
||||
|
||||
if (affect_pressure) {
|
||||
pt->pressure = pressure;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user