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)
This commit is contained in:
2009-11-04 14:06:10 +00:00
parent 510aa6ba53
commit 42fb30f37a
2 changed files with 23 additions and 6 deletions

View File

@@ -790,12 +790,16 @@ short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, fl
* 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 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_
/* 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 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_
// cfra-= give_timeoffset(ob)*scene->r.framelen;
//}
}
#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 */
return insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
ret |= insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
}
return ret;
}
/* ************************************************** */

View File

@@ -1155,7 +1155,7 @@ static PySequenceMethods pyrna_prop_as_sequence = {
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;