2.5 Paint:

* Weight paint and vertex paint now use the same cursor setup as sculpt
This commit is contained in:
Nicholas Bishop 2009-08-20 16:00:17 +00:00
parent ff27281f2e
commit 4df4b17ed6
5 changed files with 31 additions and 83 deletions

@ -33,7 +33,12 @@ struct Object;
struct Paint; struct Paint;
struct Scene; 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 free_paint(struct Paint *p);
void copy_paint(struct Paint *orig, struct Paint *new); void copy_paint(struct Paint *orig, struct Paint *new);

@ -39,6 +39,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.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) Paint *paint_get_active(Scene *sce)
{ {
if(sce && sce->basact && sce->basact->object) { 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; Brush *brush;
@ -163,13 +168,7 @@ void paint_init(Paint *p, const char *col)
brush_check_exists(&brush, "Brush"); brush_check_exists(&brush, "Brush");
paint_brush_set(p, brush); paint_brush_set(p, brush);
if(col)
memcpy(p->paint_cursor_col, col, 3); 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; p->paint_cursor_col[3] = 128;
} }

@ -142,56 +142,6 @@ static int wp_poll(bContext *C)
return 0; 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) static VPaint *new_vpaint(int wpaint)
{ {
VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint"); VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint");
@ -1127,9 +1077,8 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
if(wp==NULL) if(wp==NULL)
wp= scene->toolsettings->wpaint= new_vpaint(1); wp= scene->toolsettings->wpaint= new_vpaint(1);
paint_init(&wp->paint, NULL); paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
paint_cursor_start(C, wp_poll);
toggle_paint_cursor(C, 1);
mesh_octree_table(ob, NULL, NULL, 's'); mesh_octree_table(ob, NULL, NULL, 's');
@ -1145,9 +1094,6 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
} }
} }
else { else {
if(wp)
toggle_paint_cursor(C, 1);
mesh_octree_table(ob, NULL, NULL, 'e'); 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) static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
{ {
Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); Paint *p = paint_get_active(CTX_data_scene(C));
Brush *brush = paint_brush(p);
toggle_paint_cursor(C, 0); WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
p->paint_cursor = NULL;
brush_radial_control_invoke(op, brush, 1); brush_radial_control_invoke(op, brush, 1);
return WM_radial_control_invoke(C, op, event); 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); int ret = WM_radial_control_modal(C, op, event);
if(ret != OPERATOR_RUNNING_MODAL) if(ret != OPERATOR_RUNNING_MODAL)
toggle_paint_cursor(C, 0); paint_cursor_start(C, vp_poll);
return ret; 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) static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
{ {
Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); Paint *p = paint_get_active(CTX_data_scene(C));
toggle_paint_cursor(C, 1); 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); brush_radial_control_invoke(op, brush, 1);
return WM_radial_control_invoke(C, op, event); 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); int ret = WM_radial_control_modal(C, op, event);
if(ret != OPERATOR_RUNNING_MODAL) if(ret != OPERATOR_RUNNING_MODAL)
toggle_paint_cursor(C, 1); paint_cursor_start(C, wp_poll);
return ret; return ret;
} }
@ -1614,11 +1565,6 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
if(ob->mode & OB_MODE_VERTEX_PAINT) { if(ob->mode & OB_MODE_VERTEX_PAINT) {
ob->mode &= ~OB_MODE_VERTEX_PAINT; ob->mode &= ~OB_MODE_VERTEX_PAINT;
if(vp) {
toggle_paint_cursor(C, 0);
vp->paintcursor= NULL;
}
} }
else { else {
ob->mode |= OB_MODE_VERTEX_PAINT; ob->mode |= OB_MODE_VERTEX_PAINT;
@ -1629,9 +1575,9 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
if(vp==NULL) if(vp==NULL)
vp= scene->toolsettings->vpaint= new_vpaint(0); 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) if (me)

@ -1549,8 +1549,6 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
free_sculptsession(&ob->sculpt); free_sculptsession(&ob->sculpt);
} }
else { else {
const char col[3] = {255, 100, 100};
/* Enter sculptmode */ /* Enter sculptmode */
ob->mode |= OB_MODE_SCULPT; ob->mode |= OB_MODE_SCULPT;
@ -1564,7 +1562,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
free_sculptsession(&ob->sculpt); free_sculptsession(&ob->sculpt);
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); 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); paint_cursor_start(C, sculpt_poll);

@ -151,7 +151,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr)
Scene *scene= CTX_data_scene(C); Scene *scene= CTX_data_scene(C);
if(scene) 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) static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)