[Bf-blender-cvs] [259a4db] temp-curve-draw: Expose curve type option

Campbell Barton noreply at git.blender.org
Thu Apr 14 22:19:50 CEST 2016


Commit: 259a4db2c8040c4a7c7771b9c17f3d7c906540a5
Author: Campbell Barton
Date:   Fri Apr 15 06:19:52 2016 +1000
Branches: temp-curve-draw
https://developer.blender.org/rB259a4db2c8040c4a7c7771b9c17f3d7c906540a5

Expose curve type option

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index b155a6a..839d5fb 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -555,14 +555,12 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
-        ob = context.active_object
-
         tool_settings = context.tool_settings
-        mesh = ob.data
 
         col = layout.column()
 
         cps = tool_settings.curve_paint_settings
+        col.prop(cps, "curve_type")
         col.prop(cps, "error_threshold")
         col.prop(cps, "use_corners_detect")
 
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 4e7d66f..c9fab31 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -100,7 +100,7 @@ struct StrokeElem {
 
 struct CurveDrawData {
 	short init_event_type;
-	short nurbs_type;
+	short curve_type;
 
 	/* projecting 2D into 3D space */
 	struct {
@@ -251,7 +251,8 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 			        selem->location_local[1] - location_prev[1],
 			        selem->location_local[2] - location_prev[2]);
 			location_prev = selem->location_local;
-			gluSphere(qobj, stroke_elem_radius(cdd, selem), 16, 12);
+			const float radius = stroke_elem_radius(cdd, selem);
+			gluSphere(qobj, radius , 12, 8);
 
 			location_prev = selem->location_local;
 		}
@@ -592,7 +593,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 	nu->flag |= CU_SMOOTH;
 
 
-	if (cdd->nurbs_type == CU_BEZIER) {
+	if (cdd->curve_type == CU_BEZIER) {
 		nu->type = CU_BEZIER;
 
 #ifdef USE_SPLINE_FIT
@@ -815,12 +816,12 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
 	cdd->init_event_type = event->type;
 
-	cdd->nurbs_type = RNA_enum_get(op->ptr, "type");
-
 	view3d_set_viewcontext(C, &cdd->vc);
 
 	const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
 
+	cdd->curve_type = cps->curve_type;
+
 	cdd->radius.min = cps->radius_min;
 	cdd->radius.max = cps->radius_max;
 	cdd->radius.range = cps->radius_max - cps->radius_min;
@@ -870,14 +871,16 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 				cdd->project.use_depth = (cdd->vc.rv3d->depths != NULL);
 			}
 
-			if (cdd->project.use_depth) {
-				cdd->sample.use_substeps = true;
-			}
-			else {
+			/* use view plane (when set or as fallback when surface can't be found) */
+			if (cdd->project.use_depth == false) {
 				plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d);;
 				plane_no = rv3d->viewinv[2];
 				cdd->project.use_plane = true;
 			}
+
+			if (cdd->project.use_depth && (cdd->curve_type != CU_POLY)) {
+				cdd->sample.use_substeps = true;
+			}
 		}
 
 		if (cdd->project.use_plane) {
@@ -963,12 +966,6 @@ static int curve_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
 	return ret;
 }
 
-static EnumPropertyItem prop_curve_draw_types[] = {
-	{CU_POLY, "POLY", 0, "Polygon", ""},
-	{CU_BEZIER, "BEZIER", 0, "Bezier", ""},
-	{0, NULL, 0, NULL, NULL}
-};
-
 void CURVE_OT_draw(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -987,8 +984,6 @@ void CURVE_OT_draw(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
 	/* properties */
-	ot->prop = RNA_def_enum(ot->srna, "type", prop_curve_draw_types, CU_BEZIER, "Type", "");
-
 	RNA_def_float(ot->srna, "error", 0.0f, 0.0f, 10.0f, "Error", "", 0.0001f, 10.0f);
 
 	RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 2b879a5..1520514 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1268,10 +1268,10 @@ typedef enum {
 
 
 typedef struct CurvePaintSettings {
-	char flag;
+	char curve_type;
 	char depth_mode;
 	char surface_plane;
-	char _pad[1];
+	char flag;
 	int error_threshold;
 	float radius_min, radius_max;
 	float radius_offset;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 25424e8..2fdffd1 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2616,6 +2616,16 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	RNA_def_struct_path_func(srna, "rna_CurvePaintSettings_path");
 	RNA_def_struct_ui_text(srna, "Curve Paint Settings", "");
 
+	static EnumPropertyItem curve_type_items[] = {
+		{CU_POLY, "POLY", 0, "Poly", ""},
+		{CU_BEZIER, "BEZIER", 0, "Bezier", ""},
+		{0, NULL, 0, NULL, NULL}};
+
+	prop = RNA_def_property(srna, "curve_type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "curve_type");
+	RNA_def_property_enum_items(prop, curve_type_items);
+	RNA_def_property_ui_text(prop, "Type", "Type of curve to use for new strokes");
+
 	prop = RNA_def_property(srna, "use_corners_detect", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVE_PAINT_FLAG_CORNERS_DETECT);
 	RNA_def_property_ui_text(prop, "Detect Corners", "");
@@ -2629,7 +2639,6 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS);
 	RNA_def_property_ui_text(prop, "Only First", "Use the start of the stroke for the depth");
 
-
 	prop = RNA_def_property(srna, "error_threshold", PROP_INT, PROP_PIXEL);
 	RNA_def_property_range(prop, 1, 100);
 	RNA_def_property_ui_text(prop, "Tolerance", "Allow deviation for a smoother, less preceise line");




More information about the Bf-blender-cvs mailing list