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:
authorJoshua Leung <aligorith@gmail.com>2016-03-27 16:55:59 +0300
committerJoshua Leung <aligorith@gmail.com>2016-03-27 17:21:29 +0300
commita7538b19c6641be5e210a1f8286c5cd4ce945389 (patch)
tree39773304bee6908dd6a3ebb23cd33318d2aa656e
parent00cfbeef11c62364e343df27d00fd363f625f2ad (diff)
GPencil: Restore ability for Smooth brush to affect pressure values of strokes
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h16
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c21
4 files changed, 28 insertions, 16 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index ab6217c20e3..cb992267b6c 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -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);
}
/* ----------------------------------------------- */
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index d6d9d7cb347..c3fafaae9c3 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -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 -------------------------------------- */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6f4d65fc09e..740fb8e0096 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -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);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index c2ffd5ea82d..30558b00b9f 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -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;
}