[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13681] trunk/blender/source/blender: == Shift-G - Select Grouped menu in PoseMode ==

Joshua Leung aligorith at gmail.com
Thu Feb 14 07:31:40 CET 2008


Revision: 13681
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13681
Author:   aligorith
Date:     2008-02-14 07:31:40 +0100 (Thu, 14 Feb 2008)

Log Message:
-----------
== Shift-G - Select Grouped menu in PoseMode ==

In PoseMode, the Shift-G menu now presents options for selecting bones in the same layer or the same bone-group. 

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_poseobject.h
    trunk/blender/source/blender/src/poseobject.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/include/BIF_poseobject.h
===================================================================
--- trunk/blender/source/blender/include/BIF_poseobject.h	2008-02-14 05:00:23 UTC (rev 13680)
+++ trunk/blender/source/blender/include/BIF_poseobject.h	2008-02-14 06:31:40 UTC (rev 13681)
@@ -68,6 +68,9 @@
 void pose_remove_from_posegroups(void);
 void pgroup_operation_with_menu(void);
 
+void pose_select_grouped(short nr);
+void pose_select_grouped_menu(void);
+
 void pose_calculate_path(struct Object *ob);
 void pose_recalculate_paths(struct Object *ob);
 void pose_clear_paths(struct Object *ob);

Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c	2008-02-14 05:00:23 UTC (rev 13680)
+++ trunk/blender/source/blender/src/poseobject.c	2008-02-14 06:31:40 UTC (rev 13681)
@@ -1131,6 +1131,111 @@
 
 /* ********************************************** */
 
+static short pose_select_same_group (Object *ob)
+{
+	bPose *pose= (ob)? ob->pose : NULL;
+	bArmature *arm= (ob)? ob->data : NULL;
+	bPoseChannel *pchan, *chan;
+	short changed= 0;
+	
+	if (ELEM3(NULL, ob, pose, arm))
+		return 0;
+	
+	/* loop in loop... bad and slow! */
+	for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+		if (arm->layer & pchan->bone->layer) {
+			if (pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
+				
+				/* only if group matches (and is not selected or current bone) */
+				for (chan= ob->pose->chanbase.first; chan; chan= chan->next) {
+					if (arm->layer & chan->bone->layer) {
+						if (pchan->agrp_index == chan->agrp_index) {
+							chan->bone->flag |= BONE_SELECTED;
+							changed= 1;
+						}
+					}
+				}
+				
+			}
+		}
+	}
+	
+	return changed;
+}
+
+static short pose_select_same_layer (Object *ob)
+{
+	bPose *pose= (ob)? ob->pose : NULL;
+	bArmature *arm= (ob)? ob->data : NULL;
+	bPoseChannel *pchan;
+	short layers= 0, changed= 0;
+	
+	if (ELEM3(NULL, ob, pose, arm))
+		return 0;
+	
+	/* figure out what bones are selected */
+	for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+		if (arm->layer & pchan->bone->layer) {
+			if (pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
+				layers |= pchan->bone->layer;
+			}
+		}
+	}
+	if (layers == 0) 
+		return 0;
+		
+	/* select bones that are on same layers as layers flag */
+	for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+		if (arm->layer & pchan->bone->layer) {
+			if (layers & pchan->bone->layer) {
+				pchan->bone->flag |= BONE_SELECTED;
+				changed= 1;
+			}
+		}
+	}
+	
+	return changed;
+}
+
+
+void pose_select_grouped (short nr)
+{
+	short changed = 0;
+	
+	if (nr == 1) 		changed= pose_select_same_group(OBACT);
+	else if (nr == 2)	changed= pose_select_same_layer(OBACT);
+	
+	if (changed) {
+		countall();
+		allqueue(REDRAWVIEW3D, 0);
+		allqueue(REDRAWBUTSOBJECT, 0);
+		allqueue(REDRAWBUTSEDIT, 0);
+		allspace(REMAKEIPO, 0);
+		allqueue(REDRAWIPO, 0);
+		allqueue(REDRAWACTION, 0);
+		BIF_undo_push("Select Grouped");
+	}
+}
+
+/* Shift-G in 3D-View while in PoseMode */
+void pose_select_grouped_menu (void)
+{
+	char *str;
+	short nr;
+
+	/* make menu string */
+	str= MEM_mallocN(512, "groupmenu");
+	strcpy(str, "Select Grouped%t|In Same Group%x1|In Same Layer%x2");
+
+	/* here we go */
+	nr= pupmenu(str);
+	MEM_freeN(str);
+	
+	pose_select_grouped(nr);
+}
+
+/* ********************************************** */
+
 /* context active object */
 void pose_flip_names(void)
 {

Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c	2008-02-14 05:00:23 UTC (rev 13680)
+++ trunk/blender/source/blender/src/space.c	2008-02-14 06:31:40 UTC (rev 13681)
@@ -1962,7 +1962,7 @@
 							select_mesh_group_menu();
 					} 
 					else if(ob && (ob->flag & OB_POSEMODE))
-						puts("Shift-G menu for PoseMode - Not Implemented!");
+						pose_select_grouped_menu();
 					else
 						select_object_grouped_menu();
 				else if((G.obedit==0) && G.qual==LR_ALTKEY) {





More information about the Bf-blender-cvs mailing list