Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2007-05-30 14:36:17 +0400
committerJoshua Leung <aligorith@gmail.com>2007-05-30 14:36:17 +0400
commit024485b9b8a1ad6a4e5e72665537b826f73ee86a (patch)
tree0ce75ea8a33392e801b5b073f48b01f130ddf76e /source
parent86ff85932b14fe5005e383b43365319fd741b66e (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')
-rw-r--r--source/blender/include/BIF_editdeform.h3
-rw-r--r--source/blender/src/editdeform.c97
-rw-r--r--source/blender/src/space.c17
3 files changed, 115 insertions, 2 deletions
diff --git a/source/blender/include/BIF_editdeform.h b/source/blender/include/BIF_editdeform.h
index 69f03652887..2a8f43c14e7 100644
--- a/source/blender/include/BIF_editdeform.h
+++ b/source/blender/include/BIF_editdeform.h
@@ -67,5 +67,8 @@ void vertexgroup_select_by_name(struct Object *ob, char *name);
extern void object_apply_deform(struct Object *ob);
+void vgroup_assign_with_menu(void);
+void vgroup_operation_with_menu(void);
+
#endif
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 ********** */
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index a528fd260ff..ec43d55a2bd 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -97,6 +97,7 @@
#include "BIF_drawscript.h"
#include "BIF_editarmature.h"
#include "BIF_editconstraint.h"
+#include "BIF_editdeform.h"
#include "BIF_editfont.h"
#include "BIF_editgroup.h"
#include "BIF_editkey.h"
@@ -1835,8 +1836,20 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case GKEY:
- if(G.qual == LR_CTRLKEY)
- group_operation_with_menu();
+ if((G.qual == LR_CTRLKEY)) {
+ 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))
if(G.obedit) {
if(G.obedit->type==OB_MESH)