Bugfix, own testing
authorTon Roosendaal <ton@blender.org>
Tue, 11 Jan 2011 12:36:49 +0000 (12:36 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 11 Jan 2011 12:36:49 +0000 (12:36 +0000)
When pressure was zero, a sculpt brush was still being executed
with step amount divided by zero, and thus entering eternal loop.

Maybe tablet-specific this but I wonder how this never got reported...

source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/sculpt.c

index 125e570946b8265a26713482a16ded7ac8d0a9cb..15bb574448f3fb5e9edf8a02ebd190c564c366a6 100644 (file)
@@ -769,14 +769,18 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
                        float pressure;
 
                        pressure = event_tablet_data(event, NULL);
-                       scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
-                       mul_v2_fl(vec, scale);
+                       if(pressure > FLT_EPSILON) {
+                               scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+                               if(scale > FLT_EPSILON) {
+                                       mul_v2_fl(vec, scale);
 
-                       steps = (int)(1.0f / scale);
+                                       steps = (int)(1.0f / scale);
 
-                       for(i = 0; i < steps; ++i, ++cnt) {
-                               add_v2_v2(mouse, vec);
-                               paint_brush_stroke_add_step(C, op, event, mouse);
+                                       for(i = 0; i < steps; ++i, ++cnt) {
+                                               add_v2_v2(mouse, vec);
+                                               paint_brush_stroke_add_step(C, op, event, mouse);
+                                       }
+                               }
                        }
                }
        }
index 6429a70515b1ed513d8dc4dd2c14d7b6b1acf667..c0399fadb902aca412f162782f2e25456670fce1 100644 (file)
@@ -306,6 +306,7 @@ static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
 {
        test->radius_squared= ss->cache->radius_squared;
        copy_v3_v3(test->location, ss->cache->location);
+       test->dist= 0.0f;       /* just for initialize */
 }
 
 static int sculpt_brush_test(SculptBrushTest *test, float co[3])