[Bf-blender-cvs] [f434dd6] temp-curve-draw: Tweak corner detection

Campbell Barton noreply at git.blender.org
Wed Apr 13 21:47:58 CEST 2016


Commit: f434dd6cca68aaa825acc18149fd4511d208aa64
Author: Campbell Barton
Date:   Thu Apr 14 05:47:14 2016 +1000
Branches: temp-curve-draw
https://developer.blender.org/rBf434dd6cca68aaa825acc18149fd4511d208aa64

Tweak corner detection

Only consider points above the angle limit to begin with.

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

M	extern/curve_fit_nd/intern/curve_fit_corners_detect.c
M	source/blender/editors/curve/editcurve_paint.c

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

diff --git a/extern/curve_fit_nd/intern/curve_fit_corners_detect.c b/extern/curve_fit_nd/intern/curve_fit_corners_detect.c
index 72a063b..47b8002 100644
--- a/extern/curve_fit_nd/intern/curve_fit_corners_detect.c
+++ b/extern/curve_fit_nd/intern/curve_fit_corners_detect.c
@@ -249,8 +249,17 @@ static double point_corner_angle(
 {
 	assert(angle_threshold_cos == cos(angle_threshold));
 
+	if (i == 0 || i == points_len - 1) {
+		return 0.0;
+	}
+
 	const double *p = &points[i * dims];
 
+	/* initial test */
+	if (angle_vnvnvn_cos(&points[(i - 1) * dims], p, &points[(i + 1) * dims], dims) > angle_threshold_cos) {
+		return 0.0;
+	}
+
 #ifdef USE_VLA
 	double p_mid_prev[dims];
 	double p_mid_next[dims];
@@ -295,8 +304,9 @@ static double point_corner_angle(
 			        p_max_prev, &i_max_prev_next,
 			        p_max_next, &i_max_next_prev))
 			{
+				const double angle_mid = acos(angle_mid_cos);
 				const double angle_max = angle_vnvnvn(p_max_prev, p, p_max_next, dims) / 2.0;
-				const double angle_diff = acos(angle_mid_cos) - angle_max;
+				const double angle_diff = angle_mid - angle_max;
 				if (angle_diff > angle_threshold) {
 					return angle_diff;
 				}
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index a24a04a..efb57c2 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -419,8 +419,8 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 
 		if (cps->flag & CURVE_PAINT_FLAG_CORNERS_DETECT) {
 			/* this could be configurable... */
-			const float corner_radius_min = error_threshold;
-			const float corner_radius_max = error_threshold * 3;
+			const float corner_radius_min = error_threshold / 8;
+			const float corner_radius_max = error_threshold * 2;
 			const unsigned int samples_max = 16;
 			spline_fit_corners_detect_fl(
 			        (const float *)coords, stroke_len, DIMS,




More information about the Bf-blender-cvs mailing list