[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19729] branches/blender2.5/blender/source /blender: PoseLib: Interactively browsing poses with Ctrl-L now mostly works again

Joshua Leung aligorith at gmail.com
Wed Apr 15 14:04:10 CEST 2009


Revision: 19729
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19729
Author:   aligorith
Date:     2009-04-15 14:04:10 +0200 (Wed, 15 Apr 2009)

Log Message:
-----------
PoseLib: Interactively browsing poses with Ctrl-L now mostly works again

This (most important part) of PoseLib now mostly works again. It even works for PoseLibs saved with the old animation system.

However, there are a few annoying bugs that need to be addressed still:
* When 'confirming' poses, the pose changes to the next one before PoseLib exits. I'm not quite sure where this is coming from yet...
* There are still a few minor bugs in the search-string code that will get ironed out
* AutoKeyframing doesn't work yet for this

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c
    branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
    branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
    branches/blender2.5/blender/source/blender/editors/armature/poselib.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c	2009-04-15 10:57:28 UTC (rev 19728)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c	2009-04-15 12:04:10 UTC (rev 19729)
@@ -1076,6 +1076,9 @@
 				char *path = NULL;
 				int arraylen, i;
 				
+				/* set initial group name */
+				groupname= (cks->id) ? cks->id->name : NULL;
+				
 				/* construct the path */
 				// FIXME: this currently only works with a few hardcoded cases
 				if ((ksp->templates & KSP_TEMPLATE_PCHAN) && (cks->pchan)) {
@@ -1083,12 +1086,18 @@
 					BLI_dynstr_append(pathds, "pose.pose_channels[\"");
 					BLI_dynstr_append(pathds, cks->pchan->name);
 					BLI_dynstr_append(pathds, "\"]");
+					
+					/* override default group name */
+					groupname= cks->pchan->name;
 				}
 				if ((ksp->templates & KSP_TEMPLATE_CONSTRAINT) && (cks->con)) {
 					/* add basic constraint path access */
 					BLI_dynstr_append(pathds, "constraints[\"");
 					BLI_dynstr_append(pathds, cks->con->name);
 					BLI_dynstr_append(pathds, "\"]");
+					
+					/* override default group name */
+					groupname= cks->con->name;
 				}
 				{
 					/* add property stored in KeyingSet Path */
@@ -1101,13 +1110,17 @@
 					BLI_dynstr_free(pathds);
 				}
 				
-				/* get pointer to name of group to add channels to */
-				if (ksp->groupmode == KSP_GROUP_NONE)
-					groupname= NULL;
-				else if (ksp->groupmode == KSP_GROUP_KSNAME)
-					groupname= ks->name;
-				else
-					groupname= ksp->group;
+				/* if the group name settings have not been overriden for the entire KeyingSet,
+				 * get pointer to name of group to add channels to 
+				 */
+				if ((ks->flag & KEYINGSET_GROUPNAMES_OVERRIDE)==0) {
+					if (ksp->groupmode == KSP_GROUP_NONE)
+						groupname= NULL;
+					else if (ksp->groupmode == KSP_GROUP_KSNAME)
+						groupname= ks->name;
+					else
+						groupname= ksp->group;
+				}
 				
 				/* init arraylen and i - arraylen should be greater than i so that
 				 * normal non-array entries get keyframed correctly

Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-04-15 10:57:28 UTC (rev 19728)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-04-15 12:04:10 UTC (rev 19729)
@@ -73,6 +73,7 @@
 void POSELIB_OT_pose_add(struct wmOperatorType *ot);
 void POSELIB_OT_pose_remove(struct wmOperatorType *ot);
 void POSELIB_OT_pose_rename(struct wmOperatorType *ot);
+void POSELIB_OT_browse_interactive(struct wmOperatorType *ot);
 
 /* editarmature.c */
 struct bArmature;

Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c	2009-04-15 10:57:28 UTC (rev 19728)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c	2009-04-15 12:04:10 UTC (rev 19729)
@@ -155,6 +155,8 @@
 	WM_operatortype_append(POSE_OT_select_linked);
 	
 	/* POSELIB */
