[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59066] branches/soc-2013-paint/source/ blender/editors/sculpt_paint/paint_stroke.c: Polyline strokes could have dabs not belonging to the lines due to the

Antony Riakiotakis kalast at gmail.com
Sun Aug 11 12:35:34 CEST 2013


Revision: 59066
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59066
Author:   psy-fi
Date:     2013-08-11 10:35:34 +0000 (Sun, 11 Aug 2013)
Log Message:
-----------
Polyline strokes could have dabs not belonging to the lines due to the
way dab interpolation for space strokes worked. This commit includes an
simpler implementation based on the initial space stroke code that
corrects this issue.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.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-11 10:35:30 UTC (rev 59065)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c	2013-08-11 10:35:34 UTC (rev 59066)
@@ -800,7 +800,10 @@
 {
 	Brush *br = stroke->brush;
 	if (stroke->stroke_started && (br->flag & (BRUSH_LINE | BRUSH_POLYLINE))) {
+		const Scene *scene = CTX_data_scene(C);
+		const float spacing = paint_space_stroke_spacing(scene, stroke, 1.0f, 1.0f);
 		LinePoint *p = stroke->line.first;
+		float length_residue = 0.0f;
 
 		/* last line point in polyline is dangling so remove */
 		if (br->flag & BRUSH_POLYLINE) {
@@ -815,7 +818,39 @@
 			paint_brush_stroke_add_step(C, op, p->pos, 1.0);
 
 		for (p = p->next; p; p = p->next) {
-			paint_space_stroke(C, op, p->pos, 1.0);
+			UnifiedPaintSettings *ups = stroke->ups;
+
+			float mouse[2], dmouse[2];
+			float length;
+
+			sub_v2_v2v2(dmouse, p->pos, p->prev->pos);
+			copy_v2_v2(stroke->last_mouse_position, p->prev->pos);
+
+			length = normalize_v2(dmouse) + length_residue;
+
+			while (length > 0.0f) {
+				float spacing_final = spacing - length_residue;
+				length_residue = 0.0;
+
+				if (length >= spacing) {
+					mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
+					mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
+
+					ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, spacing/stroke->zoom_2d);
+
+					stroke->stroke_distance += spacing / stroke->zoom_2d;
+					paint_brush_stroke_add_step(C, op, mouse, 1.0);
+
+					length -= spacing;
+					spacing_final = spacing;
+				}
+				else {
+					break;
+				}
+			}
+
+			/* length residue helps to correctly */
+			length_residue = length;
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list