2.5 Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Thu, 20 Aug 2009 16:00:17 +0000 (16:00 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Thu, 20 Aug 2009 16:00:17 +0000 (16:00 +0000)
* Weight paint and vertex paint now use the same cursor setup as sculpt

source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/paint.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/makesrna/intern/rna_space.c

index 45d2e24c7f6f9ff08c85ffa42911a35d1515ece8..4337d2757763d06e49a752c641c5cd85e7584e5f 100644 (file)
@@ -33,7 +33,12 @@ struct Object;
 struct Paint;
 struct Scene;
 
-void paint_init(struct Paint *p, const char *col);
+extern const char PAINT_CURSOR_SCULPT[3];
+extern const char PAINT_CURSOR_VERTEX_PAINT[3];
+extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
+extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
+
+void paint_init(struct Paint *p, const char col[3]);
 void free_paint(struct Paint *p);
 void copy_paint(struct Paint *orig, struct Paint *new);
 
index f0893e058faaa1421fe00a5c1e3bd933f01e3666..7c5b2b82b4b7663b83390bcc4ed787ea3209bc41 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
+const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
+const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
+const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
+
 Paint *paint_get_active(Scene *sce)
 {
        if(sce && sce->basact && sce->basact->object) {
@@ -154,7 +159,7 @@ int paint_facesel_test(Object *ob)
 
 }
 
-void paint_init(Paint *p, const char *col)
+void paint_init(Paint *p, const char col[3])
 {
        Brush *brush;
 
@@ -163,13 +168,7 @@ void paint_init(Paint *p, const char *col)
        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;
-       }
+       memcpy(p->paint_cursor_col, col, 3);
        p->paint_cursor_col[3] = 128;
 }
 
index 0d8213b28d6871ba7f75cce85cc3698c2d80265f..704773795e8c0e771685d0d168526fd52dfdd979 100644 (file)
@@ -142,56 +142,6 @@ static int wp_poll(bContext *C)
        return 0;
 }
 
-
-/* Cursors */
-static void vp_drawcursor(bContext *C, int x, int y, void *customdata)
-{
-       Brush *brush = paint_brush(&CTX_data_tool_settings(C)->vpaint->paint);
-       
-       glTranslatef((float)x, (float)y, 0.0f);
-       
-       glColor4ub(255, 255, 255, 128);
-       glEnable( GL_LINE_SMOOTH );
-       glEnable(GL_BLEND);
-       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
-       glDisable(GL_BLEND);
-       glDisable( GL_LINE_SMOOTH );
-       
-       glTranslatef((float)-x, (float)-y, 0.0f);
-}
-
-static void wp_drawcursor(bContext *C, int x, int y, void *customdata)
-{
-       Brush *brush = paint_brush(&CTX_data_tool_settings(C)->wpaint->paint);
-
-       glTranslatef((float)x, (float)y, 0.0f);
-       
-       glColor4ub(200, 200, 255, 128);
-       glEnable( GL_LINE_SMOOTH );
-       glEnable(GL_BLEND);
-       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
-       glDisable(GL_BLEND);
-       glDisable( GL_LINE_SMOOTH );
-       
-       glTranslatef((float)-x, (float)-y, 0.0f);
-}
-
-static void toggle_paint_cursor(bContext *C, int wpaint)
-{
-       ToolSettings *ts = CTX_data_scene(C)->toolsettings;
-       VPaint *vp = wpaint ? ts->wpaint : ts->vpaint;
-
-       if(vp->paintcursor) {
-               WM_paint_cursor_end(CTX_wm_manager(C), vp->paintcursor);
-               vp->paintcursor = NULL;
-       }
-       else {
-               vp->paintcursor = wpaint ?
-                       WM_paint_cursor_activate(CTX_wm_manager(C), wp_poll, wp_drawcursor, NULL) :
-                       WM_paint_cursor_activate(CTX_wm_manager(C), vp_poll, vp_drawcursor, NULL);
-       }
-}
-
 static VPaint *new_vpaint(int wpaint)
 {
        VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint");
@@ -1127,9 +1077,8 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                if(wp==NULL)
                        wp= scene->toolsettings->wpaint= new_vpaint(1);
 
-               paint_init(&wp->paint, NULL);
-
-               toggle_paint_cursor(C, 1);
+               paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
+               paint_cursor_start(C, wp_poll);
                
                mesh_octree_table(ob, NULL, NULL, 's');
                
@@ -1145,9 +1094,6 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                }
        }
        else {
-               if(wp)
-                       toggle_paint_cursor(C, 1);
-               
                mesh_octree_table(ob, NULL, NULL, 'e');
        }
        
@@ -1188,9 +1134,11 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
 
 static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint);
-
-       toggle_paint_cursor(C, 0);
+       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);
 }
@@ -1199,7 +1147,7 @@ static int vpaint_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, 0);
+               paint_cursor_start(C, vp_poll);
        return ret;
 }
 
@@ -1211,8 +1159,11 @@ static int vpaint_radial_control_exec(bContext *C, wmOperator *op)
 
 static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint);
-       toggle_paint_cursor(C, 1);
+       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);
 }
@@ -1221,7 +1172,7 @@ static int wpaint_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, 1);
+               paint_cursor_start(C, wp_poll);
        return ret;
 }
 
@@ -1614,11 +1565,6 @@ static int set_vpaint(bContext *C, wmOperator *op)               /* toggle */
        if(ob->mode & OB_MODE_VERTEX_PAINT) {
                
                ob->mode &= ~OB_MODE_VERTEX_PAINT;
-               
-               if(vp) {
-                       toggle_paint_cursor(C, 0);
-                       vp->paintcursor= NULL;
-               }
        }
        else {
                ob->mode |= OB_MODE_VERTEX_PAINT;
@@ -1629,9 +1575,9 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
                if(vp==NULL)
                        vp= scene->toolsettings->vpaint= new_vpaint(0);
                
-               toggle_paint_cursor(C, 0);
+               paint_cursor_start(C, vp_poll);
 
-               paint_init(&vp->paint, NULL);
+               paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT);
        }
        
        if (me)
index e02062107995aadf57970ce481bf137429055933..76c5c3504da639fdd8dd5fa5055a717d282576c4 100644 (file)
@@ -1549,8 +1549,6 @@ 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;
@@ -1564,7 +1562,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                        free_sculptsession(&ob->sculpt);
                ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
 
-               paint_init(&ts->sculpt->paint, col);
+               paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT);
                
                paint_cursor_start(C, sculpt_poll);
 
index d220c707143b51ab74b5907e443dab0458ce97c6..8e8c9a9837c3eaa7b279dd179ac73d37d6ef47be 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, NULL);
+               paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
 }
 
 static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)