[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17653] branches/animsys2/source/blender: AnimSys2: Bones can be made unselectable in the outliner.c

Joshua Leung aligorith at gmail.com
Sun Nov 30 23:13:20 CET 2008


Revision: 17653
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17653
Author:   aligorith
Date:     2008-11-30 23:13:20 +0100 (Sun, 30 Nov 2008)

Log Message:
-----------
AnimSys2: Bones can be made unselectable in the outliner.c

Currently, this only works for PoseChannels (i.e. bones in Pose Mode). Also, added these settings to the toggle/enable/disable setting tools.

Modified Paths:
--------------
    branches/animsys2/source/blender/makesdna/DNA_armature_types.h
    branches/animsys2/source/blender/src/editarmature.c
    branches/animsys2/source/blender/src/outliner.c

Modified: branches/animsys2/source/blender/makesdna/DNA_armature_types.h
===================================================================
--- branches/animsys2/source/blender/makesdna/DNA_armature_types.h	2008-11-30 20:18:55 UTC (rev 17652)
+++ branches/animsys2/source/blender/makesdna/DNA_armature_types.h	2008-11-30 22:13:20 UTC (rev 17653)
@@ -156,6 +156,7 @@
 	BONE_DRAWWIRE				= (1<<17),	/* bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */
 	BONE_NO_CYCLICOFFSET		= (1<<18),	/* when no parent, bone will not get cyclic offset */
 	BONE_EDITMODE_LOCKED		= (1<<19),	/* bone transforms are locked in EditMode */
+	BONE_UNSELECTABLE			= (1<<20),	/* bone cannot be selected */
 } eBone_Flag;
 
 #endif

Modified: branches/animsys2/source/blender/src/editarmature.c
===================================================================
--- branches/animsys2/source/blender/src/editarmature.c	2008-11-30 20:18:55 UTC (rev 17652)
+++ branches/animsys2/source/blender/src/editarmature.c	2008-11-30 22:13:20 UTC (rev 17653)
@@ -1061,9 +1061,9 @@
 	Object *ob= base->object;
 	Bone *bone;
 	EditBone *ebone;
-	void *firstunSel=NULL, *firstSel=NULL, *data;
+	void *firstunSel=NULL, *firstSel=NULL, *data=NULL;
 	unsigned int hitresult;
-	short i, takeNext=0, sel;
+	short i, takeNext=0, sel=0;
 	
 	for (i=0; i< hits; i++){
 		hitresult = buffer[3+(i*4)];
@@ -1077,27 +1077,42 @@
 					/* no singular posemode, so check for correct object */
 					if(base->selcol == (hitresult & 0xFFFF)) {
 						bone = get_indexed_bone(ob, hitresult);
-
-						if (findunsel)
-							sel = (bone->flag & BONE_SELECTED);
-						else
-							sel = !(bone->flag & BONE_SELECTED);
 						
-						data = bone;
+						/* only include if selectable */
+						if ((bone->flag & BONE_UNSELECTABLE)==0) {
+							if (findunsel)
+								sel = (bone->flag & BONE_SELECTED);
+							else
+								sel = !(bone->flag & BONE_SELECTED);
+							
+							data = bone;
+						}
+						else {
+							data= NULL;
+							sel= 0;
+						}
 					}
 					else {
 						data= NULL;
 						sel= 0;
 					}
 				}
-				else{
+				else {
 					ebone = BLI_findlink(&G.edbo, hitresult);
-					if (findunsel)
-						sel = (ebone->flag & BONE_SELECTED);
-					else
-						sel = !(ebone->flag & BONE_SELECTED);
 					
-					data = ebone;
+					/* only include if selectable */
+					if ((ebone->flag & BONE_UNSELECTABLE)==0) {
+						if (findunsel)
+							sel = (ebone->flag & BONE_SELECTED);
+						else
+							sel = !(ebone->flag & BONE_SELECTED);
+						
+						data = ebone;
+					}
+					else {
+						data= NULL;
+						sel= 0;
+					}
 				}
 				
 				if(data) {
@@ -1266,11 +1281,11 @@
 	
 	/* get flag to set (sync these with the ones used in eBone_Flag */
 	if (mode == 2)
-		flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
+		flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6|Unselectable %x7");
 	else if (mode == 1)
-		flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
+		flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6|Unselectable %x7");
 	else
-		flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
+		flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6|Unselectable %x7");
 	switch (flag) {
 		case 1: 	flag = BONE_DRAWWIRE; 	break;
 		case 2:		flag = BONE_NO_DEFORM; break;
@@ -1278,6 +1293,7 @@
 		case 4:		flag = BONE_HINGE; break;
 		case 5:		flag = BONE_NO_SCALE; break;
 		case 6: 	flag = BONE_EDITMODE_LOCKED; break;
+		case 7:		flag = BONE_UNSELECTABLE; break;
 		default:	return;
 	}
 	

Modified: branches/animsys2/source/blender/src/outliner.c
===================================================================
--- branches/animsys2/source/blender/src/outliner.c	2008-11-30 20:18:55 UTC (rev 17652)
+++ branches/animsys2/source/blender/src/outliner.c	2008-11-30 22:13:20 UTC (rev 17653)
@@ -3985,6 +3985,11 @@
 						(int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
 				uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
 				uiButSetFlag(bt, UI_NO_HILITE);
+				
+				bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, REDRAWALL, ICON_RESTRICT_SELECT_OFF, 
+						(int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selectablility in the 3D View");
+				uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
+				uiButSetFlag(bt, UI_NO_HILITE);
 			}
 			else if(tselem->type==TSE_EBONE)  {
 				EditBone *ebone= (EditBone *)te->directdata;
@@ -3994,6 +3999,12 @@
 						(int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
 				uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
 				uiButSetFlag(bt, UI_NO_HILITE);
+				
+					// FIXME: currently, doesn't work for editbones yet due to editbone-point tests
+				//bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, REDRAWALL, ICON_RESTRICT_SELECT_OFF, 
+				//		(int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selectablility in the 3D View");
+				//uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
+				//uiButSetFlag(bt, UI_NO_HILITE);
 			}
 		}
 		





More information about the Bf-blender-cvs mailing list