[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30971] branches/soc-2010-jwilkins/source/ blender/editors/sculpt_paint/paint_stroke.c: * Rewrote adaptive space code to try and find a bug.

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Aug 2 12:48:29 CEST 2010


Revision: 30971
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30971
Author:   jwilkins
Date:     2010-08-02 12:48:28 +0200 (Mon, 02 Aug 2010)

Log Message:
-----------
* Rewrote adaptive space code to try and find a bug.  Turns out the bug wasn't in adaptive space, it was an old bug associated with 'front-faces only'  Keeping the rewrite for now though.

Modified Paths:
--------------
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-08-02 08:58:04 UTC (rev 30970)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-08-02 10:48:28 UTC (rev 30971)
@@ -1606,8 +1606,9 @@
 		length= len_v2(vec);
 
 		if(length > FLT_EPSILON) {
-			float t;
 			float pressure = 1;
+			float dvec[2];
+			float mouse[2];
 
 			// XXX duplicate code
 			if(event->custom == EVT_DATA_TABLET) {
@@ -1621,28 +1622,45 @@
 			if (scale < FLT_EPSILON) // paranoia here: make sure scale is big enough have an effect when added
 				scale= FLT_EPSILON;
 
-			t= 0;
-			while (t < 1) {
-				float dvec[2];
-				float mouse[2];
-				float f;
-				float d;
+			if (stroke->brush->flag & BRUSH_ADAPTIVE_SPACE) {
+				float t= 0;
+				for(;;) {
+					float f;
+					float d;
 
-				mul_v2_v2fl(dvec, vec, t);
-				add_v2_v2v2(mouse, start_mouse, dvec);
+					f= stroke->brush->adaptive_space_factor;
+					CLAMP(f, 0.1f, 1); // make sure that adaptive strength never sets spacing to zero
 
-				paint_brush_stroke_add_step(C, op, event, mouse);
+					d= f*scale;
+					CLAMP(d, FLT_EPSILON, scale); // paranoia here: d has to be big enough to increment t
 
-				f= stroke->brush->adaptive_space_factor;
-				CLAMP(f, 0.1f, 1); // make sure that adaptive strength never sets spacing to zero
+					t += d;
 
-				d= f*scale;
-				CLAMP(d, FLT_EPSILON, scale); // paranoia here: d has to be big enough to increment t
+					if (t > 1) break;
 
-				t += d;
+					mul_v2_v2fl(dvec, vec, t);
+					add_v2_v2v2(mouse, start_mouse, dvec);
 
-				cnt++;
+					paint_brush_stroke_add_step(C, op, event, mouse);
+
+					cnt++;
+				}
 			}
+			else {
+				int i, steps;
+
+				steps = 1 / scale;
+
+				for (i= 0; i < steps; i++) {
+					mul_v2_v2fl(dvec, vec, (float)i/(float)steps);
+					add_v2_v2v2(mouse, start_mouse, dvec);
+
+					paint_brush_stroke_add_step(C, op, event, mouse);
+
+					cnt++;
+				}
+			}
+
 		}
 	}
 





More information about the Bf-blender-cvs mailing list