[Bf-blender-cvs] [d69d68621fb] blender2.8: GP: Improve smooth interpolation calc

Antonioya noreply at git.blender.org
Sun Sep 9 16:07:02 CEST 2018


Commit: d69d68621fbc382b5a46c6c9edb191f1f7848aee
Author: Antonioya
Date:   Sun Sep 9 16:06:10 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBd69d68621fbc382b5a46c6c9edb191f1f7848aee

GP: Improve smooth interpolation calc

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

M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 45163de559e..08c490252e5 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1334,7 +1334,11 @@ bool BKE_gpencil_smooth_stroke_strength(bGPDstroke *gps, int point_index, float
 	/* the optimal value is the corresponding to the interpolation of the strength
 	 * at the distance of point b
 	 */
-	const float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
+	float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
+	/* sometimes the factor can be wrong due stroke geometry, so use middle point */
+	if ((fac < 0.0f) || (fac > 1.0f)) {
+		fac = 0.5f;
+	}
 	const float optimal = (1.0f - fac) * pta->strength + fac * ptc->strength;
 
 	/* Based on influence factor, blend between original and optimal */
@@ -1369,7 +1373,10 @@ bool BKE_gpencil_smooth_stroke_thickness(bGPDstroke *gps, int point_index, float
 	 * at the distance of point b
 	 */
 	float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
-	CLAMP(fac, 0.0f, 1.0f);
+	/* sometimes the factor can be wrong due stroke geometry, so use middle point */
+	if ((fac < 0.0f) || (fac > 1.0f)) {
+		fac = 0.5f;
+	}
 	float optimal = interpf(ptc->pressure, pta->pressure, fac);
 
 	/* Based on influence factor, blend between original and optimal */
@@ -1404,6 +1411,10 @@ bool BKE_gpencil_smooth_stroke_uv(bGPDstroke *gps, int point_index, float influe
 	 * at the distance of point b
 	 */
 	float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
+	/* sometimes the factor can be wrong due stroke geometry, so use middle point */
+	if ((fac < 0.0f) || (fac > 1.0f)) {
+		fac = 0.5f;
+	}
 	float optimal = interpf(ptc->uv_rot, pta->uv_rot, fac);
 
 	/* Based on influence factor, blend between original and optimal */



More information about the Bf-blender-cvs mailing list