2.5 Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Mon, 17 Aug 2009 02:49:31 +0000 (02:49 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 17 Aug 2009 02:49:31 +0000 (02:49 +0000)
* Converted vertex paint and weight paint to use the new Paint type

17 files changed:
release/ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_space.c

index f945a422b54daecd78ab4f1d56aec2956ce5308d..9afcfbb7bdd744c2240e537e203423be62c90c5d 100644 (file)
@@ -292,10 +292,11 @@ class VIEW3D_PT_tools_brush(PaintPanel):
                
                settings = self.paint_settings(context)
                brush = settings.brush
+               paint = context.sculpt_object or context.vertex_paint_object
 
                if not context.particle_edit_object:
                        col = layout.split().column()
-                       if context.sculpt_object:
+                       if paint:
                                row = col.row()
                                row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
                                
@@ -303,10 +304,11 @@ class VIEW3D_PT_tools_brush(PaintPanel):
                                sub_col.itemO("paint.brush_slot_add", icon="ICON_ZOOMIN", text="")
                                sub_col.itemO("paint.brush_slot_remove", icon="ICON_ZOOMOUT", text="")
 
-               col.template_ID(settings, "brush")
-
-               if(context.sculpt_object):
-                       col.item_menu_enumO("brush.new", "sculpt_tool");
+               if context.sculpt_object:
+                       col.template_ID(settings, "brush")
+                       col.item_menu_enumO("sculpt.brush_add", "sculpt_tool");
+               else:
+                       col.template_ID(settings, "brush", new="brush.add")
                 
                # Particle Mode #
 
index dfbc6b284ff854a6bc60ed028fef24e2f07c974d..6ec988e111e2df785fb33a9593bc8ac48980fed6 100644 (file)
@@ -44,9 +44,9 @@ void make_local_brush(struct Brush *brush);
 void free_brush(struct Brush *brush);
 
 /* brush library operations used by different paint panels */
-int brush_set_nr(struct Brush **current_brush, int nr);
+int brush_set_nr(struct Brush **current_brush, int nr, const char *name);
 int brush_delete(struct Brush **current_brush);
-void brush_check_exists(struct Brush **brush);
+void brush_check_exists(struct Brush **brush, const char *name);
 void brush_toggled_fake_user(struct Brush *brush);
 int brush_texture_set_nr(struct Brush *brush, int nr);
 int brush_texture_delete(struct Brush *brush);
index 4232ac104d4a740ae0a09d14dafbd478db7a8ced..ae18d0e9561b44fda7bdabdbde5473b75fe10e91 100644 (file)
@@ -33,6 +33,7 @@ struct Object;
 struct Paint;
 struct Scene;
 
+void paint_init(Paint *p, const char *brush_name);
 void free_paint(Paint *p);
 void copy_paint(Paint *orig, Paint *new);
 
index ebde6e0077f225c9e86d78cc2f55b8dad5f05529..3524550925ef1423616aa06b49b500095c4a90bf 100644 (file)
@@ -186,7 +186,7 @@ void make_local_brush(Brush *brush)
 
 /* Library Operations */
 
-int brush_set_nr(Brush **current_brush, int nr)
+int brush_set_nr(Brush **current_brush, int nr, const char *name)
 {
        ID *idtest, *id;
        
@@ -195,7 +195,7 @@ int brush_set_nr(Brush **current_brush, int nr)
        
        if(idtest==0) { /* new brush */
                if(id) idtest= (ID *)copy_brush((Brush *)id);
-               else idtest= (ID *)add_brush("Brush");
+               else idtest= (ID *)add_brush(name);
                idtest->us--;
        }
        if(idtest!=id) {
@@ -369,10 +369,10 @@ int brush_clone_image_delete(Brush *brush)
        return 0;
 }
 
-void brush_check_exists(Brush **brush)
+void brush_check_exists(Brush **brush, const char *name)
 {
        if(*brush==NULL)
-               brush_set_nr(brush, 1);
+               brush_set_nr(brush, 1, name);
 }
 
 /* Brush Sampling */
index 3f6eed8528ad9842f3ed8b09ff10718df814ec35..8e774e4c85a45f3f6c1ca21c126a9fa52091e85c 100644 (file)
 Paint *paint_get_active(Scene *sce)
 {
        if(sce && sce->basact && sce->basact->object) {
+               ToolSettings *ts = sce->toolsettings;
+
                switch(sce->basact->object->mode) {
                case OB_MODE_SCULPT:
-                       return &sce->toolsettings->sculpt->paint;
+                       return &ts->sculpt->paint;
+               case OB_MODE_VERTEX_PAINT:
+                       return &ts->vpaint->paint;
+               case OB_MODE_WEIGHT_PAINT:
+                       return &ts->wpaint->paint;
+               case OB_MODE_TEXTURE_PAINT:
+                       break;
+                       //return &ts->imapaint->paint;
                }
        }
-       /*else if(G.f & G_VERTEXPAINT)
-               return &sce->toolsettings->vpaint->paint;
-       else if(G.f & G_WEIGHTPAINT)
-               return &sce->toolsettings->wpaint->paint;
-       else if(G.f & G_TEXTUREPAINT)
-       return &sce->toolsettings->imapaint.paint;*/
 
        return NULL;
 }
@@ -137,6 +140,16 @@ int paint_facesel_test(Object *ob)
 
 }
 
+void paint_init(Paint *p, const char *name)
+{
+       Brush *brush;
+
+       /* If there's no brush, create one */
+       brush = paint_brush(p);
+       brush_check_exists(&brush, name);
+       paint_brush_set(p, brush);
+}
+
 void free_paint(Paint *paint)
 {
        if(paint->brushes)
index f1727cc6b59000c6e1a925dbd909461a6b129435..dc1a55ed0eb525daf98cb9426f7292fe06a93647 100644 (file)
@@ -163,14 +163,14 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type)
                                ts->vpaint->paintcursor= NULL;
                                ts->vpaint->vpaint_prev= NULL;
                                ts->vpaint->wpaint_prev= NULL;
-                               id_us_plus((ID *)ts->vpaint->brush);
+                               copy_paint(&ts->vpaint->paint, &ts->vpaint->paint);
                        }
                        if(ts->wpaint) {
                                ts->wpaint= MEM_dupallocN(ts->wpaint);
                                ts->wpaint->paintcursor= NULL;
                                ts->wpaint->vpaint_prev= NULL;
                                ts->wpaint->wpaint_prev= NULL;
-                               id_us_plus((ID *)ts->wpaint->brush);
+                               copy_paint(&ts->wpaint->paint, &ts->wpaint->paint);
                        }
                        if(ts->sculpt) {
                                ts->sculpt= MEM_dupallocN(ts->sculpt);
@@ -272,10 +272,14 @@ void free_scene(Scene *sce)
        BLI_freelistN(&sce->r.layers);
        
        if(sce->toolsettings) {
-               if(sce->toolsettings->vpaint)
+               if(sce->toolsettings->vpaint) {
+                       free_paint(&sce->toolsettings->vpaint->paint);
                        MEM_freeN(sce->toolsettings->vpaint);
-               if(sce->toolsettings->wpaint)
+               }
+               if(sce->toolsettings->wpaint) {
+                       free_paint(&sce->toolsettings->wpaint->paint);
                        MEM_freeN(sce->toolsettings->wpaint);
+               }
                if(sce->toolsettings->sculpt) {
                        free_paint(&sce->toolsettings->sculpt->paint);
                        MEM_freeN(sce->toolsettings->sculpt);
index 91596cf884330385640d00ba41fd05e702631576..685c379dab23ad68be3de305de2a199cf9a1ef57 100644 (file)
@@ -4046,14 +4046,9 @@ static void lib_link_scene(FileData *fd, Main *main)
                                newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
 
                        link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
+                       link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
+                       link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
 
-                       if(sce->toolsettings->vpaint)
-                               sce->toolsettings->vpaint->brush=
-                                       newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush);
-                       if(sce->toolsettings->wpaint)
-                               sce->toolsettings->wpaint->brush=
-                                       newlibadr_us(fd, sce->id.lib, sce->toolsettings->wpaint->brush);
-                       
                        sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
 
                        for(base= sce->base.first; base; base= next) {
@@ -4160,9 +4155,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
        
        sce->toolsettings= newdataadr(fd, sce->toolsettings);
        if(sce->toolsettings) {
-               sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint);
-               sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint);
                direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt);
+               direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint);
+               direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint);
 
                sce->toolsettings->imapaint.paintcursor= NULL;
                sce->toolsettings->particle.paintcursor= NULL;
