#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) {
}
-void paint_init(Paint *p, const char *col)
+void paint_init(Paint *p, const char col[3])
{
Brush *brush;
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;
}
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");
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');
}
}
else {
- if(wp)
- toggle_paint_cursor(C, 1);
-
mesh_octree_table(ob, NULL, NULL, 'e');
}
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);
}
{
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;
}
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);
}
{
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;
}
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;
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)