2.5/Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Thu, 20 Aug 2009 05:13:07 +0000 (05:13 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Thu, 20 Aug 2009 05:13:07 +0000 (05:13 +0000)
* Converted vertex paint to use the new stroke system. Now supports the same smooth stroke and stroke spacing as sculpt mode.
* Refactored the paint cursor a bit, just sculpt for now but other modes soon.
* A couple warning fixes

15 files changed:
release/ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/paint.c
source/blender/editors/object/object_edit.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/gpu/GPU_draw.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_operators.c

index 1b4c1e25c3469158d2c6de9a5d1908391f04874d..5d882866e96e0ae66c5f589120f165da27b5526a 100644 (file)
@@ -429,7 +429,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel):
 
        def poll(self, context):
                settings = self.paint_settings(context)
-               return (settings and settings.brush and context.sculpt_object)
+               return (settings and settings.brush and (context.sculpt_object or context.vertex_paint_object))
 
        def draw(self, context):
                settings = self.paint_settings(context)
index 67b260b234829df3686371c94960afdd531a76b1..45d2e24c7f6f9ff08c85ffa42911a35d1515ece8 100644 (file)
@@ -33,7 +33,7 @@ struct Object;
 struct Paint;
 struct Scene;
 
-void paint_init(struct Paint *p, const char *brush_name);
+void paint_init(struct Paint *p, const char *col);
 void free_paint(struct Paint *p);
 void copy_paint(struct Paint *orig, struct Paint *new);
 
index 80016f23d7c5525ef0e985a7bab023995095a4c3..f0893e058faaa1421fe00a5c1e3bd933f01e3666 100644 (file)
@@ -154,14 +154,23 @@ int paint_facesel_test(Object *ob)
 
 }
 
-void paint_init(Paint *p, const char *name)
+void paint_init(Paint *p, const char *col)
 {
        Brush *brush;
 
        /* If there's no brush, create one */
        brush = paint_brush(p);
-       brush_check_exists(&brush, name);
+       brush_check_exists(&brush, "Brush");
        paint_brush_set(p, brush);
+
+       if(col)
+               memcpy(p->paint_cursor_col, col, 3);
+       else {
+               p->paint_cursor_col[0] = 255;
+               p->paint_cursor_col[1] = 255;
+               p->paint_cursor_col[2] = 255;
+       }
+       p->paint_cursor_col[3] = 128;
 }
 
 void free_paint(Paint *paint)
index f8d969d2462a504d5f6f0c8f085c3b709a30ad47..39fd64335481f210f48b3776bf163717ba5f2a28 100644 (file)
@@ -7073,6 +7073,25 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, in
        return item;
 }
 
+static const char *object_mode_op_string(int mode)
+{
+       if(mode == OB_MODE_EDIT)
+               return "OBJECT_OT_editmode_toggle";
+       if(mode == OB_MODE_SCULPT)
+               return "SCULPT_OT_sculptmode_toggle";
+       if(mode == OB_MODE_VERTEX_PAINT)
+               return "PAINT_OT_vertex_paint_toggle";
+       if(mode == OB_MODE_WEIGHT_PAINT)
+               return "PAINT_OT_weight_paint_toggle";
+       if(mode == OB_MODE_TEXTURE_PAINT)
+               return "PAINT_OT_texture_paint_toggle";
+       if(mode == OB_MODE_PARTICLE_EDIT)
+               return "PARTICLE_OT_particle_edit_toggle";
+       if(mode == OB_MODE_POSE)
+               return "OBJECT_OT_posemode_toggle";
+       return NULL;
+}
+
 static int object_mode_set_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_active_object(C);
@@ -7081,20 +7100,13 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
        if(!ob)
                return OPERATOR_CANCELLED;
 
-       if((mode == OB_MODE_EDIT) == !(ob->mode & OB_MODE_EDIT))
-               WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_SCULPT) == !(ob->mode & OB_MODE_SCULPT))
-               WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_VERTEX_PAINT) == !(ob->mode & OB_MODE_VERTEX_PAINT))
-               WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_WEIGHT_PAINT) == !(ob->mode & OB_MODE_WEIGHT_PAINT))
-               WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_TEXTURE_PAINT) == !(ob->mode & OB_MODE_TEXTURE_PAINT))
-               WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_PARTICLE_EDIT) == !(ob->mode & OB_MODE_PARTICLE_EDIT))
-               WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if((mode == OB_MODE_POSE) == !(ob->mode & OB_MODE_POSE))
-               WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+       /* Exit off current mode */
+       if(ob->mode != OB_MODE_OBJECT)
+               WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL);
+
+       /* Enter new mode */
+       if(mode != OB_MODE_OBJECT)
+               WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL);
 
        return OPERATOR_FINISHED;
 }
