[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33008] trunk/blender: Animation Editors: Experimental indicators + "fixup" operator for "Disabled FCurves"

Joshua Leung aligorith at gmail.com
Thu Nov 11 12:56:50 CET 2010


Revision: 33008
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33008
Author:   aligorith
Date:     2010-11-11 12:56:50 +0100 (Thu, 11 Nov 2010)

Log Message:
-----------
Animation Editors: Experimental indicators + "fixup" operator for "Disabled FCurves"

F-Curves tagged as "disabled" now have their channels drawn with a red line underlining their names. 

"Disabled" F-Curves are skipped for evaluation, and typically result (for example) from assigning an action from one armature to another, but the new armature does not have some of the bones the action's F-Curves need in order for the datapaths (referring to the property the F-Curves affect) to be resolved. This is to prevent heaps of invalid channels slowing down animation playback.

I've also added a new operator, found by:
Channels -> Revive Disabled F-Curves
in the Graph Editor and DopeSheet/Action Editors, which will clear all the disabled tags for all the F-Curves in the animation editor at the time (based on the filtering criteria). 

Use this operator to clear the disabled tags, allowing such channels to be able to be evaluated again (perhaps after adding the offending bones for example, or when using the action on the original armature again). 

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_dopesheet.py
    trunk/blender/release/scripts/ui/space_graph.py
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/anim_channels_edit.c

Modified: trunk/blender/release/scripts/ui/space_dopesheet.py
===================================================================
--- trunk/blender/release/scripts/ui/space_dopesheet.py	2010-11-11 11:53:30 UTC (rev 33007)
+++ trunk/blender/release/scripts/ui/space_dopesheet.py	2010-11-11 11:56:50 UTC (rev 33008)
@@ -202,6 +202,10 @@
         layout.separator()
         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
 
+        layout.separator()
+        layout.operator("anim.channels_revive_fcurves")
+
+
 class DOPESHEET_MT_key(bpy.types.Menu):
     bl_label = "Key"
 

Modified: trunk/blender/release/scripts/ui/space_graph.py
===================================================================
--- trunk/blender/release/scripts/ui/space_graph.py	2010-11-11 11:53:30 UTC (rev 33007)
+++ trunk/blender/release/scripts/ui/space_graph.py	2010-11-11 11:56:50 UTC (rev 33008)
@@ -160,7 +160,10 @@
         layout.separator()
         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
 
+        layout.separator()
+        layout.operator("anim.channels_revive_fcurves")
 
+
 class GRAPH_MT_key(bpy.types.Menu):
     bl_label = "Key"
 

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2010-11-11 11:53:30 UTC (rev 33007)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2010-11-11 11:56:50 UTC (rev 33008)
@@ -25,8 +25,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <stdio.h>
 
-
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
@@ -61,6 +61,7 @@
 #include "ED_keyframing.h"
 
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -2785,6 +2786,17 @@
 		
 		offset += 3;
 		UI_DrawString(offset, ytext, name);
+		
+		/* draw red underline if channel is disabled */
+		if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) 
+		{
+			// FIXME: replace hardcoded color here, and check on extents!
+			glColor3f(1.0f, 0.0f, 0.0f);
+			glLineWidth(2.0);
+				fdrawline((float)(offset), yminc, 
+						  (float)(v2d->cur.xmax), yminc);
+			glLineWidth(1.0);
+		}
 	}
 	
 	/* step 6) draw backdrops behidn mute+protection toggles + (sliders) ....................... */

Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-11-11 11:53:30 UTC (rev 33007)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-11-11 11:56:50 UTC (rev 33008)
@@ -1596,9 +1596,73 @@
 	ot->prop= RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)");
 }
 
+/* ******************* Reenable Disabled Operator ******************* */
+
+static int animchannels_revive_poll (bContext *C)
+{
+	ScrArea *sa= CTX_wm_area(C);
+	
+	/* channels region test */
+	// TODO: could enhance with actually testing if channels region?
+	if (ELEM(NULL, sa, CTX_wm_region(C)))
+		return 0;
+		
+	/* animation editor test - Action/Dopesheet/etc. and Graph only */
+	if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO) == 0)
+		return 0;
+		
+	return 1;
+}
+
+static int animchannels_revive_exec (bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	/* loop through filtered data and clean curves */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		FCurve *fcu = (FCurve *)ale->data;
+		fcu->flag &= ~FCURVE_DISABLED;
+	}
+	
+	/* free temp data */
+	BLI_freelistN(&anim_data);
+		
+	/* send notifier that things have changed */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
+	
+	return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_channels_revive_fcurves (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Revive Disabled F-Curves";
+	ot->idname= "ANIM_OT_channels_revive_fcurves";
+	ot->description= "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again";
+	
+	/* api callbacks */
+	ot->exec= animchannels_revive_exec;
+	ot->poll= animchannels_revive_poll;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* ********************** Select All Operator *********************** */
 
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_deselectall_exec (bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
 	
@@ -2115,6 +2179,8 @@
 	
 	WM_operatortype_append(ANIM_OT_channels_visibility_toggle);
 	WM_operatortype_append(ANIM_OT_channels_visibility_set);
+	
+	WM_operatortype_append(ANIM_OT_channels_revive_fcurves);
 }
 
 // TODO: check on a poll callback for this, to get hotkeys into menus





More information about the Bf-blender-cvs mailing list