diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-16 00:36:15 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-08-16 00:36:15 +0400 |
commit | e182d653709a9abd664deaa874f0727ebba83832 (patch) | |
tree | a91df79e87cc7d7d919a7f4bc8d0e4fc6d78c24d /source/blender/editors | |
parent | 2b3d2b72ea157a218e1a6e49759e64de77f99850 (diff) |
2.5/Vertex paint:
* Made vertex paint local to object, like sculpt mode.
* New test for vertex paint is (ob->mode & OB_MODE_VERTEX_PAINT)
Diffstat (limited to 'source/blender/editors')
12 files changed, 62 insertions, 52 deletions
diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c index 99d50d1a9b0..e06381780db 100644 --- a/source/blender/editors/mesh/mesh_layers.c +++ b/source/blender/editors/mesh/mesh_layers.c @@ -54,12 +54,14 @@ #include "WM_types.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_view3d.h" #include "mesh_intern.h" -static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) +static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer) { + Mesh *me = ob->data; CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata; void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data; int type= layer->type; @@ -87,9 +89,8 @@ static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) mesh_update_customdata_pointers(me); } - if(!CustomData_has_layer(data, type)) - if(type == CD_MCOL && (G.f & G_VERTEXPAINT)) - G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */ + if(!CustomData_has_layer(data, type) && (type == CD_MCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) + ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); /* reconstruct active layer */ if (actlayerdata != layerdata) { @@ -225,7 +226,7 @@ static int uv_texture_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl); + delete_customdata_layer(C, ob, cdl); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -328,7 +329,7 @@ static int vertex_color_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl); + delete_customdata_layer(C, ob, cdl); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c65855c24a0..f5a93fae8e9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -4165,7 +4165,7 @@ void special_editmenu(Scene *scene, View3D *v3d) } DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } - else if(G.f & G_VERTEXPAINT) { + else if(ob->mode & OB_MODE_VERTEX_PAINT) { Mesh *me= get_mesh(ob); if(me==0 || (me->mcol==NULL && me->mtface==NULL) ) return; @@ -7042,4 +7042,6 @@ void ED_object_toggle_modes(bContext *C, int mode) { if(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) + WM_operator_name_call(C, "SCULPT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index ba91502dcbb..0ac9333aafc 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -44,6 +44,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; + Object *ob = NULL; + + if(scene && scene->basact) + ob = scene->basact->object; if(CTX_data_dir(member)) { static const char *dir[] = { @@ -112,14 +116,14 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if(CTX_data_equals(member, "sculpt_object")) { - if(scene->basact && (scene->basact->object->mode & OB_MODE_SCULPT)) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_SCULPT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "vertex_paint_object")) { - if(G.f & G_VERTEXPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 812c41f430e..b8ee2710152 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -108,7 +108,9 @@ static void error() {} static int vp_poll(bContext *C) { - if(G.f & G_VERTEXPAINT) { + Object *ob = CTX_data_active_object(C); + + if(ob && ob->mode & OB_MODE_VERTEX_PAINT) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -369,12 +371,12 @@ void clear_vpaint(Scene *scene) unsigned int *to, paintcol; int a; - if((G.f & G_VERTEXPAINT)==0) return; - 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); @@ -540,10 +542,10 @@ void vpaint_dogamma(Scene *scene) int a, temp; unsigned char *cp, gamtab[256]; - if((G.f & G_VERTEXPAINT)==0) return; - ob= OBACT; me= get_mesh(ob); + + if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if(me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; @@ -1584,22 +1586,22 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); if(me==NULL || object_data_is_libdata(ob)) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_FINISHED; } if(me && me->mcol==NULL) make_vertexcol(scene, 0); /* toggle: end vpaint */ - if(G.f & G_VERTEXPAINT) { + if(ob->mode & OB_MODE_VERTEX_PAINT) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; if(vp) { toggle_paint_cursor(C, 0); @@ -1608,7 +1610,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ } else { - G.f |= G_VERTEXPAINT; + ob->mode |= OB_MODE_VERTEX_PAINT; /* Turn off weight painting */ if (G.f & G_WEIGHTPAINT) set_wpaint(C, op); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 0be151a11b6..d438490ff7e 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -323,7 +323,7 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) if(obact && obact->mode & OB_MODE_SCULPT) br= ts->sculpt->brush; - else if(G.f & G_VERTEXPAINT) + else if(obact && obact->mode & OB_MODE_VERTEX_PAINT) br= ts->vpaint->brush; else if(G.f & G_WEIGHTPAINT) br= ts->wpaint->brush; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 850731baf91..3f3cb401959 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2348,12 +2348,13 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base GPU_disable_material(); } - else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) { - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); - } - else if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) { - glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + else if((G.f & G_TEXTUREPAINT || ob->mode & OB_MODE_VERTEX_PAINT)) { + if(me->mcol) + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); + else { + glColor3f(1.0f, 1.0f, 1.0f); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + } } else do_draw= 1; } @@ -5072,7 +5073,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) dtx= 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ - if(ob==OBACT && (G.f & (G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT))) { + if(ob==OBACT && (G.f & (G_TEXTUREPAINT+G_WEIGHTPAINT) || ob->mode & OB_MODE_VERTEX_PAINT)) { if(ob->type==OB_MESH) { if(ob==scene->obedit); @@ -5710,7 +5711,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(G.f & G_RENDER_SHADOW) return; /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if(ob!=OBACT || (G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) { + if(ob!=OBACT || ((G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT))==0) || ob->mode & OB_MODE_VERTEX_PAINT) { int do_draw_center= -1; /* defines below are zero or positive... */ if((scene->basact)==base) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index c09646e7cd7..8057ed9f819 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1058,7 +1058,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + if(ob->mode & OB_MODE_VERTEX_PAINT || G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT)) { } else { //bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, ""); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f88386a08a6..c1f02c74460 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1091,7 +1091,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; - struct Base *base; + struct Base *base = scene->basact; /*for 2.43 release, don't use glext and just define the constant. this to avoid possibly breaking platforms before release.*/ @@ -1103,7 +1103,9 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) int m; #endif - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (scene->basact && paint_facesel_test(scene->basact->object))); + if(G.f & G_WEIGHTPAINT || + (base && (base->object->mode & OB_MODE_VERTEX_PAINT || + paint_facesel_test(base->object)))); else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); @@ -1150,7 +1152,6 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) G.f |= G_BACKBUFSEL; - base= (scene->basact); if(base && (base->lay & v3d->lay)) { draw_object_backbufsel(scene, v3d, rv3d, base->object); } @@ -1883,7 +1884,7 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen, Object *ob) } /* check if we need mcols due to vertex paint or weightpaint */ - if(G.f & G_VERTEXPAINT) + if(ob && ob->mode & OB_MODE_VERTEX_PAINT) mask |= CD_MASK_MCOL; if(G.f & G_WEIGHTPAINT) mask |= CD_MASK_WEIGHT_MCOL; @@ -2121,7 +2122,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) /* XXX here was the blockhandlers for floating panels */ - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) { + if((ob && ob->mode & OB_MODE_VERTEX_PAINT) || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a451dbaef63..26e2918c032 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -139,8 +139,6 @@ static void ED_toggle_paint_modes(bContext *C, int mode) { if(mode & G_TEXTUREPAINT) WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & G_VERTEXPAINT) - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); else if(mode & G_WEIGHTPAINT) WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); @@ -155,7 +153,7 @@ int ED_view3d_exit_paint_modes(bContext *C) ED_toggle_paint_modes(C, G.f); - G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_PARTICLEEDIT); + G.f &= ~(G_TEXTUREPAINT+G_WEIGHTPAINT+G_PARTICLEEDIT); return restore; } @@ -985,8 +983,7 @@ static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_ void uiTemplate_view3d_select_metaballmenu(uiLayout *layout, bContext *C) { void *arg_unused = NULL; - ARegion *ar= CTX_wm_region(C); - view3d_select_metaballmenu(C, ar, arg_unused); + view3d_select_metaballmenu(C, layout, arg_unused); } static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) @@ -3476,7 +3473,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) } } else if (v3d->modeselect == V3D_VERTEXPAINTMODE_SEL) { - if (!(G.f & G_VERTEXPAINT)) { + if (ob && !(ob->mode & OB_MODE_VERTEX_PAINT)) { v3d->flag &= ~V3D_MODE; ED_view3d_exit_paint_modes(C); ED_object_toggle_modes(C, ob->mode); @@ -3710,7 +3707,7 @@ 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 (G.f & G_VERTEXPAINT) { + 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; @@ -3804,7 +3801,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else if(ob && (ob->flag & OB_POSEMODE)) v3d->modeselect = V3D_POSEMODE_SEL; else if (ob && (ob->mode & OB_MODE_SCULPT)) v3d->modeselect = V3D_SCULPTMODE_SEL; else if (G.f & G_WEIGHTPAINT) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL; - else if (G.f & G_VERTEXPAINT) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL; + else if (ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL; else if (G.f & G_TEXTUREPAINT) v3d->modeselect = V3D_TEXTUREPAINTMODE_SEL; /*else if(G.f & G_FACESELECT) v3d->modeselect = V3D_FACESELECTMODE_SEL;*/ else if(G.f & G_PARTICLEEDIT) v3d->modeselect = V3D_PARTICLEEDITMODE_SEL; @@ -3814,7 +3811,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* not sure what the v3d->flag is useful for now... modeselect is confusing */ if(obedit) v3d->flag |= V3D_EDITMODE; if(ob && (ob->flag & OB_POSEMODE)) v3d->flag |= V3D_POSEMODE; - if(G.f & G_VERTEXPAINT) v3d->flag |= V3D_VERTEXPAINT; + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT; if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT; if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT; if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT; @@ -3860,7 +3857,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); } } else { - if (obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) { + if (obedit==NULL && ((ob && ob->mode & OB_MODE_VERTEX_PAINT) || G.f & (G_WEIGHTPAINT|G_TEXTUREPAINT))) { uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); header_xco_step(ar, &xco, &yco, &maxco, XIC+10); } else { diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 3966fc343c4..a6a42c0ba67 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -694,10 +694,12 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select) { + Object *ob = CTX_data_active_object(C); + if(vc->obedit==NULL) { - if(paint_facesel_test(CTX_data_active_object(C))) + if(paint_facesel_test(ob)) do_lasso_select_facemode(vc, mcords, moves, select); - else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) + else if(G.f & (G_TEXTUREPAINT|G_WEIGHTPAINT) || (ob && ob->mode & OB_MODE_VERTEX_PAINT)) ; else if(G.f & G_PARTICLEEDIT) PE_lasso_select(C, mcords, moves, select); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 55e06b731f4..be377f6af83 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -358,10 +358,10 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(ob->obmat, scene->twmax); } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT)) { + else if(G.f & (G_TEXTUREPAINT + G_WEIGHTPAINT)) { ; } - else if(ob && (ob->mode & OB_MODE_SCULPT)) { + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT))) { ; } else if(G.f & G_PARTICLEEDIT) { diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 46853fa62c3..6ba67084387 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -894,10 +894,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if(ob && (ob->mode & OB_MODE_SCULPT)) + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT))) { } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT)) + else if(G.f & (G_TEXTUREPAINT + G_WEIGHTPAINT)) { } else if(G.f & G_PARTICLEEDIT) |