index 465aa281e252df35a0705ba0850d6f5177cf77f3..8a8041abbffe1cbf4a3914dfb3fe7647df433426 100644 (file)
@@ -5174,7 +5174,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
                        me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
                                                         NULL, me->totface);
 
-               paint_init(&scene->toolsettings->imapaint.paint, "Brush");
+               paint_init(&scene->toolsettings->imapaint.paint, NULL);
 
                if(U.glreslimit != 0)
                        GPU_free_images();
index 41764a70686f4743174fdacf10da0821e97ea844..c6c93026c44e253bd402b782a5237ec24c7da8c1 100644 (file)
@@ -50,6 +50,10 @@ struct PaintStroke *paint_stroke_new(bContext *C, StrokeTestStart test_start,
                                     StrokeUpdateStep update_step, StrokeDone done);
 int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
 struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
+void *paint_stroke_mode_data(struct PaintStroke *stroke);
+void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
+int paint_poll(bContext *C);
+void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
 
 /* paint_vertex.c */
 void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
index 63a6591d0576b96b934b8a0e55c965446d37fff9..1ea612c0aa5de2d4e2be71660c6c20727b274bc4 100644 (file)
@@ -77,12 +77,6 @@ void BRUSH_OT_add(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for.");
 }
 
-/* Paint operators */
-static int paint_poll(bContext *C)
-{
-       return !!paint_get_active(CTX_data_scene(C));
-}
-
 /**************************** registration **********************************/
 
 void ED_operatortypes_paint(void)
index 634b82674b5272612ea756d50016bf16e9d90271..1167e011c865361b9aabb9345f8317e818be24d6 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "BLI_arithb.h"
 
+#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "ED_screen.h"
@@ -54,6 +55,9 @@
 #include <math.h>
 
 typedef struct PaintStroke {
+       void *mode_data;
+       void *smooth_stroke_cursor;
+
        /* Cached values */
        ViewContext vc;
        bglMats mats;
@@ -71,6 +75,42 @@ typedef struct PaintStroke {
        StrokeDone done;
 } PaintStroke;
 
+/*** Cursor ***/
+static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata) 
+{
+       Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C)));
+       PaintStroke *stroke = customdata;
+
+       glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
+       glEnable(GL_LINE_SMOOTH);
+       glEnable(GL_BLEND);
+
+       if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
+               ARegion *ar = CTX_wm_region(C);
+               sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin,
+                         (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
+       }
+
+       glDisable(GL_BLEND);
+       glDisable(GL_LINE_SMOOTH);
+}
+
+static void paint_draw_cursor(bContext *C, int x, int y, void *customdata)
+{
+       Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C)));
+
+       glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
+       glEnable(GL_LINE_SMOOTH);
+       glEnable(GL_BLEND);
+
+       glTranslatef((float)x, (float)y, 0.0f);
+       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
+       glTranslatef((float)-x, (float)-y, 0.0f);
+
+       glDisable(GL_BLEND);
+       glDisable(GL_LINE_SMOOTH);
+}
+
 /* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
 static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2])
 {
@@ -191,6 +231,11 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
                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)
+                       stroke->smooth_stroke_cursor =
+                               WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
+
                ED_region_tag_redraw(ar);
        }
 
@@ -209,6 +254,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
 
        /* TODO: fix hardcoded event here */
        if(event->type == LEFTMOUSE && event->val == 0) {
+               if(stroke->smooth_stroke_cursor)
+                       WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor);
+
                stroke->done(C, stroke);
                MEM_freeN(stroke);
                return OPERATOR_FINISHED;
@@ -222,3 +270,31 @@ ViewContext *paint_stroke_view_context(PaintStroke *stroke)
        return &stroke->vc;
 }
 
+void *paint_stroke_mode_data(struct PaintStroke *stroke)
+{
+       return stroke->mode_data;
+}
+
+void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data)
+{
+       stroke->mode_data = mode_data;
+}
+
+int paint_poll(bContext *C)
+{
+       Paint *p = paint_get_active(CTX_data_scene(C));
+       Object *ob = CTX_data_active_object(C);
+
+       return p && ob && paint_brush(p) &&
+               CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
+               CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
+}
+
+void paint_cursor_start(bContext *C, int (*poll)(bContext *C))
+{
+       Paint *p = paint_get_active(CTX_data_scene(C));
+
+       if(p && !p->paint_cursor)
+               p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
+}
+
index 05faa47e0f4be559c61c129e6c437bddcc814ef6..19f0293c1b893ab71c5074dbce51076c51be97eb 100644 (file)
@@ -62,6 +62,7 @@
 #include "DNA_userdef_types.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
 
 #include "BKE_armature.h"
 #include "BKE_brush.h"
