diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-11-11 14:56:50 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-11-11 14:56:50 +0300 |
commit | c1a74d9bd6b186966568e6455f6fe4c50a3cf17f (patch) | |
tree | 92d83d1e02cfadbbbf164caf5816101851862ffd /source/blender | |
parent | 5aea6c21810f4deaeb7b3c834b65f4969be48054 (diff) |
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).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 14 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 68 |
2 files changed, 80 insertions, 2 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 73c7cfd4381..9121d8cd66c 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ - +#include <stdio.h> #include "MEM_guardedalloc.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 @@ void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float 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) ....................... */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 3fe867fa3af..58b1ebda55a 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1596,9 +1596,73 @@ void ANIM_OT_channels_collapse (wmOperatorType *ot) 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 @@ void ED_operatortypes_animchannels(void) 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 |