From 4e845e06704bad3c11297ae8e86b400ef80b2a89 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Jul 2016 16:34:01 +1000 Subject: Py-Driver: add 'self' option Drivers can use this to refer to the data which the driver is applied to, useful for objects, bones, to avoid having to create a variable pointing to its self. --- source/blender/editors/animation/keyframing.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0c0f54f0179..98be77b491f 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -930,11 +930,18 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr /* update F-Curve flags to ensure proper behaviour for property type */ update_autoflags_fcurve_direct(fcu, prop); - + /* adjust frame on which to add keyframe */ if ((flag & INSERTKEY_DRIVER) && (fcu->driver)) { - /* for making it easier to add corrective drivers... */ - cfra = evaluate_driver(fcu->driver, cfra); + PathResolvedRNA anim_rna; + + if (RNA_path_resolved_create(&ptr, prop, fcu->array_index, &anim_rna)) { + /* for making it easier to add corrective drivers... */ + cfra = evaluate_driver(&anim_rna, fcu->driver, cfra); + } + else { + cfra = 0.0f; + } } /* obtain value to give keyframe */ -- cgit v1.2.3