diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-05-30 14:36:17 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-05-30 14:36:17 +0400 |
commit | 024485b9b8a1ad6a4e5e72665537b826f73ee86a (patch) | |
tree | 0ce75ea8a33392e801b5b073f48b01f130ddf76e /source/blender/src/editdeform.c | |
parent | 86ff85932b14fe5005e383b43365319fd741b66e (diff) |
Patch #6759: this speeds up the vertex group editing workflow a bit.
The hotkey Ctrl-G in EditMode for Meshes and Lattices, brings up a menu giving the user options to assign/remove selected vertices to a new/the active Vertex Group.
The hotkey Ctrl-Shift-G in EditMode for Meshes and Lattices, brings up a menu giving the user options to change the active Vertex Group and delete the current Vertex Group.
Diffstat (limited to 'source/blender/src/editdeform.c')
-rw-r--r-- | source/blender/src/editdeform.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c index 305d01a8aea..7a086ed5be3 100644 --- a/source/blender/src/editdeform.c +++ b/source/blender/src/editdeform.c @@ -55,12 +55,16 @@ #include "BKE_mesh.h" #include "BKE_utildefines.h" +#include "BIF_interface.h" #include "BIF_editdeform.h" #include "BIF_editmesh.h" +#include "BIF_space.h" #include "BIF_toolbox.h" #include "BSE_edit.h" +#include "butspace.h" +#include "mydevice.h" #include "editmesh.h" #include "multires.h" @@ -788,6 +792,99 @@ void vertexgroup_select_by_name(Object *ob, char *name) ob->actdef=0; // this signals on painting to create a new one, if a bone in posemode is selected */ } +/* This function provides a shortcut for adding/removing verts from + * vertex groups. It is called by the Ctrl-G hotkey in EditMode for Meshes + * and Lattices. (currently only restricted to those two) + * It is only responsible for + */ +void vgroup_assign_with_menu(void) +{ + Object *ob= G.obedit; + int defCount; + int mode; + + /* prevent crashes */ + if (ob==NULL) return; + + defCount= BLI_countlist(&ob->defbase); + + /* give user choices of adding to current/new or removing from current */ + if (defCount && ob->actdef) + mode = pupmenu("Vertex Groups %t|Add Selected to New Group %x1|Add Selected to Active Group %x2|Remove Selected from Active Group %x3"); + else + mode= pupmenu("Vertex Groups %t|Add Selected to New Group %x1"); + + /* handle choices */ + switch (mode) { + case 1: /* add to new group */ + add_defgroup(ob); + assign_verts_defgroup(); + allqueue(REDRAWVIEW3D, 1); + BIF_undo_push("Assign to vertex group"); + break; + case 2: /* add to current group */ + assign_verts_defgroup(); + allqueue(REDRAWVIEW3D, 1); + BIF_undo_push("Assign to vertex group"); + break; + case 3: /* remove from current group */ + remove_verts_defgroup(0); + allqueue(REDRAWVIEW3D, 1); + BIF_undo_push("Remove from vertex group"); + break; + } +} + +/* This function provides a shortcut for commonly used vertex group + * functions - change weight (not implemented), change active group, delete active group, + * when Ctrl-Shift-G is used in EditMode, for Meshes and Lattices (only for now). + */ +void vgroup_operation_with_menu(void) +{ + Object *ob= G.obedit; + int defCount; + int mode; + + /* prevent crashes and useless cases */ + if (ob==NULL) return; + + defCount= BLI_countlist(&ob->defbase); + if (defCount == 0) return; + + /* give user choices of adding to current/new or removing from current */ + if (ob->actdef) + mode = pupmenu("Vertex Groups %t|Change Active Group%x1|Delete Active Group%x2"); + else + mode= pupmenu("Vertex Groups %t|Change Active Group%x1"); + + /* handle choices */ + switch (mode) { + case 1: /* change active group*/ + { + char *menustr= get_vertexgroup_menustr(ob); + short nr; + + if (menustr) { + nr= pupmenu(menustr); + + if ((nr >= 1) && (nr <= defCount)) + ob->actdef= nr; + + MEM_freeN(menustr); + } + allqueue(REDRAWBUTSALL, 0); + } + break; + case 2: /* delete active group */ + { + del_defgroup(ob); + allqueue (REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + BIF_undo_push("Delete vertex group"); + } + break; + } +} /* ******************* other deform edit stuff ********** */ |