[Bf-blender-cvs] [1c40dfc] blender-v2.75-release: Fix: "Delete Keyframes" RMB-menu option didn't work on NLA Strip properties

Joshua Leung noreply at git.blender.org
Thu Jun 18 17:36:53 CEST 2015


Commit: 1c40dfc43cf85d57ec6beb1a48d235526c3ac216
Author: Joshua Leung
Date:   Sun Jun 14 01:14:03 2015 +1200
Branches: blender-v2.75-release
https://developer.blender.org/rB1c40dfc43cf85d57ec6beb1a48d235526c3ac216

Fix: "Delete Keyframes" RMB-menu option didn't work on NLA Strip properties

===================================================================

M	source/blender/editors/animation/keyframing.c

===================================================================

diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index cd7a326..ab43048 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);




More information about the Bf-blender-cvs mailing list