From 193e77cc673e6836525ab1a0bad0ff5491e04d23 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 19 May 2014 00:24:45 +1000 Subject: Fix T40201: Keyframe edits fail to update the viewport --- .../editors/animation/anim_channels_defines.c | 2 +- .../blender/editors/animation/anim_channels_edit.c | 42 +++++++++---------- source/blender/editors/animation/anim_deps.c | 47 +++++++++++++++++++++- source/blender/editors/animation/keyframes_draw.c | 6 +-- source/blender/editors/animation/keyframes_edit.c | 8 ++-- .../blender/editors/animation/keyframes_general.c | 4 ++ 6 files changed, 79 insertions(+), 30 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 1cd1a26678d..26ab4d84bed 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3569,7 +3569,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void ANIM_flush_setting_anim_channels(&ac, &anim_data, ale_setting, setting, on); /* free temp data */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* callback for wrapping NLA Track "solo" toggle logic */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 5d97b7be9f7..2b85cae440e 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -184,7 +184,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f } /* clean up */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* Deselect all animation channels @@ -373,7 +373,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s } /* Cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* ---------------------------- Graph Editor ------------------------------------- */ @@ -1177,7 +1177,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } /* free temp data */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* send notifier that things have changed */ @@ -1290,7 +1290,7 @@ static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } } @@ -1321,7 +1321,7 @@ static int animchannels_group_exec(bContext *C, wmOperator *op) } /* free temp data */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* updatss */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -1393,7 +1393,7 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* updates */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -1470,7 +1470,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* filter data */ @@ -1515,7 +1515,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -1586,7 +1586,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 0); } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* make all the selected channels visible */ filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); @@ -1605,7 +1605,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1); } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); @@ -1683,7 +1683,7 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); /* send notifier that things have changed */ @@ -1799,7 +1799,7 @@ static void setflag_anim_channels(bAnimContext *ac, short setting, short mode, s ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode); } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); } @@ -2064,11 +2064,11 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) fcu->driver->flag &= ~DRIVER_FLAG_INVALID; /* tag everything for updates - in particular, this is needed to get drivers working again */ - ANIM_list_elem_update(ac.scene, ale); + ale->update |= ANIM_UPDATE_DEPS; } - /* free temp data */ - BLI_freelistN(&anim_data); + ANIM_animdata_update(&ac, &anim_data); + ANIM_animdata_freelist(&anim_data); /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -2228,7 +2228,7 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec } /* cleanup */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* ------------------- */ @@ -2312,7 +2312,7 @@ static void rename_anim_channels(bAnimContext *ac, int channel_index) if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", channel_index); - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); return; } @@ -2338,7 +2338,7 @@ static void rename_anim_channels(bAnimContext *ac, int channel_index) } /* free temp data and tag for refresh */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); ED_region_tag_redraw(ac->ar); } @@ -2413,7 +2413,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index); - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); return 0; } @@ -2421,7 +2421,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* TODO: should this feature be extended to work with other channel types too? */ if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) { /* normal channels should not behave normally in this case */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); return 0; } @@ -2706,7 +2706,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, } /* free channels */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* return notifier flags */ return notifierFlags; diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index c0543862265..5bffdfbcc4b 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -45,6 +45,7 @@ #include "BKE_animsys.h" #include "BKE_action.h" +#include "BKE_fcurve.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -341,5 +342,49 @@ void ANIM_sync_animchannels_to_data(const bContext *C) } } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); +} + +void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) +{ + bAnimListElem *ale; + + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) + return; + + for (ale = anim_data->first; ale; ale = ale->next) { + FCurve *fcu = ale->key_data; + + if (ale->update & ANIM_UPDATE_ORDER) { + ale->update &= ~ANIM_UPDATE_ORDER; + sort_time_fcurve(fcu); + } + + if (ale->update & ANIM_UPDATE_HANDLES) { + ale->update &= ~ANIM_UPDATE_HANDLES; + calchandles_fcurve(fcu); + } + + if (ale->update & ANIM_UPDATE_DEPS) { + ale->update &= ~ANIM_UPDATE_DEPS; + ANIM_list_elem_update(ac->scene, ale); + } + + BLI_assert(ale->update == 0); + } +} + +void ANIM_animdata_freelist(ListBase *anim_data) +{ +#ifndef NDEBUG + bAnimListElem *ale, *ale_next; + for (ale = anim_data->first; ale; ale = ale_next) { + ale_next = ale->next; + BLI_assert(ale->update == 0); + MEM_freeN(ale); + } + BLI_listbase_clear(anim_data); +#else + BLI_freelistN(anim_data); +#endif } diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index e233608dea2..c5e54cc1c7c 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -798,7 +798,7 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) } } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } } @@ -832,7 +832,7 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks) @@ -868,7 +868,7 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree *blocks) diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index e43da7587cf..ee5039488bd 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -223,7 +223,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o } } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* return return code - defaults to zero if nothing happened */ return ret; @@ -265,7 +265,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene } } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); /* return return code - defaults to zero if nothing happened */ return ret; @@ -301,7 +301,7 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key break; } - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); return ret_code; } @@ -397,7 +397,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) } /* free temp data */ - BLI_freelistN(&anim_data); + ANIM_animdata_freelist(&anim_data); } /* ************************************************************************** */ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index c610595c4ba..07a1a7e6b30 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -857,6 +857,8 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, totmatch++; paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode); } + + ale->update |= ANIM_UPDATE_DEFAULT; } /* don't continue if some fcurves were pasted */ @@ -865,6 +867,8 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, } } + ANIM_animdata_update(ac, anim_data); + return 0; } -- cgit v1.2.3