[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18820] branches/blender2.5/blender/source /blender: 2.5 - Bugfixes for Pose 'Clear' Operators

Joshua Leung aligorith at gmail.com
Thu Feb 5 06:51:22 CET 2009


Revision: 18820
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18820
Author:   aligorith
Date:     2009-02-05 06:51:21 +0100 (Thu, 05 Feb 2009)

Log Message:
-----------
2.5 - Bugfixes for Pose 'Clear' Operators 

* Fixed context iterators for PoseChannels. The actual selection test was missing (but layer visibility was getting checked). Also added check for hidden bones here too.

* Removed unnecessary defines added by mfoxdogg in BKE_context.h

* Removed the old hacks in 'Clear ...' operators for ensuring that object animation (ipos/actions) don't overwrite poses. These are no longer necessary, since normal animation calculation is only done in a separate step on frame-changes now.
* Removed the manual checks for layer visibility from 'Clear ...' operators, since that's taken care of by context iterators.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h
    branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h	2009-02-05 05:13:08 UTC (rev 18819)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h	2009-02-05 05:51:21 UTC (rev 18820)
@@ -40,8 +40,6 @@
 struct ListBase;
 struct Main;
 struct Object;
-struct Bone;
-struct bArmature;
 struct PointerRNA;
 struct ReportList;
 struct Scene;

Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-02-05 05:13:08 UTC (rev 18819)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-02-05 05:51:21 UTC (rev 18820)
@@ -33,7 +33,7 @@
 
 /* editarmature.c */
 void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep);
-EditBone *armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo);
+EditBone *armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators
 
 void POSE_OT_hide(struct wmOperatorType *ot);
 void POSE_OT_reveil(struct wmOperatorType *ot);

Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c	2009-02-05 05:13:08 UTC (rev 18819)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c	2009-02-05 05:51:21 UTC (rev 18820)
@@ -4012,32 +4012,27 @@
 	}
 } 
 /* ************* Clear Pose *****************************/
+
 static int pose_clear_scale_exec(bContext *C, wmOperator *op) 
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob= CTX_data_active_object(C);
-	bArmature *arm= ob->data;
 	
 	/* only clear those channels that are not locked */
-	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
-		if (arm->layer & pchan->bone->layer) {
-			if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
-				pchan->size[0]= 1.0f;
-			if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
-				pchan->size[1]= 1.0f;
-			if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
-				pchan->size[2]= 1.0f;
-			/* the current values from IPO's may not be zero, so tag as unkeyed */
-			pchan->bone->flag |= BONE_UNKEYED;
-		}
+	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
+		if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
+			pchan->size[0]= 1.0f;
+		if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
+			pchan->size[1]= 1.0f;
+		if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
+			pchan->size[2]= 1.0f;
+			
+		/* the current values from IPO's may not be zero, so tag as unkeyed */
+		//pchan->bone->flag |= BONE_UNKEYED;
 	}
 	CTX_DATA_END;
-		
+	
 	DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-	/* no update for this object, this will execute the action again */
-	/* is weak... like for ipo editing which uses ctime now... */
-	where_is_pose (scene, ob);
-	ob->recalc= 0;
 
 	/* note, notifier might evolve */
 	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
@@ -4064,28 +4059,22 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob= CTX_data_active_object(C);
-	bArmature *arm= ob->data;
 	
 	/* only clear those channels that are not locked */
-	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
-		if (arm->layer & pchan->bone->layer) {
-			if ((pchan->protectflag & OB_LOCK_LOCX)==0)
-				pchan->loc[0]= 0.0f;
-			if ((pchan->protectflag & OB_LOCK_LOCY)==0)
-				pchan->loc[1]= 0.0f;
-			if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
-				pchan->loc[2]= 0.0f;
-			/* the current values from IPO's may not be zero, so tag as unkeyed */
-			pchan->bone->flag |= BONE_UNKEYED;
-		}
+	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
+		if ((pchan->protectflag & OB_LOCK_LOCX)==0)
+			pchan->loc[0]= 0.0f;
+		if ((pchan->protectflag & OB_LOCK_LOCY)==0)
+			pchan->loc[1]= 0.0f;
+		if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
+			pchan->loc[2]= 0.0f;
+			
+		/* the current values from IPO's may not be zero, so tag as unkeyed */
+		//pchan->bone->flag |= BONE_UNKEYED;
 	}
 	CTX_DATA_END;
