diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-22 06:27:37 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-22 06:27:37 +0400 |
commit | 0be1e72dca48a6709c2ae8b3805387d4ef5bcdcb (patch) | |
tree | 4fc4833e0280051203a765da2b5f587251291b78 /source/blender/editors/sculpt_paint | |
parent | 095ec3a6e9357e6ce14fd200396ea221ac88e3b6 (diff) |
2.5/Vertex paint:
* Added operator for filling vertex colors with the brush color
* Pythonized the vertex paint menu
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 27 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 42 |
3 files changed, 41 insertions, 31 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index a0187566c43..ba1b57a1bef 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -57,6 +57,9 @@ int paint_poll(bContext *C); void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); /* paint_vertex.c */ +int vertex_paint_mode_poll(bContext *C); +void clear_vpaint(Scene *scene, int selected); + void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 1ea612c0aa5..c38b36007e9 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -77,6 +77,32 @@ void BRUSH_OT_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for."); } +static int vertex_color_set_exec(bContext *C, wmOperator *op) +{ + int selected = RNA_boolean_get(op->ptr, "selected"); + Scene *scene = CTX_data_scene(C); + + clear_vpaint(scene, selected); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_vertex_color_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Vertex Colors"; + ot->idname= "PAINT_OT_vertex_color_set"; + + /* api callbacks */ + ot->exec= vertex_color_set_exec; + ot->poll= vertex_paint_mode_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "selected", 0, "Type", "Only color selected faces."); +} + /**************************** registration **********************************/ void ED_operatortypes_paint(void) @@ -103,5 +129,6 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); + WM_operatortype_append(PAINT_OT_vertex_color_set); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index bc2ac480657..ee3d9e5baa1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -110,11 +110,18 @@ static void error() {} /* polling - retrieve whether cursor should be set or operator should be done */ -static int vp_poll(bContext *C) + +/* Returns true if vertex paint mode is active */ +int vertex_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); - if(ob && ob->mode & OB_MODE_VERTEX_PAINT && + return ob && ob->mode == OB_MODE_VERTEX_PAINT; +} + +static int vp_poll(bContext *C) +{ + if(vertex_paint_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { @@ -323,34 +330,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) } -void clear_vpaint(Scene *scene) -{ - Mesh *me; - Object *ob; - unsigned int *to, paintcol; - int a; - - ob= OBACT; - me= get_mesh(ob); - if(!ob || ob->id.lib) return; - - if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; - - if(me==0 || me->mcol==0 || me->totface==0) return; - - paintcol= vpaint_get_current_col(scene->toolsettings->vpaint); - - to= (unsigned int *)me->mcol; - a= 4*me->totface; - while(a--) { - *to= paintcol; - to++; - } - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - -} - -void clear_vpaint_selectedfaces(Scene *scene) +void clear_vpaint(Scene *scene, int selected) { Mesh *me; MFace *mf; @@ -370,7 +350,7 @@ void clear_vpaint_selectedfaces(Scene *scene) mf = me->mface; mcol = (unsigned int*)me->mcol; for (i = 0; i < me->totface; i++, mf++, mcol+=4) { - if (mf->flag & ME_FACE_SEL) { + if (!selected || mf->flag & ME_FACE_SEL) { mcol[0] = paintcol; mcol[1] = paintcol; mcol[2] = paintcol; |