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 | |
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')
-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 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 70 |
4 files changed, 41 insertions, 101 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; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 9fa1b222868..73cd65cafcd 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -2426,71 +2426,6 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un #endif } - -/* vertex paint menu */ -static void do_view3d_vpaintmenu(bContext *C, void *arg, int event) -{ -#if 0 - /* events >= 3 are registered bpython scripts */ -#ifndef DISABLE_PYTHON - if (event >= 3) BPY_menu_do_python(PYMENU_VERTEXPAINT, event - 3); -#endif - switch(event) { - case 0: /* undo vertex painting */ - BIF_undo(); - break; - case 1: /* set vertex colors/weight */ - if(paint_facesel_test(CTX_data_active_object(C))) - clear_vpaint_selectedfaces(); - else /* we know were in vertex paint mode */ - clear_vpaint(); - break; - case 2: - make_vertexcol(1); - break; - } -#endif -} - -static uiBlock *view3d_vpaintmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth=120; -#ifndef DISABLE_PYTHON -// XXX BPyMenu *pym; -// int i=0; -#endif - - block= uiBeginBlock(C, ar, "view3d_paintmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_vpaintmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Vertex Painting|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Vertex Colors|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Shaded Vertex Colors", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - -#ifndef DISABLE_PYTHON - /* note that we account for the 3 previous entries with i+3: - even if the last item isnt displayed, it dosent matter */ -// for (pym = BPyMenuTable[PYMENU_VERTEXPAINT]; pym; pym = pym->next, i++) { -// uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, -// menuwidth, 19, NULL, 0.0, 0.0, 1, i+3, -// pym->tooltip?pym->tooltip:pym->filename); -// } -#endif - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - return block; -} - - /* texture paint menu (placeholder, no items yet??) */ static void do_view3d_tpaintmenu(bContext *C, void *arg, int event) { @@ -3050,11 +2985,6 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o uiDefPulldownBut(block, view3d_wpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if (ob && ob->mode & OB_MODE_VERTEX_PAINT) { - xmax= GetButStringLength("Paint"); - uiDefPulldownBut(block, view3d_vpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->mode & OB_MODE_TEXTURE_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_tpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); |