index 6822305e75f5b4ec24189cdeb8332b4c92485486..f59fc769d5d2590964b54fb4e503c552374eeefb 100644 (file)
@@ -1713,10 +1713,14 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
                
                tos = sce->toolsettings;
                writestruct(wd, DATA, "ToolSettings", 1, tos);
-               if(tos->vpaint)
+               if(tos->vpaint) {
                        writestruct(wd, DATA, "VPaint", 1, tos->vpaint);
-               if(tos->wpaint)
+                       write_paint(wd, &tos->vpaint->paint);
+               }
+               if(tos->wpaint) {
                        writestruct(wd, DATA, "VPaint", 1, tos->wpaint);
+                       write_paint(wd, &tos->wpaint->paint);
+               }
                if(tos->sculpt) {
                        writestruct(wd, DATA, "Sculpt", 1, tos->sculpt);
                        write_paint(wd, &tos->sculpt->paint);
index 3d3e29bcc228f5efc4677c1cc0a27d40f179bed5..154ab14df60100189a94fd1b11af1db93446af7d 100644 (file)
@@ -57,6 +57,7 @@
 #include "BKE_global.h"
 #include "BKE_lattice.h"
 #include "BKE_mesh.h"
+#include "BKE_paint.h"
 #include "BKE_utildefines.h"
 
 #include "RNA_access.h"
@@ -1028,11 +1029,11 @@ void vgroup_assign_with_menu(Scene *scene, Object *ob)
        switch (mode) {
                case 1: /* add to new group */
                        add_defgroup(ob);
-                       assign_verts_defgroup(ob, wp->brush->alpha);
+                       assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha);
                        BIF_undo_push("Assign to vertex group");
                        break;
                case 2: /* add to current group */
-                       assign_verts_defgroup(ob, wp->brush->alpha);
+                       assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha);
                        BIF_undo_push("Assign to vertex group");
                        break;
                case 3: /* remove from current group */
