[Bf-blender-cvs] [2625dc5] master: Bugfix T41525: Button keyframe indicators don't work correctly when editing NLA Strips

Joshua Leung noreply at git.blender.org
Sun Nov 16 08:25:18 CET 2014


Commit: 2625dc53487971d3def110ca70b88c178f772712
Author: Joshua Leung
Date:   Sun Nov 16 20:24:38 2014 +1300
Branches: master
https://developer.blender.org/rB2625dc53487971d3def110ca70b88c178f772712

Bugfix T41525: Button keyframe indicators don't work correctly when editing NLA Strips

When the active action is a NLA strip, the keyframe indicator colors for buttons
and the 3D view indicator (i.e. the current frame indicator changes color) didn't
work correctly. This was because they were still checking for keyframes in
"global" time space, whereas they needed to be applying NLA corrections to
"look inside" the remapped action.

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

M	source/blender/blenkernel/BKE_fcurve.h
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index c377769..8378394 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -44,6 +44,7 @@ struct DriverTarget;
 struct FCM_EnvelopeData;
 
 struct bContext;
+struct AnimData;
 struct bAction;
 struct BezTriple;
 struct StructRNA;
@@ -224,10 +225,10 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix,
 
 /* find an f-curve based on an rna property. */
 struct FCurve *rna_get_fcurve(struct PointerRNA *ptr, struct PropertyRNA *prop, int rnaindex,
-                              struct bAction **action, bool *r_driven);
+                              struct AnimData **adt, struct bAction **action, bool *r_driven);
 /* Same as above, but takes a context data, temp hack needed for complex paths like texture ones. */
 struct FCurve *rna_get_fcurve_context_ui(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop,
-                                         int rnaindex, struct bAction **action, bool *r_driven);
+                                         int rnaindex, struct AnimData **adt, struct bAction **action, bool *r_driven);
 
 /* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
  * Returns the index to insert at (data already at that index will be offset if replace is 0)
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index e90a089..325c605 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -309,17 +309,18 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix,
 	return matches;
 }
 
-FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, bool *r_driven)
+FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **adt, bAction **action, bool *r_driven)
 {
-	return rna_get_fcurve_context_ui(NULL, ptr, prop, rnaindex, action, r_driven);
+	return rna_get_fcurve_context_ui(NULL, ptr, prop, rnaindex, adt, action, r_driven);
 }
 
 FCurve *rna_get_fcurve_context_ui(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int rnaindex,
-                                  bAction **action, bool *r_driven)
+                                  AnimData **animdata, bAction **action, bool *r_driven)
 {
 	FCurve *fcu = NULL;
 	PointerRNA tptr = *ptr;
 	
+	if (animdata) *animdata = NULL;
 	*r_driven = false;
 	
 	/* there must be some RNA-pointer + property combon */
@@ -350,11 +351,14 @@ FCurve *rna_get_fcurve_context_ui(bContext *C, PointerRNA *ptr, PropertyRNA *pro
 					if (!fcu && (adt->drivers.first)) {
 						fcu = list_find_fcurve(&adt->drivers, path, rnaindex);
 						
-						if (fcu)
+						if (fcu) {
+							if (animdata) *animdata = adt;
 							*r_driven = true;
+						}
 					}
 					
 					if (fcu && action) {
+						if (animdata) *animdata = adt;
 						*action = adt->action;
 						break;
 					}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 9a9c987..2c66d92 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -2011,7 +2011,13 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
 	
 	/* check own animation data - specifically, the action it contains */
 	if ((ob->adt) && (ob->adt->action)) {
-		if (action_frame_has_keyframe(ob->adt->action, frame, filter))
+		/* T41525 - When the active action is a NLA strip being edited, 
+		 * we need to correct the frame number to "look inside" the
+		 * remapped action
+		 */
+		float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP);
+		
+		if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter))
 			return 1;
 	}
 	
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index aa23184..7e7806f 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -43,6 +43,7 @@
 #include "BKE_animsys.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
+#include "BKE_nla.h"
 
 #include "ED_keyframing.h"
 
@@ -55,28 +56,37 @@
 
 #include "interface_intern.h"
 
-static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, bool *r_driven)
+static FCurve *ui_but_get_fcurve(uiBut *but, AnimData **adt, bAction **action, bool *r_driven)
 {
 	/* for entire array buttons we check the first component, it's not perfect
 	 * but works well enough in typical cases */
 	int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex;
 
-	return rna_get_fcurve_context_ui(but->block->evil_C, &but->rnapoin, but->rnaprop, rnaindex, action, r_driven);
+	return rna_get_fcurve_context_ui(but->block->evil_C, &but->rnapoin, but->rnaprop, rnaindex, adt, action, r_driven);
 }
 
 void ui_but_anim_flag(uiBut *but, float cfra)
 {
+	AnimData *adt;
+	bAction *act;
 	FCurve *fcu;
 	bool driven;
 
 	but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
 
-	fcu = ui_but_get_fcurve(but, NULL, &driven);
+	fcu = ui_but_get_fcurve(but, &adt, &act, &driven);
 
 	if (fcu) {
 		if (!driven) {
 			but->flag |= UI_BUT_ANIMATED;
 			
+			/* T41525 - When the active action is a NLA strip being edited, 
+			 * we need to correct the frame number to "look inside" the
+			 * remapped action
+			 */
+			if (adt)
+				cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
+			
 			if (fcurve_frame_has_keyframe(fcu, cfra, 0))
 				but->flag |= UI_BUT_ANIMATED_KEY;
 		}
@@ -92,7 +102,7 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
 	ChannelDriver *driver;
 	bool driven;
 
-	fcu = ui_but_get_fcurve(but, NULL, &driven);
+	fcu = ui_but_get_fcurve(but, NULL, NULL, &driven);
 
 	if (fcu && driven) {
 		driver = fcu->driver;
@@ -112,7 +122,7 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
 	ChannelDriver *driver;
 	bool driven;
 
-	fcu = ui_but_get_fcurve(but, NULL, &driven);
+	fcu = ui_but_get_fcurve(but, NULL, NULL, &driven);
 
 	if (fcu && driven) {
 		driver = fcu->driver;
@@ -208,7 +218,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
 	FCurve *fcu;
 	bool driven;
 
-	fcu = ui_but_get_fcurve(but, &action, &driven);
+	fcu = ui_but_get_fcurve(but, NULL, &action, &driven);
 
 	if (fcu && !driven) {
 		id = but->rnapoin.id.data;
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 377bd3a..3df6bd5 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -197,7 +197,7 @@ static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob
 
 				RNA_id_pointer_create(&ob->id, &ptr);
 				prop = RNA_struct_find_property(&ptr, rnapropname);
-				fcu = rna_get_fcurve_context_ui(C, &ptr, prop, 0, &action, &driven);
+				fcu = rna_get_fcurve_context_ui(C, &ptr, prop, 0, NULL, &action, &driven);
 
 				if (fcu && !driven) {
 					id = ptr.id.data;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 806b9d0..9494377 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1630,9 +1630,10 @@ bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
 	if (RNA_property_array_check(prop))
 		len = RNA_property_array_length(ptr, prop);
 
-	for (index = 0; index < len; index++)
-		if (rna_get_fcurve(ptr, prop, index, NULL, &driven))
+	for (index = 0; index < len; index++) {
+		if (rna_get_fcurve(ptr, prop, index, NULL, NULL, &driven))
 			return true;
+	}
 
 	return false;
 }




More information about the Bf-blender-cvs mailing list