-		
+	
 	DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-	/* no update for this object, this will execute the action again */
-	/* is weak... like for ipo editing which uses ctime now... */
-	where_is_pose (scene, ob);
-	ob->recalc= 0;
 
 	/* note, notifier might evolve */
 	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
@@ -4112,46 +4101,55 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob= CTX_data_active_object(C);
-	bArmature *arm= ob->data;
 	
 	/* only clear those channels that are not locked */
-	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
-		if (arm->layer & pchan->bone->layer) {
-			if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
-				float eul[3], oldeul[3], quat1[4];
-					
+	CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) {
+		if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
+			float eul[3], oldeul[3], quat1[4];
+			
+			if (pchan->rotmode == PCHAN_ROT_QUAT) {
 				QUATCOPY(quat1, pchan->quat);
 				QuatToEul(pchan->quat, oldeul);
-				eul[0]= eul[1]= eul[2]= 0.0f;
-				
-				if (pchan->protectflag & OB_LOCK_ROTX)
-					eul[0]= oldeul[0];
-				if (pchan->protectflag & OB_LOCK_ROTY)
-					eul[1]= oldeul[1];
-				if (pchan->protectflag & OB_LOCK_ROTZ)
-					eul[2]= oldeul[2];
-							
+			}
+			else {
+				VECCOPY(oldeul, pchan->eul);
+			}
+			eul[0]= eul[1]= eul[2]= 0.0f;
+			
+			if (pchan->protectflag & OB_LOCK_ROTX)
+				eul[0]= oldeul[0];
+			if (pchan->protectflag & OB_LOCK_ROTY)
+				eul[1]= oldeul[1];
+			if (pchan->protectflag & OB_LOCK_ROTZ)
+				eul[2]= oldeul[2];
+			
+			if (pchan->rotmode == PCHAN_ROT_QUAT) {
 				EulToQuat(eul, pchan->quat);
 				/* quaternions flip w sign to accumulate rotations correctly */
 				if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
 					QuatMulf(pchan->quat, -1.0f);
 				}
-			}						
-			else { 
-				pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F; 
-				pchan->quat[0]=1.0F;
 			}
-			/* the current values from IPO's may not be zero, so tag as unkeyed */
-			pchan->bone->flag |= BONE_UNKEYED;
+			else {
+				VECCOPY(pchan->eul, eul);
+			}
+		}						
+		else { 
+			if (pchan->rotmode == PCHAN_ROT_QUAT) {
+				pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f; 
+				pchan->quat[0]= 1.0f;
+			}
+			else {
+				pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 0.0f;
+			}
 		}
+		
+		/* the current values from IPO's may not be zero, so tag as unkeyed */
+		//pchan->bone->flag |= BONE_UNKEYED;
 	}
 	CTX_DATA_END;
-		
+	
 	DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-	/* no update for this object, this will execute the action again */
-	/* is weak... like for ipo editing which uses ctime now... */
-	where_is_pose (scene, ob);
-	ob->recalc= 0;
 
 	/* note, notifier might evolve */
 	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-02-05 05:13:08 UTC (rev 18819)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-02-05 05:51:21 UTC (rev 18820)
@@ -507,8 +507,10 @@
 		
 		if (obact && arm) {
 			for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
-				if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
-					CTX_data_list_add(result, pchan);
+				/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
+				if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+					if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) 
+						CTX_data_list_add(result, pchan);
 				}
 			}
 			





More information about the Bf-blender-cvs mailing list