Fix #115330: Animation not updating when cancelling modal operators in the Graph Editor

When using any of the operators in `graph_slider_ops.cc` and cancelling the operation,
the location of the object in the 3D viewport might get stuck in the state prior to cancelling.

To fix this, explicitly update the depsgraph when cancelling.

I've only done that in case of cancelling, since that's where the issue came from.
For fear of introducing performance regressions I'm not tagging the depsgraph
for an update at any other point. (It might already do that at some other part of
the operator code though)

Pull Request: https://projects.blender.org/blender/blender/pulls/115810
This commit is contained in:
Christoph Lendenfeld
2023-12-08 11:12:50 +01:00
committed by Christoph Lendenfeld
parent 58041799bc
commit beacdc3f01

View File

@@ -20,6 +20,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "DEG_depsgraph.hh"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
@@ -283,6 +284,20 @@ static void graph_slider_exit(bContext *C, wmOperator *op)
op->customdata = nullptr;
}
static void update_depsgraph(tGraphSliderOp *gso)
{
ListBase anim_data = {nullptr, nullptr};
bAnimContext *ac = &gso->ac;
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
DEG_id_tag_update(ale->fcurve_owner_id, ID_RECALC_ANIMATION);
}
ANIM_animdata_freelist(&anim_data);
}
static int graph_slider_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
@@ -310,6 +325,10 @@ static int graph_slider_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
reset_bezts(gso);
/* The owner id's of the FCurves need to be updated, else the animation will be stuck in
* the state prior to calling reset_bezt. */
update_depsgraph(gso);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
graph_slider_exit(C, op);