[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27084] trunk/blender/source/blender: - respect insert available with pose copy/paste (note: autokeyframe_pose_cb_func needs to be used for all cases I think)

Campbell Barton ideasman42 at gmail.com
Mon Feb 22 16:49:40 CET 2010


Revision: 27084
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27084
Author:   campbellbarton
Date:     2010-02-22 16:49:40 +0100 (Mon, 22 Feb 2010)

Log Message:
-----------
- respect insert available with pose copy/paste (note: autokeyframe_pose_cb_func needs to be used for all cases I think)
- copy, paste ID properties with pose

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2010-02-22 15:03:13 UTC (rev 27083)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2010-02-22 15:49:40 UTC (rev 27084)
@@ -52,6 +52,7 @@
 #include "DNA_userdef_types.h"
 
 #include "BKE_anim.h"
+#include "BKE_idprop.h"
 #include "BKE_animsys.h"
 #include "BKE_action.h"
 #include "BKE_armature.h"
@@ -840,6 +841,15 @@
 void free_posebuf(void) 
 {
 	if (g_posebuf) {
+		bPoseChannel *pchan;
+
+		for (pchan= g_posebuf->chanbase.first; pchan; pchan= pchan->next) {
+			if(pchan->prop) {
+				IDP_FreeProperty(pchan->prop);
+				MEM_freeN(pchan->prop);
+			}
+		}
+
 		/* was copied without constraints */
 		BLI_freelistN(&g_posebuf->chanbase);
 		MEM_freeN(g_posebuf);
@@ -891,7 +901,8 @@
 /* Pointers to the builtin KeyingSets that we want to use */
 static KeyingSet *posePaste_ks_locrotscale = NULL;		/* the only keyingset we'll need */
 
-/* ---- */
+/* transform.h */
+extern void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
 
 static int pose_paste_exec (bContext *C, wmOperator *op)
 {
@@ -1002,33 +1013,55 @@
 					}
 				}
 				
-				if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-					/* Set keys on pose
-					 *	- KeyingSet to use depends on rotation mode 
-					 *	(but that's handled by the templates code)  
-					 */
-					// TODO: for getting the KeyingSet used, we should really check which channels were affected
-					if (posePaste_ks_locrotscale == NULL)
-						posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
-					
-					/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
-					cks.pchan= pchan;
-					
-					modify_keyframes(scene, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
-					
-					/* clear any unkeyed tags */
-					if (chan->bone)
-						chan->bone->flag &= ~BONE_UNKEYED;
+				/* ID property */
+				if(pchan->prop) {
+					IDP_FreeProperty(pchan->prop);
+					MEM_freeN(pchan->prop);
+					pchan->prop= NULL;
 				}
-				else {
-					/* add unkeyed tags */
-					if (chan->bone)
-						chan->bone->flag |= BONE_UNKEYED;
+
+				if(chan->prop) {
+					pchan->prop= IDP_CopyProperty(chan->prop);
 				}
+
+				/* auto key, TODO, fix up this INSERTAVAIL vs all other cases */
+				if (IS_AUTOKEY_FLAG(INSERTAVAIL) == 0) { /* deal with this case later */
+					if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+
+						/* Set keys on pose
+						 *	- KeyingSet to use depends on rotation mode
+						 *	(but that's handled by the templates code)
+						 */
+						// TODO: for getting the KeyingSet used, we should really check which channels were affected
+						if (posePaste_ks_locrotscale == NULL)
+							posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+
+						/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
+						cks.pchan= pchan;
+
+						modify_keyframes(scene, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+
+						/* clear any unkeyed tags */
+						if (chan->bone)
+							chan->bone->flag &= ~BONE_UNKEYED;
+					}
+					else {
+						/* add unkeyed tags */
+						if (chan->bone)
+							chan->bone->flag |= BONE_UNKEYED;
+					}
+				}
 			}
 		}
 	}
 
+	if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
+		View3D *v3d= CTX_wm_view3d(C);
+		autokeyframe_pose_cb_func(C, scene, v3d, ob, TFM_TRANSLATION, 0);
+		autokeyframe_pose_cb_func(C, scene, v3d, ob, TFM_ROTATION, 0);
+		autokeyframe_pose_cb_func(C, scene, v3d, ob, TFM_TIME_SCALE, 0);
+	}
+
 	/* Update event for pose and deformation children */
 	DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 	

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-02-22 15:03:13 UTC (rev 27083)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-02-22 15:49:40 UTC (rev 27084)
@@ -456,8 +456,10 @@
 #define		AUTOKEY_MODE_NORMAL		3
 #define		AUTOKEY_MODE_EDITKEYS	5
 
-/* Auto-Keying flag */
-	/* U.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days) */
+/* Auto-Keying flag
+ * U.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days)
+ * note: AUTOKEY_FLAG_* is used with a macro, search for lines like IS_AUTOKEY_FLAG(INSERTAVAIL)
+ */
 #define		AUTOKEY_FLAG_INSERTAVAIL	(1<<0)
 #define		AUTOKEY_FLAG_INSERTNEEDED	(1<<1)
 #define		AUTOKEY_FLAG_AUTOMATKEY		(1<<2)





More information about the Bf-blender-cvs mailing list