index 4ff658b51cf8bf8323d37c5e0629b3baaec7e5fc..93744072fffaa9ed5e517af77d603edda6e7a163 100644 (file)
@@ -5167,7 +5167,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);
 
-               brush_check_exists(&scene->toolsettings->imapaint.brush);
+               brush_check_exists(&scene->toolsettings->imapaint.brush, "Brush");
 
                if(U.glreslimit != 0)
                        GPU_free_images();
index c1404b7a63e2985f610cd072754484e19a80bddd..5d6589b7d8cef415f38d5fd17154cd4d45f96742 100644 (file)
@@ -19,6 +19,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include "DNA_brush_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
 #include "BKE_brush.h"
@@ -26,6 +28,7 @@
 #include "BKE_paint.h"
 
 #include "ED_sculpt.h"
+#include "UI_resources.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 #include <string.h>
 
 /* Brush operators */
-static int new_brush_exec(bContext *C, wmOperator *op)
+static int brush_add_exec(bContext *C, wmOperator *op)
 {
-       int sculpt_tool = RNA_enum_get(op->ptr, "sculpt_tool");
-       const char *name = NULL;
+       int type = RNA_enum_get(op->ptr, "type");
+       int sculpt_tool = SCULPT_TOOL_DRAW;
+       const char *name = "Brush";
        Brush *br = NULL;
 
-       RNA_enum_name(brush_sculpt_tool_items, sculpt_tool, &name);
+       if(type == OB_MODE_SCULPT) {
+               sculpt_tool = RNA_enum_get(op->ptr, "sculpt_tool");
+               RNA_enum_name(brush_sculpt_tool_items, sculpt_tool, &name);
+       }
+
        br = add_brush(name);
 
        if(br) {
@@ -56,20 +64,43 @@ static int new_brush_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void BRUSH_OT_new(wmOperatorType *ot)
+static EnumPropertyItem brush_type_items[] = {
+       {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
+       {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
+       {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
+       {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
+       {0, NULL, 0, NULL, NULL}};
+
+void SCULPT_OT_brush_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Brush";
+       ot->idname= "SCULPT_OT_brush_add";
+       
+       /* api callbacks */
+       ot->exec= brush_add_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       RNA_def_enum(ot->srna, "sculpt_tool", brush_sculpt_tool_items, SCULPT_TOOL_DRAW, "Sculpt Tool", "");
+
+       RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_SCULPT, "Type", "Which paint mode to create the brush for.");
+}
+
+void BRUSH_OT_add(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Add Brush";
-       ot->idname= "BRUSH_OT_new";
+       ot->idname= "BRUSH_OT_add";
        
        /* api callbacks */
-       ot->exec= new_brush_exec;
+       ot->exec= brush_add_exec;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
-       /* TODO: add enum props for other paint modes */
-       RNA_def_enum(ot->srna, "sculpt_tool", brush_sculpt_tool_items, 0, "Sculpt Tool", "");
+       RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for.");
 }
 
 /* Paint operators */
@@ -133,9 +164,12 @@ void ED_operatortypes_paint(void)
        WM_operatortype_append(PAINT_OT_brush_slot_remove);
 
        /* brush */
-       WM_operatortype_append(BRUSH_OT_new);
+       WM_operatortype_append(BRUSH_OT_add);
        WM_operatortype_append(BRUSH_OT_curve_preset);
 
+       /* sculpt */
+       WM_operatortype_append(SCULPT_OT_brush_add);
+
        /* image */
        WM_operatortype_append(PAINT_OT_texture_paint_toggle);
        WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
index bbc68a6bd0a856417ed11295b6b4b554c2d99bc1..1a548708ec89cd4b3cd4c0c919a1a7acdf98b964 100644 (file)
@@ -76,6 +76,7 @@
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
+#include "BKE_paint.h"
 #include "BKE_utildefines.h"
 
 #include "WM_api.h"
@@ -110,7 +111,8 @@ static int vp_poll(bContext *C)
 {
        Object *ob = CTX_data_active_object(C);
 
-       if(ob && ob->mode & OB_MODE_VERTEX_PAINT) {
+       if(ob && ob->mode & OB_MODE_VERTEX_PAINT &&
+          paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) {
                ScrArea *sa= CTX_wm_area(C);
                if(sa->spacetype==SPACE_VIEW3D) {
                        ARegion *ar= CTX_wm_region(C);
@@ -125,7 +127,8 @@ static int wp_poll(bContext *C)
 {
        Object *ob = CTX_data_active_object(C);
 
-       if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
+       if(ob && ob->mode & OB_MODE_WEIGHT_PAINT &&
+          paint_brush(&CTX_data_tool_settings(C)->wpaint->paint)) {
                ScrArea *sa= CTX_wm_area(C);
                if(sa->spacetype==SPACE_VIEW3D) {
                        ARegion *ar= CTX_wm_region(C);
@@ -140,14 +143,14 @@ static int wp_poll(bContext *C)
 /* Cursors */
 static void vp_drawcursor(bContext *C, int x, int y, void *customdata)
 {
-       ToolSettings *ts= CTX_data_tool_settings(C);
+       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, ts->vpaint->brush->size, 40);
+       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
        glDisable(GL_BLEND);
        glDisable( GL_LINE_SMOOTH );
        
@@ -156,14 +159,14 @@ static void vp_drawcursor(bContext *C, int x, int y, void *customdata)
 
 static void wp_drawcursor(bContext *C, int x, int y, void *customdata)
 {
-       ToolSettings *ts= CTX_data_tool_settings(C);
-       
+       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, ts->wpaint->brush->size, 40);
+       glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
        glDisable(GL_BLEND);
        glDisable( GL_LINE_SMOOTH );
        
@@ -236,7 +239,8 @@ unsigned int rgba_to_mcol(float r, float g, float b, float a)
 
 static unsigned int vpaint_get_current_col(VPaint *vp)
 {
-       return rgba_to_mcol(vp->brush->rgb[0], vp->brush->rgb[1], vp->brush->rgb[2], 1.0f);
+       Brush *brush = paint_brush(&vp->paint);
+       return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f);
 }
 
 void do_shared_vertexcol(Mesh *me)
@@ -725,6 +729,7 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
 
 static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha)
 {
+       Brush *brush = paint_brush(&vp->paint);
 
        if(vp->mode==VP_MIX || vp->mode==VP_BLUR) *col= mcol_blend( *col, paintcol, alpha);
        else if(vp->mode==VP_ADD) *col= mcol_add( *col, paintcol, alpha);
@@ -738,7 +743,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u
                unsigned int testcol=0, a;
                char *cp, *ct, *co;
                
-               alpha= (int)(255.0*vp->brush->alpha);
+               alpha= (int)(255.0*brush->alpha);
                
                if(vp->mode==VP_MIX || vp->mode==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha);
                else if(vp->mode==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha);
@@ -804,6 +809,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
 
 static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, short *mval)
 {
+       Brush *brush = paint_brush(&vp->paint);
        float fac, dx, dy;
        int alpha;
        short vertco[2];
@@ -814,14 +820,14 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa
                dy= mval[1]-vertco[1];
                
                fac= sqrt(dx*dx + dy*dy);
-               if(fac > vp->brush->size) return 0;
+               if(fac > brush->size) return 0;
                if(vp->flag & VP_HARD)
                        alpha= 255;
                else
-                       alpha= 255.0*vp->brush->alpha*(1.0-fac/vp->brush->size);
+                       alpha= 255.0*brush->alpha*(1.0-fac/brush->size);
        }
        else {
-               alpha= 255.0*vp->brush->alpha;
+               alpha= 255.0*brush->alpha;
        }
 
        if(vp->flag & VP_NORMALS) {
@@ -843,6 +849,7 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa
 
 static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval)
 {
+       Brush *brush = paint_brush(&wp->paint);
        
        if(dw==NULL || uw==NULL) return;
        
@@ -868,7 +875,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float
        if((wp->flag & VP_SPRAY)==0) {
                float testw=0.0f;
                
-               alpha= wp->brush->alpha;
+               alpha= brush->alpha;
                if(wp->mode==VP_MIX || wp->mode==VP_BLUR)
                        testw = paintval*alpha + uw->weight*(1.0-alpha);
                else if(wp->mode==VP_ADD)
@@ -1117,8 +1124,8 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                if(wp==NULL)
                        wp= scene->toolsettings->wpaint= new_vpaint(1);
 
-               brush_check_exists(&wp->brush);
-               
+               paint_init(&wp->paint, "Brush");
+
                toggle_paint_cursor(C, 1);
                
                mesh_octree_table(ob, NULL, NULL, 's');
@@ -1178,8 +1185,10 @@ 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);
-       brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1);
+       brush_radial_control_invoke(op, brush, 1);
        return WM_radial_control_invoke(C, op, event);
 }
 
@@ -1193,13 +1202,15 @@ static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
 
 static int vpaint_radial_control_exec(bContext *C, wmOperator *op)
 {
-       return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1);
+       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint);
+       return brush_radial_control_exec(op, brush, 1);
 }
 
 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);
-       brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1);
+       brush_radial_control_invoke(op, brush, 1);
        return WM_radial_control_invoke(C, op, event);
 }
 
@@ -1213,7 +1224,8 @@ static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
 
 static int wpaint_radial_control_exec(bContext *C, wmOperator *op)
 {
-       return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1);
+       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint);
+       return brush_radial_control_exec(op, brush, 1);
 }
 
 void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot)