@@ -91,6 +92,8 @@
 #include "ED_util.h"
 #include "ED_view3d.h"
 
+#include "paint_intern.h"
+
        /* vp->mode */
 #define VP_MIX 0
 #define VP_ADD 1
@@ -807,7 +810,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
        return tot;
 }
 
-static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, short *mval)
+static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval)
 {
        Brush *brush = paint_brush(&vp->paint);
        float fac, dx, dy;
@@ -1124,7 +1127,7 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                if(wp==NULL)
                        wp= scene->toolsettings->wpaint= new_vpaint(1);
 
-               paint_init(&wp->paint, "Brush");
+               paint_init(&wp->paint, NULL);
 
                toggle_paint_cursor(C, 1);
                
@@ -1329,7 +1332,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        float paintweight= ts->vgroup_weight;
                        int *indexar= wpd->indexar;
                        int totindex, index, alpha, totw;
-                       short mval[2];
+                       float mval[2];
                        
                        view3d_operator_needs_opengl(C);
                        
@@ -1634,7 +1637,7 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
                
                toggle_paint_cursor(C, 0);
 
-               paint_init(&vp->paint, "Brush");
+               paint_init(&vp->paint, NULL);
        }
        
        if (me)
@@ -1693,25 +1696,47 @@ struct VPaintData {
        float vpimat[3][3];
 };
 
-static void vpaint_exit(bContext *C, wmOperator *op)
+static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event)
 {
        ToolSettings *ts= CTX_data_tool_settings(C);
-       struct VPaintData *vpd= op->customdata;
+       struct PaintStroke *stroke = op->customdata;
+       VPaint *vp= ts->vpaint;
+       struct VPaintData *vpd;
+       Object *ob= CTX_data_active_object(C);
+       Mesh *me;
+       float mat[4][4], imat[4][4];
+
+       /* context checks could be a poll() */
+       me= get_mesh(ob);
+       if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH;
        
-       if(vpd->vertexcosnos)
-               MEM_freeN(vpd->vertexcosnos);
-       MEM_freeN(vpd->indexar);
+       if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0);
+       if(me->mcol==NULL) return OPERATOR_CANCELLED;
        
-       /* frees prev buffer */
-       copy_vpaint_prev(ts->vpaint, NULL, 0);
+       /* make mode data storage */
+       vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData");
+       paint_stroke_set_mode_data(stroke, vpd);
+       view3d_set_viewcontext(C, &vpd->vc);
        
-       MEM_freeN(vpd);
-       op->customdata= NULL;
+       vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob);
+       vpd->indexar= get_indexarray();
+       vpd->paintcol= vpaint_get_current_col(vp);
+       
+       /* for filtering */
+       copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface);
+       
+       /* some old cruft to sort out later */
+       Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat);
+       Mat4Invert(imat, mat);
+       Mat3CpyMat4(vpd->vpimat, imat);
+
+       return 1;
 }
 
-static void vpaint_dot(bContext *C, struct VPaintData *vpd, wmEvent *event)
+static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 {
        ToolSettings *ts= CTX_data_tool_settings(C);
+       struct VPaintData *vpd = paint_stroke_mode_data(stroke);
        VPaint *vp= ts->vpaint;
        Brush *brush = paint_brush(&vp->paint);
        ViewContext *vc= &vpd->vc;
@@ -1720,7 +1745,9 @@ static void vpaint_dot(bContext *C, struct VPaintData *vpd, wmEvent *event)
        float mat[4][4];
        int *indexar= vpd->indexar;
        int totindex, index;
-       short mval[2];
+       float mval[2];
+
+       RNA_float_get_array(itemptr, "mouse", mval);
                        
        view3d_operator_needs_opengl(C);
                        
@@ -1728,10 +1755,11 @@ static void vpaint_dot(bContext *C, struct VPaintData *vpd, wmEvent *event)
        wmMultMatrix(ob->obmat);
        wmGetSingleMatrix(mat);
        wmLoadMatrix(vc->rv3d->viewmat);
+
+       mval[0]-= vc->ar->winrct.xmin;
+       mval[1]-= vc->ar->winrct.ymin;
+
                        
-       mval[0]= event->x - vc->ar->winrct.xmin;
-       mval[1]= event->y - vc->ar->winrct.ymin;
-                               
        /* which faces are involved */
        if(vp->flag & VP_AREA) {
                totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size);
@@ -1811,58 +1839,27 @@ static void vpaint_dot(bContext *C, struct VPaintData *vpd, wmEvent *event)
        DAG_object_flush_update(vc->scene, ob, OB_RECALC_DATA);
 }
 
