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 /source/blender/editors/gpencil/gpencil_utils.c
parent00cfbeef11c62364e343df27d00fd363f625f2ad (diff)
GPencil: Restore ability for Smooth brush to affect pressure values of strokes
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c21
1 files changed, 16 insertions, 5 deletions
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;
}