@@ -1297,6 +1309,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        ToolSettings *ts= CTX_data_tool_settings(C);
        VPaint *wp= ts->wpaint;
+       Brush *brush = paint_brush(&wp->paint);
        
        switch(event->type) {
                case LEFTMOUSE:
@@ -1332,7 +1345,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        
                        /* which faces are involved */
                        if(wp->flag & VP_AREA) {
-                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->brush->size);
+                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size);
                        }
                        else {
                                indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
@@ -1611,7 +1624,6 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
                }
        }
        else {
-               
                ob->mode |= OB_MODE_VERTEX_PAINT;
                /* Turn off weight painting */
                if (ob->mode & OB_MODE_WEIGHT_PAINT)
@@ -1621,7 +1633,8 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
                        vp= scene->toolsettings->vpaint= new_vpaint(0);
                
                toggle_paint_cursor(C, 0);
-               brush_check_exists(&scene->toolsettings->vpaint->brush);
+
+               paint_init(&vp->paint, "Brush");
        }
        
        if (me)
@@ -1700,6 +1713,7 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        ToolSettings *ts= CTX_data_tool_settings(C);
        VPaint *vp= ts->vpaint;
+       Brush *brush = paint_brush(&vp->paint);
        
        switch(event->type) {
                case LEFTMOUSE:
@@ -1732,7 +1746,7 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                
                        /* which faces are involved */
                        if(vp->flag & VP_AREA) {
-                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->brush->size);
+                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size);
                        }
                        else {
                                indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
index eae73feeccb42ee5d09b946480ca8206696afcb3..59a716090651f4815c7c370bbbfa27546ae61413 100644 (file)
@@ -1686,8 +1686,6 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                free_sculptsession(&ob->sculpt);
        }
        else {
-               Brush *brush;
-
                /* Enter sculptmode */
 
                ob->mode |= OB_MODE_SCULPT;
@@ -1704,10 +1702,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                if(!ts->sculpt->cursor)
                        toggle_paint_cursor(C);
 
-               /* If there's no brush, create one */
-               brush = paint_brush(&ts->sculpt->paint);
-               brush_check_exists(&brush);
-               paint_brush_set(&ts->sculpt->paint, brush);
+               paint_init(&ts->sculpt->paint, "Draw");
 
                WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
        }