-static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
+static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke)
 {
-       switch(event->type) {
-       case LEFTMOUSE:
-               if(event->val==0) { /* release */
-                       vpaint_exit(C, op);
-                       return OPERATOR_FINISHED;
-               }
-               /* pass on, first press gets painted too */
-               
-       case MOUSEMOVE: 
-               vpaint_dot(C, op->customdata, event);
-               break;
-       }       
+       ToolSettings *ts= CTX_data_tool_settings(C);
+       struct VPaintData *vpd= paint_stroke_mode_data(stroke);
        
-       return OPERATOR_RUNNING_MODAL;
+       if(vpd->vertexcosnos)
+               MEM_freeN(vpd->vertexcosnos);
+       MEM_freeN(vpd->indexar);
+       
+       /* frees prev buffer */
+       copy_vpaint_prev(ts->vpaint, NULL, 0);
+       
+       MEM_freeN(vpd);
 }
 
 static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       ToolSettings *ts= CTX_data_tool_settings(C);
-       VPaint *vp= ts->vpaint;
-       struct VPaintData *vpd;
-       Object *ob= CTX_data_active_object(C);
-       Mesh *me;
-       float mat[4][4], imat[4][4];
-       
-       /* context checks could be a poll() */
-       me= get_mesh(ob);
-       if(me==NULL || me->totface==0) return OPERATOR_PASS_THROUGH;
        
-       if(me->mcol==NULL) make_vertexcol(CTX_data_scene(C), 0);
-       if(me->mcol==NULL) return OPERATOR_CANCELLED;
-       
-       /* make customdata storage */
-       op->customdata= vpd= MEM_callocN(sizeof(struct VPaintData), "VPaintData");
-       view3d_set_viewcontext(C, &vpd->vc);
-       
-       vpd->vertexcosnos= mesh_get_mapped_verts_nors(vpd->vc.scene, ob);
-       vpd->indexar= get_indexarray();
-       vpd->paintcol= vpaint_get_current_col(vp);
-       
-       /* for filtering */
-       copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface);
-       
-       /* some old cruft to sort out later */
-       Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat);
-       Mat4Invert(imat, mat);
-       Mat3CpyMat4(vpd->vpimat, imat);
-       
-       /* do paint once for click only paint */
-       vpaint_modal(C, op, event);
+       op->customdata = paint_stroke_new(C, vpaint_stroke_test_start,
+                                         vpaint_stroke_update_step,
+                                         vpaint_stroke_done);
        
        /* add modal handler */
        WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
@@ -1878,11 +1875,13 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke= vpaint_invoke;
-       ot->modal= vpaint_modal;
+       ot->modal= paint_stroke_modal;
        /* ot->exec= vpaint_exec; <-- needs stroke property */
        ot->poll= vp_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+
+       RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
 }
 
index c01004f5b7edfb0ee880362a2c857955951a9313..94703dbe4ff681864de62edd4acdc919a36a7591 100644 (file)
@@ -1042,47 +1042,7 @@ static int sculpt_mode_poll(bContext *C)
 
 static int sculpt_poll(bContext *C)
 {
-       return sculpt_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->sculpt->paint) &&
-               CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
-               CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
-}
-
-/*** Sculpt Cursor ***/
-static void draw_paint_cursor(bContext *C, int x, int y, void *customdata)
-{
-       Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
-       SculptSession *ss= CTX_data_active_object(C)->sculpt;
-       Brush *brush = paint_brush(&sd->paint);
-       
-       glColor4ub(255, 100, 100, 128);
-       glEnable( GL_LINE_SMOOTH );
-       glEnable(GL_BLEND);
-
-       glTranslatef((float)x, (float)y, 0.0f);
-       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
-       glTranslatef((float)-x, (float)-y, 0.0f);
-
-       if(ss && ss->cache && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
-               ARegion *ar = CTX_wm_region(C);
-               sdrawline(x, y, (int)ss->cache->mouse[0] - ar->winrct.xmin, (int)ss->cache->mouse[1] - ar->winrct.ymin);
-       }
-
-       glDisable(GL_BLEND);
-       glDisable( GL_LINE_SMOOTH );
-}
-
-static void toggle_paint_cursor(bContext *C)
-{
-       Sculpt *s = CTX_data_scene(C)->toolsettings->sculpt;
-
-       if(s->cursor) {
-               WM_paint_cursor_end(CTX_wm_manager(C), s->cursor);
-               s->cursor = NULL;
-       }
-       else {
-               s->cursor =
-                       WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_poll, draw_paint_cursor, NULL);
-       }
+       return sculpt_mode_poll(C) && paint_poll(C);
 }
 
 static void sculpt_undo_push(bContext *C, Sculpt *sd)
