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.
This commit is contained in:
@@ -67,5 +67,8 @@ void vertexgroup_select_by_name(struct Object *ob, char *name);
|
|||||||
|
|
||||||
extern void object_apply_deform(struct Object *ob);
|
extern void object_apply_deform(struct Object *ob);
|
||||||
|
|
||||||
|
void vgroup_assign_with_menu(void);
|
||||||
|
void vgroup_operation_with_menu(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,16 @@
|
|||||||
#include "BKE_mesh.h"
|
#include "BKE_mesh.h"
|
||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
|
|
||||||
|
#include "BIF_interface.h"
|
||||||
#include "BIF_editdeform.h"
|
#include "BIF_editdeform.h"
|
||||||
#include "BIF_editmesh.h"
|
#include "BIF_editmesh.h"
|
||||||
|
#include "BIF_space.h"
|
||||||
#include "BIF_toolbox.h"
|
#include "BIF_toolbox.h"
|
||||||
|
|
||||||
#include "BSE_edit.h"
|
#include "BSE_edit.h"
|
||||||
|
|
||||||
|
#include "butspace.h"
|
||||||
|
#include "mydevice.h"
|
||||||
#include "editmesh.h"
|
#include "editmesh.h"
|
||||||
#include "multires.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 */
|
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 ********** */
|
/* ******************* other deform edit stuff ********** */
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
#include "BIF_drawscript.h"
|
#include "BIF_drawscript.h"
|
||||||
#include "BIF_editarmature.h"
|
#include "BIF_editarmature.h"
|
||||||
#include "BIF_editconstraint.h"
|
#include "BIF_editconstraint.h"
|
||||||
|
#include "BIF_editdeform.h"
|
||||||
#include "BIF_editfont.h"
|
#include "BIF_editfont.h"
|
||||||
#include "BIF_editgroup.h"
|
#include "BIF_editgroup.h"
|
||||||
#include "BIF_editkey.h"
|
#include "BIF_editkey.h"
|
||||||
@@ -1835,8 +1836,20 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case GKEY:
|
case GKEY:
|
||||||
if(G.qual == LR_CTRLKEY)
|
if((G.qual == LR_CTRLKEY)) {
|
||||||
group_operation_with_menu();
|
if(G.obedit) {
|
||||||
|
if(ELEM(G.obedit->type, OB_MESH, OB_LATTICE))
|
||||||
|
vgroup_assign_with_menu();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
group_operation_with_menu();
|
||||||
|
}
|
||||||
|
else if((G.qual == (LR_CTRLKEY|LR_SHIFTKEY))) {
|
||||||
|
if(G.obedit) {
|
||||||
|
if(ELEM(G.obedit->type, OB_MESH, OB_LATTICE))
|
||||||
|
vgroup_operation_with_menu();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if((G.qual==LR_SHIFTKEY))
|
else if((G.qual==LR_SHIFTKEY))
|
||||||
if(G.obedit) {
|
if(G.obedit) {
|
||||||
if(G.obedit->type==OB_MESH)
|
if(G.obedit->type==OB_MESH)
|
||||||
|
|||||||
Reference in New Issue
Block a user