Index: source/blender/makesdna/DNA_view3d_types.h =================================================================== --- source/blender/makesdna/DNA_view3d_types.h (revision 11461) +++ source/blender/makesdna/DNA_view3d_types.h (working copy) @@ -166,8 +166,9 @@ /* View3d->flag2 (short) */ #define V3D_OPP_DIRECTION_NAME 1 -#define V3D_FLYMODE 2 -#define V3D_TRANSFORM_SNAP 4 +#define V3D_FLYMODE 2 +#define V3D_TRANSFORM_SNAP 4 +#define V3D_VERTEX_EDIT 8 /* View3d->snap_target */ #define V3D_SNAP_TARGET_CLOSEST 0 Index: source/blender/src/header_view3d.c =================================================================== --- source/blender/src/header_view3d.c (revision 11461) +++ source/blender/src/header_view3d.c (working copy) @@ -63,6 +63,7 @@ #include "BKE_action.h" #include "BKE_curve.h" +#include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_effect.h" @@ -5090,9 +5091,36 @@ *xcoord= xco; } +static void update_selection_cb(void *poin, void *poin2) +{ + EM_clear_flag_all(SELECT); + sel_verts_defgroup(1); + + allqueue(REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + countall(); +} + +static void verify_vertexgroup_name_func(void *datav, void *data2_unused) +{ + unique_vertexgroup_name((bDeformGroup*)datav, OBACT); +} + +static void delete_current_vgroup_cb(void *poin, void *poin2) +{ + Object *ob = (Object *)poin; + + del_defgroup(ob); + + allqueue(REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + BIF_undo_push("Delete vertex group"); +} + void view3d_buttons(void) { uiBlock *block; + uiBut *bt; Object *ob= OBACT; int a; short xco = 0; @@ -5280,6 +5308,48 @@ xco+= 10; } + /* Vertex groups */ + if(G.obedit && (G.obedit->type == OB_MESH)) { + uiBlockBeginAlign(block); + + uiDefIconButBitS(block, TOG, V3D_VERTEX_EDIT, B_REDR, ICON_SNAP_GEO,xco,0,XIC,YIC, &G.vd->flag2, 0, 0, 0, 0, "Edit Vertex Groups"); /* TODO: icon */ + xco+= XIC; + + if(G.vd->flag2 & V3D_VERTEX_EDIT) { + bDeformGroup *defGroup; + static float editbutvweight= 1; /* was global in buttons_editing.c before! */ + int defCount; + char *str= get_vertexgroup_menustr(ob); + + //strcpy(str, "Vertex Group%t|ADD NEW %x32767"); + defCount= BLI_countlist(&ob->defbase); + + bt= uiDefButS(block, MENU, B_MAKEDISP, str,xco,0,XIC,YIC, (short *)&ob->actdef, 1, defCount, 0, 0, "Browses available vertex groups"); /* should contain ADD NEW too! */ + uiButSetFunc(bt, update_selection_cb, NULL, NULL); + xco+= XIC; + + if(ob->actdef) { + defGroup = BLI_findlink(&ob->defbase, ob->actdef-1); + bt= uiDefBut(block, TEX, REDRAWBUTSEDIT,"",xco,0,100,YIC, defGroup->name, 0, 31, 0, 0, "Displays current vertex group name. Click to change. (Match bone name for deformation.)"); + uiButSetFunc(bt, verify_vertexgroup_name_func, defGroup, NULL); + uiButSetCompleteFunc(bt, autocomplete_vgroup, (void *)ob); + xco+= 100; + + uiDefButF(block, NUM, REDRAWVIEW3D, "", xco,0,3*XIC,YIC, &editbutvweight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength"); + xco+= 3*XIC; + } + + bt= uiDefIconBut(block, BUT, B_NOP, ICON_X,xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Delete vertex group"); + uiButSetFunc(bt, delete_current_vgroup_cb, ob, NULL); + xco+= XIC; + + MEM_freeN(str); + } + + uiBlockEndAlign(block); + xco+= 10; + } + /* selection modus */ if(G.obedit && (G.obedit->type == OB_MESH)) { uiBlockBeginAlign(block); Index: source/blender/src/editmesh_mods.c =================================================================== --- source/blender/src/editmesh_mods.c (revision 11461) +++ source/blender/src/editmesh_mods.c (working copy) @@ -73,6 +73,7 @@ #include "BKE_verse.h" #endif +#include "BIF_editdeform.h" #include "BIF_editmesh.h" #include "BIF_resources.h" #include "BIF_gl.h" @@ -1668,6 +1669,12 @@ EM_selectmode_flush(); countall(); + /* update active vertex group */ + if(G.vd->flag2 & V3D_VERTEX_EDIT) { + remove_verts_defgroup(1); + assign_verts_defgroup(); /* gives error in case no verts are selected -> remove error? */ + } + allqueue(REDRAWVIEW3D, 0); }