2.5 Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Fri, 21 Aug 2009 00:46:36 +0000 (00:46 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Fri, 21 Aug 2009 00:46:36 +0000 (00:46 +0000)
* Added airbrush and airbrush rate options to paint stroke. Works for sculpt, vertex paint, and weight paint.

release/ui/space_view3d_toolbar.py
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c

index 5f42ff1d8b8cfba66aaa78801a54119e5fc17642..35df4dc8b54570065fa4d00583fe9000df49ffd7 100644 (file)
@@ -449,6 +449,11 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel):
                col.active = brush.space
                col.itemR(brush, "spacing", text="Distance", slider=True)
 
+               layout.itemR(brush, "airbrush")
+               col = layout.column()
+               col.active = brush.airbrush
+               col.itemR(brush, "rate", slider=True)
+
 
 class VIEW3D_PT_tools_brush_curve(PaintPanel):
        __label__ = "Curve"
index 715399af88805f4151d4ead5dc8efba3505ccb81..bd9ea50e0f8a3fd221b7a92a94fd45c5f6759334 100644 (file)
@@ -43,6 +43,8 @@
 
 #include "BLI_arithb.h"
 
+#include "PIL_time.h"
+
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
@@ -57,6 +59,7 @@
 typedef struct PaintStroke {
        void *mode_data;
        void *smooth_stroke_cursor;
+       wmTimer *timer;
 
        /* Cached values */
        ViewContext vc;
@@ -227,15 +230,22 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
        PaintStroke *stroke = op->customdata;
        float mouse[2];
 
+       if(event->type == TIMER && (event->customdata != stroke->timer))
+               return OPERATOR_RUNNING_MODAL;
+
        if(!stroke->stroke_started) {
                stroke->last_mouse_position[0] = event->x;
                stroke->last_mouse_position[1] = event->y;
                stroke->stroke_started = stroke->test_start(C, op, event);
 
-               if(stroke->stroke_started)
+               if(stroke->stroke_started) {
                        stroke->smooth_stroke_cursor =
                                WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
 
+                       if(stroke->brush->flag & BRUSH_AIRBRUSH)
+                               stroke->timer = WM_event_add_window_timer(CTX_wm_window(C), TIMER, stroke->brush->rate);
+               }
+
                ED_region_tag_redraw(ar);
        }
 
@@ -254,9 +264,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
 
        /* TODO: fix hardcoded event here */
        if(event->type == LEFTMOUSE && event->val == 0) {
+               /* Exit stroke, free data */
+
                if(stroke->smooth_stroke_cursor)
                        WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor);
 
+               if(stroke->timer)
+                       WM_event_remove_window_timer(CTX_wm_window(C), stroke->timer);
+
                stroke->done(C, stroke);
                MEM_freeN(stroke);
                return OPERATOR_FINISHED;
index 704773795e8c0e771685d0d168526fd52dfdd979..bc2ac480657998cba398352d08ddedeacd29164c 100644 (file)
@@ -1513,6 +1513,8 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        /* add modal handler */
        WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+
+       op->type->modal(C, op, event);
        
        return OPERATOR_RUNNING_MODAL;
 }
@@ -1803,6 +1805,8 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        /* add modal handler */
        WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+
+       op->type->modal(C, op, event);
        
        return OPERATOR_RUNNING_MODAL;
 }
index 76c5c3504da639fdd8dd5fa5055a717d282576c4..adaba8047991d62ecfc10f7b24635fe8940bb9d8 100644 (file)
@@ -1439,6 +1439,8 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
 
        /* add modal handler */
        WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+
+       op->type->modal(C, op, event);
        
        return OPERATOR_RUNNING_MODAL;
 }