2.5 Paint:

* Converted vertex paint and weight paint to use the new Paint type
This commit is contained in:
Nicholas Bishop 2009-08-17 02:49:31 +00:00
parent 1e0fd0d4c1
commit 9d2d3a8be7
17 changed files with 144 additions and 86 deletions

@ -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 #

@ -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);

@ -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);

@ -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 */

@ -41,17 +41,20 @@
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)

@ -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);

@ -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;

@ -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);

@ -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 */

@ -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();

@ -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"
@ -39,13 +42,18 @@
#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= "BRUSH_OT_new";
ot->idname= "SCULPT_OT_brush_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, "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_add";
/* api callbacks */
ot->exec= brush_add_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
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);

@ -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]);

@ -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));
}

@ -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;
}

@ -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;

@ -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.");

@ -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)