[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22646] branches/blender2.5/blender: 2.5/ Paint:
Nicholas Bishop
nicholasbishop at gmail.com
Thu Aug 20 07:13:08 CEST 2009
Revision: 22646
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22646
Author: nicholasbishop
Date: 2009-08-20 07:13:07 +0200 (Thu, 20 Aug 2009)
Log Message:
-----------
2.5/Paint:
* Converted vertex paint to use the new stroke system. Now supports the same smooth stroke and stroke spacing as sculpt mode.
* Refactored the paint cursor a bit, just sculpt for now but other modes soon.
* A couple warning fixes
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h
branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
branches/blender2.5/blender/source/blender/editors/object/object_edit.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_intern.h
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_vertex.c
branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
branches/blender2.5/blender/source/blender/gpu/GPU_draw.h
branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_space.c
branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d_toolbar.py 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/release/ui/space_view3d_toolbar.py 2009-08-20 05:13:07 UTC (rev 22646)
@@ -429,7 +429,7 @@
def poll(self, context):
settings = self.paint_settings(context)
- return (settings and settings.brush and context.sculpt_object)
+ return (settings and settings.brush and (context.sculpt_object or context.vertex_paint_object))
def draw(self, context):
settings = self.paint_settings(context)
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h 2009-08-20 05:13:07 UTC (rev 22646)
@@ -33,7 +33,7 @@
struct Paint;
struct Scene;
-void paint_init(struct Paint *p, const char *brush_name);
+void paint_init(struct Paint *p, const char *col);
void free_paint(struct Paint *p);
void copy_paint(struct Paint *orig, struct Paint *new);
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c 2009-08-20 05:13:07 UTC (rev 22646)
@@ -154,14 +154,23 @@
}
-void paint_init(Paint *p, const char *name)
+void paint_init(Paint *p, const char *col)
{
Brush *brush;
/* If there's no brush, create one */
brush = paint_brush(p);
- brush_check_exists(&brush, name);
+ 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;
+ }
+ p->paint_cursor_col[3] = 128;
}
void free_paint(Paint *paint)
Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-08-20 05:13:07 UTC (rev 22646)
@@ -7073,6 +7073,25 @@
return item;
}
+static const char *object_mode_op_string(int mode)
+{
+ if(mode == OB_MODE_EDIT)
+ return "OBJECT_OT_editmode_toggle";
+ if(mode == OB_MODE_SCULPT)
+ return "SCULPT_OT_sculptmode_toggle";
+ if(mode == OB_MODE_VERTEX_PAINT)
+ return "PAINT_OT_vertex_paint_toggle";
+ if(mode == OB_MODE_WEIGHT_PAINT)
+ return "PAINT_OT_weight_paint_toggle";
+ if(mode == OB_MODE_TEXTURE_PAINT)
+ return "PAINT_OT_texture_paint_toggle";
+ if(mode == OB_MODE_PARTICLE_EDIT)
+ return "PARTICLE_OT_particle_edit_toggle";
+ if(mode == OB_MODE_POSE)
+ return "OBJECT_OT_posemode_toggle";
+ return NULL;
+}
+
static int object_mode_set_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
@@ -7081,21 +7100,14 @@
if(!ob)
return OPERATOR_CANCELLED;
- if((mode == OB_MODE_EDIT) == !(ob->mode & OB_MODE_EDIT))
- WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_SCULPT) == !(ob->mode & OB_MODE_SCULPT))
- WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_VERTEX_PAINT) == !(ob->mode & OB_MODE_VERTEX_PAINT))
- WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_WEIGHT_PAINT) == !(ob->mode & OB_MODE_WEIGHT_PAINT))
- WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_TEXTURE_PAINT) == !(ob->mode & OB_MODE_TEXTURE_PAINT))
- WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_PARTICLE_EDIT) == !(ob->mode & OB_MODE_PARTICLE_EDIT))
- WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if((mode == OB_MODE_POSE) == !(ob->mode & OB_MODE_POSE))
- WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ /* Exit off current mode */
+ if(ob->mode != OB_MODE_OBJECT)
+ WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL);
+ /* Enter new mode */
+ if(mode != OB_MODE_OBJECT)
+ WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL);
+
return OPERATOR_FINISHED;
}
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c 2009-08-20 05:13:07 UTC (rev 22646)
@@ -5174,7 +5174,7 @@
me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
NULL, me->totface);
- paint_init(&scene->toolsettings->imapaint.paint, "Brush");
+ paint_init(&scene->toolsettings->imapaint.paint, NULL);
if(U.glreslimit != 0)
GPU_free_images();
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_intern.h 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_intern.h 2009-08-20 05:13:07 UTC (rev 22646)
@@ -50,6 +50,10 @@
StrokeUpdateStep update_step, StrokeDone done);
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
+void *paint_stroke_mode_data(struct PaintStroke *stroke);
+void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
+int paint_poll(bContext *C);
+void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
/* paint_vertex.c */
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c 2009-08-20 05:13:07 UTC (rev 22646)
@@ -77,12 +77,6 @@
RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for.");
}
-/* Paint operators */
-static int paint_poll(bContext *C)
-{
- return !!paint_get_active(CTX_data_scene(C));
-}
-
/**************************** registration **********************************/
void ED_operatortypes_paint(void)
Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2009-08-20 01:46:44 UTC (rev 22645)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2009-08-20 05:13:07 UTC (rev 22646)
@@ -43,6 +43,7 @@
#include "BLI_arithb.h"
+#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_screen.h"
@@ -54,6 +55,9 @@
#include <math.h>
typedef struct PaintStroke {
+ void *mode_data;
+ void *smooth_stroke_cursor;
+
/* Cached values */
ViewContext vc;
bglMats mats;
@@ -71,6 +75,42 @@
StrokeDone done;
} PaintStroke;
+/*** Cursor ***/
+static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata)
+{
+ Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C)));
+ PaintStroke *stroke = customdata;
+
+ glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+
+ if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
+ ARegion *ar = CTX_wm_region(C);
+ sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin,
+ (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
+ }
+
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+}
+
+static void paint_draw_cursor(bContext *C, int x, int y, void *customdata)
+{
+ Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C)));
+
+ glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+
+ glTranslatef((float)x, (float)y, 0.0f);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
+ glTranslatef((float)-x, (float)-y, 0.0f);
+
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+}
+
/* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2])
{
@@ -191,6 +231,11 @@
stroke->last_mouse_position[0] = event->x;
stroke->last_mouse_position[1] = event->y;
stroke->stroke_started = stroke->test_start(C, op, event);
+
+ if(stroke->stroke_started)
+ stroke->smooth_stroke_cursor =
+ WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
+
ED_region_tag_redraw(ar);
}
@@ -209,6 +254,9 @@
/* TODO: fix hardcoded event here */
if(event->type == LEFTMOUSE && event->val == 0) {
+ if(stroke->smooth_stroke_cursor)
+ WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor);
+
stroke->done(C, stroke);
MEM_freeN(stroke);
return OPERATOR_FINISHED;
@@ -222,3 +270,31 @@
return &stroke->vc;
}
+void *paint_stroke_mode_data(struct PaintStroke *stroke)
+{
+ return stroke->mode_data;
+}
+
+void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data)
+{
+ stroke->mode_data = mode_data;
+}
+
+int paint_poll(bContext *C)
+{
+ Paint *p = paint_get_active(CTX_data_scene(C));
+ Object *ob = CTX_data_active_object(C);
+
+ return p && ob && paint_brush(p) &&
+ CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
+ CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
+}
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list