[Bf-blender-cvs] [bbb5e56] temp-curve-draw: Add corner angle as operator option

Campbell Barton noreply at git.blender.org
Fri Apr 15 09:43:35 CEST 2016


Commit: bbb5e5658ae6516a9846f2302ec1eb7869d7d7e4
Author: Campbell Barton
Date:   Fri Apr 15 17:43:25 2016 +1000
Branches: temp-curve-draw
https://developer.blender.org/rBbbb5e5658ae6516a9846f2302ec1eb7869d7d7e4

Add corner angle as operator option

Allows for adjusting after the stroke

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

M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/curve/editcurve_paint.c

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

diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index c6e37f2d..18740d4 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1080,7 +1080,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 				cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
 				cps->error_threshold = 8;
 				cps->radius_max = 1.0f;
-				cps->corner_angle = DEG2RAD(70);
+				cps->corner_angle = DEG2RADF(70.0f);
 			}
 		}
 
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 483a207..74f526e 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -643,9 +643,16 @@ static void curve_draw_exec_precalc(wmOperator *op)
 {
 	struct CurveDrawData *cdd = op->customdata;
 	const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
+	PropertyRNA *prop;
+
+	prop = RNA_struct_find_property(op->ptr, "corner_angle");
+	if (!RNA_property_is_set(op->ptr, prop)) {
+		const float corner_angle = (cps->flag & CURVE_PAINT_FLAG_CORNERS_DETECT) ? cps->corner_angle : M_PI;
+		RNA_property_float_set(op->ptr, prop, corner_angle);
+	}
 
-	PropertyRNA *prop_error = RNA_struct_find_property(op->ptr, "error_threshold");
-	if (!RNA_property_is_set(op->ptr, prop_error)) {
+	prop = RNA_struct_find_property(op->ptr, "error_threshold");
+	if (!RNA_property_is_set(op->ptr, prop)) {
 
 		/* error isnt set so we'll have to calculate it from the pixel values */
 		BLI_mempool_iter iter;
@@ -664,7 +671,7 @@ static void curve_draw_exec_precalc(wmOperator *op)
 		}
 		scale_px = ((len_3d > 0.0f) && (len_2d > 0.0f)) ?  (len_3d / len_2d) : 0.0f;
 		float error_threshold = (cps->error_threshold * U.pixelsize) * scale_px;
-		RNA_property_float_set(op->ptr, prop_error, error_threshold);
+		RNA_property_float_set(op->ptr, prop, error_threshold);
 	}
 
 	if ((cps->radius_taper_start != 0.0f) ||
@@ -775,6 +782,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 
 		/* error in object local space */
 		const float error_threshold = RNA_float_get(op->ptr, "error_threshold");
+		const float corner_angle = RNA_float_get(op->ptr, "corner_angle");
 
 		{
 			BLI_mempool_iter iter;
@@ -793,7 +801,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 		unsigned int *corners = NULL;
 		unsigned int  corners_len = 0;
 
-		if (cps->flag & CURVE_PAINT_FLAG_CORNERS_DETECT) {
+		if (corner_angle < M_PI) {
 			/* this could be configurable... */
 			const float corner_radius_min = error_threshold / 8;
 			const float corner_radius_max = error_threshold * 2;
@@ -802,7 +810,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 			spline_fit_corners_detect_fl(
 			        (const float *)coords, stroke_len, dims,
 			        corner_radius_min, corner_radius_max,
-			        samples_max, cps->corner_angle,
+			        samples_max, corner_angle,
 			        &corners, &corners_len);
 		}
 
@@ -1062,9 +1070,10 @@ static int curve_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
 		if (event->val == KM_RELEASE) {
 			ED_region_tag_redraw(cdd->vc.ar);
 
+			curve_draw_exec_precalc(op);
+
 			curve_draw_stroke_to_operator(op);
 
-			curve_draw_exec_precalc(op);
 			curve_draw_exec(C, op);
 
 			return OPERATOR_FINISHED;
@@ -1118,6 +1127,10 @@ void CURVE_OT_draw(wmOperatorType *ot)
 	        0.0001f, 10.0f);
 	RNA_def_property_ui_range(prop, 0.0, 10, 1, 4);
 
+	prop = RNA_def_float_distance(
+	        ot->srna, "corner_angle", DEG2RADF(70.0f), 0.0f, M_PI, "Corner Angle", "", 0.0f, M_PI);
+	RNA_def_property_subtype(prop, PROP_ANGLE);
+
 	prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
 	RNA_def_property_flag(prop, PROP_SKIP_SAVE);




More information about the Bf-blender-cvs mailing list