[Bf-blender-cvs] [8cc319d] temp-curve-draw: Add options for projection plane when drawing onto the surface

Campbell Barton noreply at git.blender.org
Thu Apr 14 21:21:14 CEST 2016


Commit: 8cc319d40f814301b778627bf7f7746aef7a881a
Author: Campbell Barton
Date:   Fri Apr 15 04:44:57 2016 +1000
Branches: temp-curve-draw
https://developer.blender.org/rB8cc319d40f814301b778627bf7f7746aef7a881a

Add options for projection plane when drawing onto the surface

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

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 124ebbd..8a0f96d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -547,10 +547,10 @@ class VIEW3D_PT_tools_add_curve_edit(View3DPanel, Panel):
         VIEW3D_PT_tools_add_object.draw_add_curve(col, label=True)
 
 
-class VIEW3D_PT_tools_curveedit_options(View3DPanel, Panel):
+class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
     bl_category = "Options"
     bl_context = "curve_edit"
-    bl_label = "Curve Options"
+    bl_label = "Curve Stroke"
 
     def draw(self, context):
         layout = self.layout
@@ -562,7 +562,6 @@ class VIEW3D_PT_tools_curveedit_options(View3DPanel, Panel):
 
         col = layout.column()
 
-        col.label("Curve Stroke:")
         cps = tool_settings.curve_paint_settings
         col.prop(cps, "error_threshold")
         col.prop(cps, "use_corners_detect")
@@ -590,6 +589,9 @@ class VIEW3D_PT_tools_curveedit_options(View3DPanel, Panel):
         col = layout.column()
         if cps.depth_mode == 'SURFACE':
             col.prop(cps, "use_stroke_endpoints")
+            if cps.use_stroke_endpoints:
+                colsub = layout.column(align=True)
+                colsub.prop(cps, "depth_plane", expand=True)
 
 
 # ********** default tools for editmode_surface ****************
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 83d0aa1..e5783cf 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -869,15 +869,21 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		cdd->project.use_depth = false;
 		cdd->project.use_plane = true;
 
-		/* calculate the plane from the surface normal */
-		float normal[3];
-		if (depth_read_normal(&cdd->vc, &cdd->mats, event->mval, normal)) {
-			float cross_a[3], cross_b[3];
-			cross_v3_v3v3(cross_a, rv3d->viewinv[2], normal);
-			cross_v3_v3v3(cross_b, normal, cross_a);
-			copy_v3_v3(normal, cross_b);
+		float normal[3] = {0.0f};
+		if (ELEM(cps->depth_plane, CURVE_PAINT_PLANE_NORMAL_VIEW, CURVE_PAINT_PLANE_NORMAL_SURFACE)) {
+			if (depth_read_normal(&cdd->vc, &cdd->mats, event->mval, normal)) {
+				if (cps->depth_plane == CURVE_PAINT_PLANE_NORMAL_VIEW) {
+					float cross_a[3], cross_b[3];
+					cross_v3_v3v3(cross_a, rv3d->viewinv[2], normal);
+					cross_v3_v3v3(cross_b, normal, cross_a);
+					copy_v3_v3(normal, cross_b);
+				}
+
+			}
 		}
-		else {
+
+		/* CURVE_PAINT_PLANE_VIEW or fallback */
+		if (is_zero_v3(normal)) {
 			copy_v3_v3(normal, rv3d->viewinv[2]);
 		}
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 957e44a..d8b7234 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1270,7 +1270,8 @@ typedef enum {
 typedef struct CurvePaintSettings {
 	char flag;
 	char depth_mode;
-	char _pad[6];
+	char depth_plane;
+	char _pad[5];
 	int error_threshold;
 	float radius_min, radius_max;
 	float corner_angle;
@@ -1283,10 +1284,16 @@ enum {
 };
 
 enum {
-	CURVE_PAINT_PROJECT_VIEW			= 0,
+	CURVE_PAINT_PROJECT_CURSOR		= 0,
 	CURVE_PAINT_PROJECT_SURFACE		= 1,
 };
 
+enum {
+	CURVE_PAINT_PLANE_NORMAL_VIEW		= 0,
+	CURVE_PAINT_PLANE_NORMAL_SURFACE	= 1,
+	CURVE_PAINT_PLANE_VIEW				= 2,
+};
+
 
 /* *************************************************************** */
 /* Stats */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 0f3e5d4..b880580 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2627,7 +2627,7 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 
 	prop = RNA_def_property(srna, "use_stroke_endpoints", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS);
-	RNA_def_property_ui_text(prop, "Only First", "Only use the first part of the stroke for snapping");
+	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);
@@ -2649,7 +2649,7 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	RNA_def_property_ui_text(prop, "Radius Max", "");
 
 	static EnumPropertyItem depth_mode_items[] = {
-		{CURVE_PAINT_PROJECT_VIEW,  "VIEW",  0, "View",  ""},
+		{CURVE_PAINT_PROJECT_CURSOR,  "CURSOR",  0, "Cursor",  ""},
 		{CURVE_PAINT_PROJECT_SURFACE, "SURFACE", 0, "Surface", ""},
 		{0, NULL, 0, NULL, NULL}};
 
@@ -2657,6 +2657,17 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	RNA_def_property_enum_sdna(prop, NULL, "depth_mode");
 	RNA_def_property_enum_items(prop, depth_mode_items);
 	RNA_def_property_ui_text(prop, "Depth", "Method of projecting depth");
+
+	static EnumPropertyItem depth_plane_items[] = {
+		{CURVE_PAINT_PLANE_NORMAL_VIEW,  "NORMAL_VIEW", 0, "Normal/View", "Draw perpendicular to the surface"},
+		{CURVE_PAINT_PLANE_NORMAL_SURFACE, "NORMAL_SURFACE", 0, "Normal/Surfave", "Draw aligned to the surface"},
+		{CURVE_PAINT_PLANE_VIEW, "VIEW", 0, "View", "Draw aligned to the viewport"},
+		{0, NULL, 0, NULL, NULL}};
+
+	prop = RNA_def_property(srna, "depth_plane", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "depth_plane");
+	RNA_def_property_enum_items(prop, depth_plane_items);
+	RNA_def_property_ui_text(prop, "Plane", "Plane for projected stroke");
 }
 
 static void rna_def_statvis(BlenderRNA  *brna)




More information about the Bf-blender-cvs mailing list