+	WM_operatortype_append(POSELIB_OT_browse_interactive);
+	
 	WM_operatortype_append(POSELIB_OT_pose_add);
 	WM_operatortype_append(POSELIB_OT_pose_remove);
 	WM_operatortype_append(POSELIB_OT_pose_rename);
@@ -258,6 +260,8 @@
 	
 	/* Pose -> PoseLib ------------- */
 	/* only set in posemode, by space_view3d listener */
+	WM_keymap_add_item(keymap, "POSELIB_OT_browse_interactive", LKEY, KM_PRESS, KM_CTRL, 0);
+	
 	WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0);
 	WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0);
 	WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);

Modified: branches/blender2.5/blender/source/blender/editors/armature/poselib.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poselib.c	2009-04-15 10:57:28 UTC (rev 19728)
+++ branches/blender2.5/blender/source/blender/editors/armature/poselib.c	2009-04-15 12:04:10 UTC (rev 19729)
@@ -86,18 +86,9 @@
 
 static void BIF_undo_push() {}
 static void error() {}
-static int qtest() {return 0;}
-static int extern_qread_ext() {return 0;}
-static void persptoetsen() {}
-static void headerprint() {}
 
-static void remake_action_ipos() {} // xxx depreceated
-//static void verify_pchan2achan_grouping() {} // xxx depreceated
 static void action_set_activemarker() {}
 
-/* ******* XXX ********** */
-
-
 /* ************************************************************* */
 /* == POSE-LIBRARY TOOL FOR BLENDER == 
  *	
@@ -222,6 +213,7 @@
 /* This tool automagically generates/validates poselib data so that it corresponds to the data 
  * in the action. This is for use in making existing actions usable as poselibs.
  */
+// TODO: operatorfy me!
 void poselib_validate_act (bAction *act)
 {
 	ListBase keys = {NULL, NULL};
@@ -401,6 +393,10 @@
 	/* make sure we've got KeyingSets to use */
 	poselib_get_builtin_keyingsets();
 	
+	/* turn on group-name overrides temporarily (only here) */
+	poselib_ks_locrotscale->flag |= KEYINGSET_GROUPNAMES_OVERRIDE;
+	poselib_ks_locrotscale2->flag |= KEYINGSET_GROUPNAMES_OVERRIDE;
+	
 	/* init common-key-source for use by KeyingSets */
 	memset(&cks, 0, sizeof(bCommonKeySrc));
 	cks.id= &ob->id;
@@ -422,6 +418,10 @@
 		}
 	}
 	
+	/* turn off group-name overrides so they don't affect the KeyingSets when used elsewhere */
+	poselib_ks_locrotscale->flag &= ~KEYINGSET_GROUPNAMES_OVERRIDE;
+	poselib_ks_locrotscale2->flag &= ~KEYINGSET_GROUPNAMES_OVERRIDE;
+	
 	/* store new 'active' pose number */
 	act->active_marker= BLI_countlist(&act->markers);
 	
@@ -603,7 +603,10 @@
 	ListBase backups;		/* tPoseLib_Backup structs for restoring poses */
 	ListBase searchp;		/* LinkData structs storing list of poses which match the current search-string */
 	
-	PointerRNA *rna_ptr;	/* RNA-Pointer to Object 'ob' */
+	Scene *scene;			/* active scene */
+	ScrArea *sa;			/* active area */
+	
+	PointerRNA rna_ptr;		/* RNA-Pointer to Object 'ob' */
 	Object *ob;				/* object to work on */
 	bArmature *arm;			/* object's armature data */
 	bPose *pose;			/* object's pose */
