diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-21 04:46:36 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-21 04:46:36 +0400 |
commit | 2881393fbb42cca81ee4d36895fc248a22c54823 (patch) | |
tree | 042981495d88ea60a5e05dc11ba979bcd6ae407b /source/blender/editors/sculpt_paint | |
parent | 23d9b6bcec742307498d927738c8837458a212c1 (diff) |
2.5 Paint:
* Added airbrush and airbrush rate options to paint stroke. Works for sculpt, vertex paint, and weight paint.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 17 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 715399af888..bd9ea50e0f8 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -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; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 704773795e8..bc2ac480657 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -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; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 76c5c3504da..adaba804799 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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; } |