diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-06-13 16:14:03 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-06-13 16:21:47 +0300 |
commit | 0b51e7d99170aa6bdb2b9a3884122a350dc3ebae (patch) | |
tree | d741dd982baa0e211445e6dafe65b59ebe6ea1ea | |
parent | 38a60418f7808970fdaa8a2c1b124564bb961266 (diff) |
Fix: "Delete Keyframes" RMB-menu option didn't work on NLA Strip properties
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index cd7a326ffd5..ab430483ed5 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1801,19 +1801,55 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) UI_context_active_but_prop_get(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - path = RNA_path_from_ID_to_property(&ptr, prop); - - if (path) { - if (all) { - /* -1 indicates operating on the entire array (or the property itself otherwise) */ - index = -1; + if (ptr.type == &RNA_NlaStrip) { + /* Handle special properties for NLA Strips, whose F-Curves are stored on the + * strips themselves. These are stored separately or else the properties will + * not have any effect. + */ + ID *id = ptr.id.data; + NlaStrip *strip = (NlaStrip *)ptr.data; + FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), 0); + + BLI_assert(fcu != NULL); /* NOTE: This should be true, or else we wouldn't be able to get here */ + + if (BKE_fcurve_is_protected(fcu)) { + BKE_reportf(op->reports, RPT_WARNING, + "Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'", + strip->name, BKE_idcode_to_name(GS(id->name)), id->name + 2); } + else { + /* remove the keyframe directly + * NOTE: cannot use delete_keyframe_fcurve(), as that will free the curve, + * and delete_keyframe() expects the FCurve to be part of an action + */ + bool found = false; + int i; + + /* try to find index of beztriple to get rid of */ + i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); + if (found) { + /* delete the key at the index (will sanity check + do recalc afterwards) */ + delete_fcurve_key(fcu, i, 1); + success = true; + } + } + } + else { + /* standard properties */ + path = RNA_path_from_ID_to_property(&ptr, prop); - success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0); - MEM_freeN(path); + if (path) { + if (all) { + /* -1 indicates operating on the entire array (or the property itself otherwise) */ + index = -1; + } + + success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0); + MEM_freeN(path); + } + else if (G.debug & G_DEBUG) + printf("Button Delete-Key: no path to property\n"); } - else if (G.debug & G_DEBUG) - printf("Button Delete-Key: no path to property\n"); } else if (G.debug & G_DEBUG) { printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop); |