[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22666] branches/blender2.5/blender: 2. 5 Paint:

Nicholas Bishop nicholasbishop at gmail.com
Fri Aug 21 02:46:37 CEST 2009


Revision: 22666
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22666
Author:   nicholasbishop
Date:     2009-08-21 02:46:36 +0200 (Fri, 21 Aug 2009)

Log Message:
-----------
2.5 Paint:

* Added airbrush and airbrush rate options to paint stroke. Works for sculpt, vertex paint, and weight paint.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d_toolbar.py	2009-08-20 21:09:48 UTC (rev 22665)
+++ branches/blender2.5/blender/release/ui/space_view3d_toolbar.py	2009-08-21 00:46:36 UTC (rev 22666)
@@ -449,7 +449,12 @@
 		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"
 	__default_closed__ = True

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2009-08-20 21:09:48 UTC (rev 22665)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2009-08-21 00:46:36 UTC (rev 22666)
@@ -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 @@
 	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 @@
 
 	/* 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;

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2009-08-20 21:09:48 UTC (rev 22665)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2009-08-21 00:46:36 UTC (rev 22666)
@@ -1513,6 +1513,8 @@
 	
 	/* 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 @@
 	
 	/* 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;
 }

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-20 21:09:48 UTC (rev 22665)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-21 00:46:36 UTC (rev 22666)
@@ -1439,6 +1439,8 @@
 
 	/* 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;
 }





More information about the Bf-blender-cvs mailing list