[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31515] trunk/blender/source/blender: possible fix [#23331] Hidden Bones Contribute to Axis Normal

Campbell Barton ideasman42 at gmail.com
Sun Aug 22 12:52:30 CEST 2010


Revision: 31515
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31515
Author:   campbellbarton
Date:     2010-08-22 12:52:30 +0200 (Sun, 22 Aug 2010)

Log Message:
-----------
possible fix [#23331] Hidden Bones Contribute to Axis Normal
cant redo this bug but noticed a number of places where bone selection/hidden state isn't being set properly.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/space_outliner/outliner.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/editors/transform/transform_manipulator.c

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2010-08-22 10:35:25 UTC (rev 31514)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2010-08-22 10:52:30 UTC (rev 31515)
@@ -1130,8 +1130,8 @@
 		 * rather than just chopping and adding numbers, 
 		 * shave off the end chars until we have a unique name.
 		 * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */
-		if (nr==0 && name[left_len]== left[left_len]) {
-			int len = strlen(name)-1;
+		if (nr==0 && name[left_len]== '\0') {
+			int len = left_len-1;
 			idtest= is_dupid(lb, id, name);
 			
 			while (idtest && len> 1) {

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2010-08-22 10:35:25 UTC (rev 31514)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2010-08-22 10:52:30 UTC (rev 31515)
@@ -5275,6 +5275,7 @@
 	if (arm->layer & bone->layer) {
 		if (bone->flag & BONE_SELECTED) {
 			bone->flag |= BONE_HIDDEN_P;
+			bone->flag &= ~BONE_SELECTED;
 			if(arm->act_bone==bone)
 				arm->act_bone= NULL;
 		}

Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner.c	2010-08-22 10:35:25 UTC (rev 31514)
+++ trunk/blender/source/blender/editors/space_outliner/outliner.c	2010-08-22 10:52:30 UTC (rev 31515)
@@ -1554,10 +1554,10 @@
 void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
 	Base *base= (Base *)te->directdata;
-	
-	if(base==NULL) base= object_in_scene((Object *)tselem->id, scene);
-	if(base) {
-		base->object->restrictflag^=OB_RESTRICT_VIEW;
+	if(base || (base= object_in_scene((Object *)tselem->id, scene))) {
+		if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) {
+			ED_base_object_select(base, BA_DESELECT);
+		}
 	}
 }
 
@@ -1883,8 +1883,8 @@
 	}
 	
 	/* find associated base in current scene */
-	for(base= FIRSTBASE; base; base= base->next) 
-		if(base->object==ob) break;
+	base= object_in_scene(ob, scene);
+
 	if(base) {
 		if(set==2) {
 			/* swap select */
@@ -1894,12 +1894,8 @@
 				ED_base_object_select(base, BA_SELECT);
 		}
 		else {
-			Base *b;
 			/* deleselect all */
-			for(b= FIRSTBASE; b; b= b->next) {
-				b->flag &= ~SELECT;
-				b->object->flag= b->flag;
-			}
+			scene_deselect_all(scene);
 			ED_base_object_select(base, BA_SELECT);
 		}
 		if(C)
@@ -4835,7 +4831,6 @@
 
 static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
 {
-	Base *base;
 	Scene *scene = (Scene *)poin;
 	Object *ob = (Object *)poin2;
 	Object *obedit= CTX_data_edit_object(C);
@@ -4851,15 +4846,9 @@
 	
 	/* deselect objects that are invisible */
 	if (ob->restrictflag & OB_RESTRICT_VIEW) {
-	
 		/* Ouch! There is no backwards pointer from Object to Base, 
 		 * so have to do loop to find it. */
-		for(base= FIRSTBASE; base; base= base->next) {
-			if(base->object==ob) {
-				base->flag &= ~SELECT;
-				base->object->flag= base->flag;
-			}
-		}
+		ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT);
 	}
 	WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
 
@@ -4867,21 +4856,14 @@
 
 static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
 {
-	Base *base;
 	Scene *scene = (Scene *)poin;
 	Object *ob = (Object *)poin2;
 	
 	/* if select restriction has just been turned on */
 	if (ob->restrictflag & OB_RESTRICT_SELECT) {
-	
 		/* Ouch! There is no backwards pointer from Object to Base, 
 		 * so have to do loop to find it. */
-		for(base= FIRSTBASE; base; base= base->next) {
-			if(base->object==ob) {
-				base->flag &= ~SELECT;
-				base->object->flag= base->flag;
-			}
-		}
+		ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT);
 	}
 	WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
 
@@ -4908,10 +4890,21 @@
 
 static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
 {
+	Bone *bone= (Bone *)poin2;
+	if(bone && (bone->flag & BONE_HIDDEN_P))
+		bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
 	WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
 }
 
+static void restrictbutton_ebone_cb(bContext *C, void *poin, void *poin2)
+{
+	EditBone *ebone= (EditBone *)poin2;
+	if(ebone && (ebone->flag & BONE_HIDDEN_A))
+		ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
 
+	WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
+}
+
 static int group_restrict_flag(Group *gr, int flag)
 {
 	GroupObject *gob;
@@ -5195,7 +5188,7 @@
 				uiBlockSetEmboss(block, UI_EMBOSSN);
 				bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, 
 						(int)ar->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);
+				uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone);
 				
 				bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, 
 						(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
@@ -5207,11 +5200,11 @@
 				uiBlockSetEmboss(block, UI_EMBOSSN);
 				bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, 
 						(int)ar->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);
+				uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone);
 				
 				bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, 
 						(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
-				uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
+				uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL);
 			}
 		}
 		

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-08-22 10:35:25 UTC (rev 31514)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-08-22 10:52:30 UTC (rev 31515)
@@ -647,7 +647,8 @@
 	}
 }
 
-/* sets transform flags in the bones, returns total */
+/* sets transform flags in the bones
+ * returns total number of bones with BONE_TRANSFORM */
 int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 {
 	bArmature *arm= ob->data;

Modified: trunk/blender/source/blender/editors/transform/transform_manipulator.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_manipulator.c	2010-08-22 10:35:25 UTC (rev 31514)
+++ trunk/blender/source/blender/editors/transform/transform_manipulator.c	2010-08-22 10:52:30 UTC (rev 31515)
@@ -288,7 +288,7 @@
 			bArmature *arm= obedit->data;
 			EditBone *ebo;
 			for (ebo= arm->edbo->first; ebo; ebo=ebo->next){
-				if(ebo->layer & arm->layer) {
+				if(ebo->layer & arm->layer && !(ebo->flag & BONE_HIDDEN_A)) {
 					if (ebo->flag & BONE_TIPSEL) {
 						calc_tw_center(scene, ebo->tail);
 						totsel++;





More information about the Bf-blender-cvs mailing list