[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58814] branches/soc-2013-paint/source/ blender: Polyline becomes a separate stroke mode.

Antony Riakiotakis kalast at gmail.com
Fri Aug 2 02:25:49 CEST 2013


Revision: 58814
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58814
Author:   psy-fi
Date:     2013-08-02 00:25:49 +0000 (Fri, 02 Aug 2013)
Log Message:
-----------
Polyline becomes a separate stroke mode. Rationale for this is that
artists like the quick drag and release for quick lines and requiring
the user to keep the shift key pressed for new line segments would be
cumbersome and inconsistent because it would mean that first line
additionis done on release and subsequent get added on key press.

So, lines now use a drag-release paradigm and polylines use regular
clicking. To confirm, use space or enter like on any operator. Polyline
bit was used for fixed textures on earlier blender versions, meaning
that I'll have to make sure that flag is not used anymore. I will do a
commit for this on trunk.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c	2013-08-02 00:24:34 UTC (rev 58813)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c	2013-08-02 00:25:49 UTC (rev 58814)
@@ -661,9 +661,7 @@
 bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
 {
 	if (!(br->flag & BRUSH_SMOOTH_STROKE) ||
-	     (br->flag & BRUSH_ANCHORED) ||
-	     (br->flag & BRUSH_DRAG_DOT) ||
-	     (br->flag & BRUSH_LINE))
+		 (br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE | BRUSH_POLYLINE)))
 	{
 		return false;
 	}
@@ -764,6 +762,22 @@
 	/*printf("avg=(%f, %f), num=%d\n", average->mouse[0], average->mouse[1], stroke->num_samples);*/
 }
 
+static void paint_stroke_polyline_end(bContext *C, wmOperator *op, PaintStroke *stroke)
+{
+	Brush *br = stroke->brush;
+	if (stroke->stroke_started && (br->flag & (BRUSH_LINE | BRUSH_POLYLINE))) {
+		LinePoint *p = stroke->line.first;
+
+		stroke->ups->overlap_factor = paint_stroke_integrate_overlap(br, br->spacing);
+
+		paint_brush_stroke_add_step(C, op, p->pos, 1.0);
+
+		for (; p; p = p->next) {
+			paint_space_stroke(C, op, p->pos, 1.0);
+		}
+	}
+}
+
 int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	Paint *p = BKE_paint_get_active_from_context(C);
@@ -778,7 +792,7 @@
 	float pressure;
 
 	/* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */
-	pressure = (br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0 : event_tablet_data(event, &stroke->pen_flip);
+	pressure = (br->flag & (BRUSH_LINE | BRUSH_POLYLINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0 : event_tablet_data(event, &stroke->pen_flip);
 
 	paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
 	paint_stroke_sample_average(stroke, &sample_average);
@@ -811,7 +825,7 @@
 			if (br->flag & BRUSH_AIRBRUSH)
 				stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate);
 
-			if (br->flag & BRUSH_LINE) {
+			if (br->flag & (BRUSH_LINE | BRUSH_POLYLINE)) {
 				LinePoint *p = MEM_callocN(sizeof(*p), "line_stroke_point");
 				stroke->stroke_cursor =
 					WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_line_cursor, stroke);
@@ -835,43 +849,28 @@
 	}
 
 	if (event->type == stroke->event_type && !first_modal) {
-		if (br->flag & BRUSH_LINE) {
-			if (event->val == KM_PRESS) {
-				if (!stroke->stroke_started) {
-					stroke_done(C, op);
-					return OPERATOR_FINISHED;
-				}
-
-				if (event->shift) {
-					/* Add new line here */
-					LinePoint *p = MEM_callocN(sizeof(*p), "line_stroke_point");
-					BLI_addtail(&stroke->line, p);
-					copy_v2_v2(p->pos, sample_average.mouse);
-					/* for rake to work well */
-					copy_v2_v2(stroke->last_mouse_position, sample_average.mouse);
-				}
-				else {
-					LinePoint *p = stroke->line.first;
-
-					stroke->ups->overlap_factor = paint_stroke_integrate_overlap(br, br->spacing);
-
-					paint_brush_stroke_add_step(C, op, p->pos, 1.0);
-
-					for (; p; p = p->next) {
-						paint_space_stroke(C, op, p->pos, 1.0);
-					}
-
-					stroke_done(C, op);
-					return OPERATOR_FINISHED;
-				}
+		if (br->flag & BRUSH_POLYLINE) {
+			if (event->val == KM_PRESS && stroke->stroke_started) {
+				/* Add new line here */
+				LinePoint *p = MEM_callocN(sizeof(*p), "line_stroke_point");
+				BLI_addtail(&stroke->line, p);
+				copy_v2_v2(p->pos, sample_average.mouse);
+				/* for rake to work well */
+				copy_v2_v2(stroke->last_mouse_position, sample_average.mouse);
 			}
 		}
 		else if (event->val == KM_RELEASE) {
+			paint_stroke_polyline_end (C, op, stroke);
 			stroke_done(C, op);
 			return OPERATOR_FINISHED;
 		}
 	}
-	else if ((br->flag & BRUSH_LINE) && stroke->stroke_started &&
+	else if (ELEM(event->type, RETKEY, SPACEKEY)) {
+		paint_stroke_polyline_end (C, op, stroke);
+		stroke_done(C, op);
+		return OPERATOR_FINISHED;
+	}
+	else if ((br->flag & (BRUSH_LINE | BRUSH_POLYLINE)) && stroke->stroke_started &&
 			 (first_modal || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE))))
 	{
 		LinePoint *p = stroke->line.last;

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-08-02 00:24:34 UTC (rev 58813)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-08-02 00:25:49 UTC (rev 58814)
@@ -156,7 +156,7 @@
 	BRUSH_SIZE_PRESSURE = (1 << 3),
 	BRUSH_JITTER_PRESSURE = (1 << 4),
 	BRUSH_SPACING_PRESSURE = (1 << 5),
-	// BRUSH_FIXED_TEX = (1 << 6), /* obsolete, use mtex->brush_map_mode = MTEX_MAP_MODE_TILED instead */
+	BRUSH_POLYLINE = (1 << 6),
 	BRUSH_RAKE = (1 << 7),
 	BRUSH_ANCHORED = (1 << 8),
 	BRUSH_DIR_IN = (1 << 9),

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c	2013-08-02 00:24:34 UTC (rev 58813)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c	2013-08-02 00:25:49 UTC (rev 58814)
@@ -695,7 +695,8 @@
 		{BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
 		{BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"},
 		{BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
-		{BRUSH_LINE, "LINE", 0, "Line", "Draw a line with dabs separated according to spacing"},
+		{BRUSH_LINE, "LINE", 0, "Line", "Drag a line with dabs separated according to spacing"},
+		{BRUSH_POLYLINE, "POLYLINE", 0, "Polyline", "Draw a series of lines with dabs separated according to spacing"},
 		{0, NULL, 0, NULL, NULL}
 	};
 
@@ -704,6 +705,7 @@
 		{BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
 		{BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
 		{BRUSH_LINE, "LINE", 0, "Line", "Draw a line with dabs separated according to spacing"},
+		{BRUSH_POLYLINE, "POLYLINE", 0, "Polyline", "Draw a series of lines with dabs separated according to spacing"},
 		{0, NULL, 0, NULL, NULL}
 	};
 
@@ -984,7 +986,7 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
 	RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
-	
+
 	prop = RNA_def_property(srna, "use_original_normal", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ORIGINAL_NORMAL);
 	RNA_def_property_ui_text(prop, "Original Normal",




More information about the Bf-blender-cvs mailing list