index ef61299ef7006d6ea11259d16a2576011998af43..318e0b0f5587d0c6150b5406c5b45c744468394f 100644 (file)
@@ -326,9 +326,9 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
                        if(obact->mode & OB_MODE_SCULPT)
                                paint_brush(&ts->sculpt->paint);
                        else if(obact->mode & OB_MODE_VERTEX_PAINT)
-                               br= ts->vpaint->brush;
+                               paint_brush(&ts->vpaint->paint);
                        else if(obact->mode & OB_MODE_WEIGHT_PAINT)
-                               br= ts->wpaint->brush;
+                               paint_brush(&ts->wpaint->paint);
                        else if(obact->mode & OB_MODE_TEXTURE_PAINT)
                                br= ts->imapaint.brush;
                }
index 05f3666be944f05dae1bf9d7c3ec4f0db26438b1..28eddeb6f2e349e58363195b4319c6194784069a 100644 (file)
@@ -474,8 +474,7 @@ typedef struct Paint {
        void *paint_cursor;
 } Paint;
 
-typedef struct Sculpt
-{
+typedef struct Sculpt {
        Paint paint;
        
        /* WM handle */
@@ -491,7 +490,7 @@ typedef struct Sculpt
 } Sculpt;
 
 typedef struct VPaint {
-       struct Brush *brush;
+       Paint paint;
 
        float gamma, mul;                       /* should become part of struct Brush? */
        short mode, flag;
index 9b0e679e3b698d58265fb9540698b7d3dfd43222..f3b970c765964bb149f2d790347ba3fa45b9f7a6 100644 (file)
@@ -159,14 +159,10 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
                {6, "DARKEN", 0, "Darken", "Use darken blending mode while painting."},
                {0, NULL, 0, NULL, NULL}};
        
-       srna= RNA_def_struct(brna, "VertexPaint", NULL);
+       srna= RNA_def_struct(brna, "VertexPaint", "Paint");
        RNA_def_struct_sdna(srna, "VPaint");
        RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode.");
     
-       prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "Brush");
-       RNA_def_property_ui_text(prop, "Brush", "");
-
        prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_mode_items);
        RNA_def_property_ui_text(prop, "Brush Mode", "Mode in which color is painted.");
index ab67af2ab0879980e998a1b431672bba49f7a0d3..24337c0fc7056c0753472cb962e886e1565b41bb 100644 (file)
@@ -145,7 +145,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr)
        Scene *scene= CTX_data_scene(C);
 
        if(scene)
-               brush_check_exists(&scene->toolsettings->imapaint.brush);
+               brush_check_exists(&scene->toolsettings->imapaint.brush, "Brush");
 }
 
 static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)