[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24306] trunk/blender/source/blender: change to insert_keyframe() so an array index of -1 keys all arrays indices

Campbell Barton ideasman42 at gmail.com
Wed Nov 4 15:06:11 CET 2009


Revision: 24306
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24306
Author:   campbellbarton
Date:     2009-11-04 15:06:10 +0100 (Wed, 04 Nov 2009)

Log Message:
-----------
change to insert_keyframe() so an array index of -1 keys all arrays indices
made this default for python so you can do...
 pose_bone.keyframe_insert("location")

rather then
 pose_bone.keyframe_insert("location", 0)
 pose_bone.keyframe_insert("location", 1)
 pose_bone.keyframe_insert("location", 2)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2009-11-04 12:09:02 UTC (rev 24305)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2009-11-04 14:06:10 UTC (rev 24306)
@@ -790,12 +790,16 @@
  *	The flag argument is used for special settings that alter the behaviour of
  *	the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
  *	and extra keyframe filtering.
+ *
+ *	index of -1 keys all array indices
  */
 short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag)
 {	
 	PointerRNA id_ptr, ptr;
 	PropertyRNA *prop;
 	FCurve *fcu;
+	int array_index_max= array_index+1;
+	int ret= 0;
 	
 	/* validate pointer first - exit if failure */
 	RNA_id_pointer_create(id, &id_ptr);
@@ -814,8 +818,8 @@
 		/* apply NLA-mapping to frame to use (if applicable) */
 		cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
 	}
-	fcu= verify_fcurve(act, group, rna_path, array_index, 1);
-	
+
+#if 0
 	/* apply special time tweaking */
 		// XXX check on this stuff...
 	if (GS(id->name) == ID_OB) {
@@ -827,9 +831,22 @@
 		//	cfra-= give_timeoffset(ob)*scene->r.framelen;
 		//}
 	}
-	
-	/* insert keyframe */
-	return insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
+#endif
+
+	if(array_index==-1) { /* Key All */
+		array_index= 0;
+		array_index_max= RNA_property_array_length(&ptr, prop) + 1;
+	}
+
+	/* will only loop once unless the array index was -1 */
+	for( ; array_index < array_index_max; array_index++) {
+		fcu= verify_fcurve(act, group, rna_path, array_index, 1);
+
+		/* insert keyframe */
+		ret |= insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
+	}
+
+	return ret;
 }
 
 /* ************************************************** */

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2009-11-04 12:09:02 UTC (rev 24305)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2009-11-04 14:06:10 UTC (rev 24306)
@@ -1155,7 +1155,7 @@
 static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA * self, PyObject *args)
 {
 	char *path, *path_full;
-	int index= 0;
+	int index= -1; /* default to all */
 	float cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
 	PropertyRNA *prop;
 	PyObject *result;





More information about the Bf-blender-cvs mailing list