[Bf-blender-cvs] [30ef478] temp-curve-draw: Draw radius at the correct size

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


Commit: 30ef478189aab619c44e3a7ef8b3fe6ce680d9c7
Author: Campbell Barton
Date:   Fri Apr 15 05:21:15 2016 +1000
Branches: temp-curve-draw
https://developer.blender.org/rB30ef478189aab619c44e3a7ef8b3fe6ce680d9c7

Draw radius at the correct size

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

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 8a0f96d..4af4cbe 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -591,7 +591,7 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
             col.prop(cps, "use_stroke_endpoints")
             if cps.use_stroke_endpoints:
                 colsub = layout.column(align=True)
-                colsub.prop(cps, "depth_plane", expand=True)
+                colsub.prop(cps, "surface_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 e5783cf..24093f4 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -118,6 +118,9 @@ struct CurveDrawData {
 		bool use_substeps;
 	} sample;
 
+	struct {
+		float min, max, range;
+	} radius;
 
 	struct {
 		float mouse[2];
@@ -241,7 +244,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, (selem->pressure * cu->ext2), 16, 12);
+			const float radius = ((selem->pressure * cdd->radius.range) + cdd->radius.min) * cu->ext2;
+			gluSphere(qobj, radius, 16, 12);
 
 			location_prev = selem->location_local;
 		}
@@ -665,7 +669,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
 				copy_v3_v3(bezt->vec[2], handle_r);
 
 				if (use_pressure_radius) {
-					bezt->radius = (pt[3] * radius_range) + radius_min;
+					bezt->radius = (pt[3] * cdd->radius.range) + cdd->radius.min;
 				}
 				else {
 					bezt->radius = radius_max;
@@ -794,6 +798,10 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
 	const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
 
+	cdd->radius.min = cps->radius_min;
+	cdd->radius.max = cps->radius_max;
+	cdd->radius.range = cps->radius_max - cps->radius_min;
+
 	/* fallback (incase we can't find the depth on first test) */
 	{
 		const float mval_fl[2] = {UNPACK2(event->mval)};
@@ -809,7 +817,6 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 	cdd->draw_handle_view = ED_region_draw_cb_activate(
 	        cdd->vc.ar->type, curve_draw_stroke_3d, op, REGION_DRAW_POST_VIEW);
 
-
 	{
 		View3D *v3d = cdd->vc.v3d;
 		RegionView3D *rv3d = cdd->vc.rv3d;
@@ -870,19 +877,21 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		cdd->project.use_plane = true;
 
 		float normal[3] = {0.0f};
-		if (ELEM(cps->depth_plane, CURVE_PAINT_PLANE_NORMAL_VIEW, CURVE_PAINT_PLANE_NORMAL_SURFACE)) {
+		if (ELEM(cps->surface_plane,
+		         CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW,
+		         CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE))
+		{
 			if (depth_read_normal(&cdd->vc, &cdd->mats, event->mval, normal)) {
-				if (cps->depth_plane == CURVE_PAINT_PLANE_NORMAL_VIEW) {
+				if (cps->surface_plane == CURVE_PAINT_SURFACE_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);
 				}
-
 			}
 		}
 
-		/* CURVE_PAINT_PLANE_VIEW or fallback */
+		/* CURVE_PAINT_SURFACE_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 d8b7234..06ccaa9 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1270,7 +1270,7 @@ typedef enum {
 typedef struct CurvePaintSettings {
 	char flag;
 	char depth_mode;
-	char depth_plane;
+	char surface_plane;
 	char _pad[5];
 	int error_threshold;
 	float radius_min, radius_max;
@@ -1289,9 +1289,9 @@ enum {
 };
 
 enum {
-	CURVE_PAINT_PLANE_NORMAL_VIEW		= 0,
-	CURVE_PAINT_PLANE_NORMAL_SURFACE	= 1,
-	CURVE_PAINT_PLANE_VIEW				= 2,
+	CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW		= 0,
+	CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE	= 1,
+	CURVE_PAINT_SURFACE_PLANE_VIEW				= 2,
 };
 
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index b880580..c233356 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2639,13 +2639,13 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	RNA_def_property_ui_text(prop, "Corner Angle", "Angles above this are considered corners");
 
 	prop = RNA_def_property(srna, "radius_min", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_range(prop, 0.0, 1000.0);
-	RNA_def_property_ui_range(prop, 0.0f, 10.0, 0.001, 2);
+	RNA_def_property_range(prop, 0.0, 100.0);
+	RNA_def_property_ui_range(prop, 0.0f, 10.0, 0.1, 2);
 	RNA_def_property_ui_text(prop, "Radius Min", "");
 
 	prop = RNA_def_property(srna, "radius_max", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0, 10.0);
-	RNA_def_property_ui_range(prop, 0.0f, 10.0, 0.001, 1);
+	RNA_def_property_ui_range(prop, 0.0f, 10.0, 0.1, 2);
 	RNA_def_property_ui_text(prop, "Radius Max", "");
 
 	static EnumPropertyItem depth_mode_items[] = {
@@ -2658,15 +2658,15 @@ static void rna_def_curve_paint_settings(BlenderRNA  *brna)
 	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"},
+	static EnumPropertyItem surface_plane_items[] = {
+		{CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW,  "NORMAL_VIEW", 0, "Normal/View", "Draw perpendicular to the surface"},
+		{CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE, "NORMAL_SURFACE", 0, "Normal/Surface", "Draw aligned to the surface"},
+		{CURVE_PAINT_SURFACE_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);
+	prop = RNA_def_property(srna, "surface_plane", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "surface_plane");
+	RNA_def_property_enum_items(prop, surface_plane_items);
 	RNA_def_property_ui_text(prop, "Plane", "Plane for projected stroke");
 }




More information about the Bf-blender-cvs mailing list