@@ -706,7 +709,7 @@
  */
 static void poselib_apply_pose (tPoseLib_PreviewData *pld)
 {
-	PointerRNA *ptr= pld->rna_ptr;
+	PointerRNA *ptr= &pld->rna_ptr;
 	bArmature *arm= pld->arm;
 	bPose *pose= pld->pose;
 	bPoseChannel *pchan;
@@ -715,13 +718,15 @@
 	
 	BeztEditData bed;
 	BeztEditFunc group_ok_cb;
-	int frame;
+	int frame= 1;
 	
 	/* get the frame */
 	if (pld->marker)
 		frame= pld->marker->frame;
 	else
 		return;	
+		
+	printf("apply pose ---> %d \n", frame);	
 	
 	/* init settings for testing groups for keyframes */
 	group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
@@ -729,10 +734,13 @@
 	bed.f1= ((float)frame) - 0.5f;
 	bed.f2= ((float)frame) + 0.5f;
 	
+	
 	/* start applying - only those channels which have a key at this point in time! */
 	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
 		/* check if group has any keyframes */
 		if (ANIM_animchanneldata_keys_bezier_loop(&bed, agrp, ALE_GROUP, NULL, group_ok_cb, NULL, 0)) {
+			printf("\tact group %s ok \n", agrp->name);
+			
 			/* has keyframe on this frame, so try to get a PoseChannel with this name */
 			pchan= get_pose_channel(pose, agrp->name);
 			
@@ -753,10 +761,13 @@
 				}
 				
 				if (ok) {
+					printf("\t\tevaluating... \n");
 					animsys_evaluate_action_group(ptr, act, agrp, NULL, (float)frame);
 				}
 			}
 		}
+		else
+			printf("\tact group %s not ok \n", agrp->name);
 	}
 }
 
@@ -766,13 +777,13 @@
 	bPose *pose= pld->pose;
 	bPoseChannel *pchan;
 	bAction *act= pld->act;
-	bActionChannel *achan;
+	bActionGroup *agrp;
 	
 	/* start tagging/keying */
-	for (achan= act->chanbase.first; achan; achan= achan->next) {
+	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
 		/* only for selected action channels */
-		if (achan->flag & ACHAN_SELECTED) {
-			pchan= get_pose_channel(pose, achan->name);
+		if (agrp->flag & AGRP_SELECTED) {
+			pchan= get_pose_channel(pose, agrp->name);
 			
 			if (pchan) {
 #if 0 // XXX old animation system	
@@ -808,11 +819,86 @@
 						pchan->bone->flag |= BONE_UNKEYED;
 				}
 #endif // XXX old animation system	
+		
 			}
 		}
 	}
 }
 
+/* Apply the relevant changes to the pose */
+static void poselib_preview_apply (bContext *C, wmOperator *op)
+{
+	tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata;
+	
+	printf("do apply(C, op) \n");
+	
+	/* only recalc pose (and its dependencies) if pose has changed */
+	if (pld->redraw == PL_PREVIEW_REDRAWALL) {
+		printf("\tupdate pose \n");
+		
+		/* don't clear pose if firsttime */
+		if ((pld->flag & PL_PREVIEW_FIRSTTIME)==0)
+			poselib_backup_restore(pld);
+		else
+			pld->flag &= ~PL_PREVIEW_FIRSTTIME;
+			
+		/* pose should be the right one to draw (unless we're temporarily not showing it) */
+		if ((pld->flag & PL_PREVIEW_SHOWORIGINAL)==0)
+			poselib_apply_pose(pld);
+		
+		/* old optimize trick... this enforces to bypass the depgraph 
+		 *	- note: code copied from transform_generics.c -> recalcData()
+		 */
+		// FIXME: shouldn't this use the builtin stuff?
+		if ((pld->arm->flag & ARM_DELAYDEFORM)==0)
+			DAG_object_flush_update(pld->scene, pld->ob, OB_RECALC_DATA);  /* sets recalc flags */
+		else
+			where_is_pose(pld->scene, pld->ob);
+	}
+	
+	/* do header print - if interactively previewing */
+	if (pld->state == PL_PREVIEW_RUNNING) {
+		if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
+			sprintf(pld->headerstr, "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again");
+			ED_area_headerprint(pld->sa, pld->headerstr);
+		}
+		else if (pld->searchstr[0]) {
+			char tempstr[65];
+			char markern[64];
+			short index;
+			
+			/* get search-string */
+			index= pld->search_cursor;
+			
+			if (IN_RANGE(index, 0, 64)) {
+				memcpy(&tempstr[0], &pld->searchstr[0], index);
+				tempstr[index]= '|';
+				memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
+			}
+			else {
+				strncpy(tempstr, pld->searchstr, 64);
+			}
+			
+			/* get marker name */
+			if (pld->marker)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list