[Bf-blender-cvs] [a7538b1] master: GPencil: Restore ability for Smooth brush to affect pressure values of strokes

Joshua Leung noreply at git.blender.org
Sun Mar 27 16:22:52 CEST 2016


Commit: a7538b19c6641be5e210a1f8286c5cd4ce945389
Author: Joshua Leung
Date:   Mon Mar 28 02:55:59 2016 +1300
Branches: master
https://developer.blender.org/rBa7538b19c6641be5e210a1f8286c5cd4ce945389

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

===================================================================

M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index ab6217c..cb99226 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 d6d9d7c..c3fafaa 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 6f4d65f..740fb8e 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 c2ffd5e..30558b0 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;
 }




More information about the Bf-blender-cvs mailing list