@@ -1112,8 +1072,11 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd)
 /**** Radial control ****/
 static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
-       toggle_paint_cursor(C);
+       Paint *p = paint_get_active(CTX_data_scene(C));
+       Brush *brush = paint_brush(p);
+
+       WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
+       p->paint_cursor = NULL;
        brush_radial_control_invoke(op, brush, 1);
        return WM_radial_control_invoke(C, op, event);
 }
@@ -1122,7 +1085,7 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
 {
        int ret = WM_radial_control_modal(C, op, event);
        if(ret != OPERATOR_RUNNING_MODAL)
-               toggle_paint_cursor(C);
+               paint_cursor_start(C, sculpt_poll);
        return ret;
 }
 
@@ -1592,6 +1555,8 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                free_sculptsession(&ob->sculpt);
        }
        else {
+               const char col[3] = {255, 100, 100};
+               
                /* Enter sculptmode */
 
                ob->mode |= OB_MODE_SCULPT;
@@ -1605,10 +1570,9 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                        free_sculptsession(&ob->sculpt);
                ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
 
-               if(!ts->sculpt->cursor)
-                       toggle_paint_cursor(C);
-
-               paint_init(&ts->sculpt->paint, "Brush");
+               paint_init(&ts->sculpt->paint, col);
+               
+               paint_cursor_start(C, sculpt_poll);
 
                WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
        }
index 1c6b8399422673b92e2d4f6e1074c0e88ead4a7a..00d0e3131e561523dae12e90cdeb8f2d276eda30 100644 (file)
@@ -43,6 +43,7 @@ struct Object;
 struct Scene;
 struct View3D;
 struct RegionView3D;
+struct SmokeModifierData;
 
 /* OpenGL drawing functions related to shading. These are also
  * shared with the game engine, where there were previously
index f1a77d78b7b1ec9dca783dbb2ff77cec35b1a95b..9161157f5977d395d481fbf5fc3342dc2f795b89 100644 (file)
@@ -455,8 +455,11 @@ typedef struct Paint {
        Brush **brushes;
        int active_brush_index, brush_count;
        
-       /* WM handle */
+       /* WM Paint cursor */
        void *paint_cursor;
+       unsigned char paint_cursor_col[4];
+
+       int pad;
 } Paint;
 
 typedef struct ImagePaintSettings {
@@ -498,9 +501,6 @@ typedef struct TransformOrientation {
 
 typedef struct Sculpt {
        Paint paint;
-       
-       /* WM handle */
-       void *cursor;
 
        /* For rotating around a pivot point */
        float pivot[3];
index be0707390c473e9538e03c89f15efc7bcf419d0d..fb71b2976838f70896e9e0f263593964793909b0 100644 (file)
@@ -151,7 +151,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr)
        Scene *scene= CTX_data_scene(C);
 
        if(scene)
-               paint_init(&scene->toolsettings->imapaint.paint, "Brush");
+               paint_init(&scene->toolsettings->imapaint.paint, NULL);
 }
 
 static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)
index b717df8f61fe4e9888e5d03cf4138a6329b23348..c400b6c9b203ca2b5e1cda642e3a64e21b5a10f3 100644 (file)
@@ -287,6 +287,11 @@ typedef struct wmTimer {
 } wmTimer;
 
 
+/* **************** Paint Cursor ******************* */
+
+typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata);
+
+
 /* ****************** Messages ********************* */
 
 enum {
index 2e813bac37d6b12568df4d9cc6f09376dd909769..304da25017b21892aaca54a930d38d211676232b 100644 (file)
@@ -1067,7 +1067,7 @@ static void WM_OT_exit_blender(wmOperatorType *ot)
 */
 
 void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C),
-                              void (*draw)(bContext *C, int, int, void *customdata), void *customdata)
+                              wmPaintCursorDraw draw, void *customdata)
 {
        wmPaintCursor *pc= MEM_callocN(sizeof(wmPaintCursor), "paint cursor");