[Bf-blender-cvs] [92a081ff83b] master: Fix T60340: Removing f-curve modifier doesn't update animation

Sergey Sharybin noreply at git.blender.org
Thu Jan 10 16:05:23 CET 2019


Commit: 92a081ff83ba551dd061f233af6239e1dbfb1241
Author: Sergey Sharybin
Date:   Thu Jan 10 15:56:02 2019 +0100
Branches: master
https://developer.blender.org/rB92a081ff83ba551dd061f233af6239e1dbfb1241

Fix T60340: Removing f-curve modifier doesn't update animation

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

M	source/blender/editors/animation/fmodifier_ui.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/space_graph/graph_buttons.c
M	source/blender/editors/space_nla/nla_buttons.c

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

diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 3136b3e7137..5d0a2fa4d86 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -50,6 +50,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_animsys.h"
 #include "BKE_context.h"
 #include "BKE_fcurve.h"
 
@@ -64,6 +65,8 @@
 #include "ED_anim_api.h"
 #include "ED_undo.h"
 
+#include "DEG_depsgraph.h"
+
 /* ********************************************** */
 /* UI STUFF */
 
@@ -86,9 +89,14 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
 }
 
 /* callback to remove the given modifier  */
-static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v)
+typedef struct FModifierDeleteContext {
+	ID *fcurve_owner_id;
+	ListBase *modifiers;
+} FModifierDeleteContext;
+static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v)
 {
-	ListBase *modifiers = (ListBase *)fmods_v;
+	FModifierDeleteContext *ctx = (FModifierDeleteContext *)ctx_v;
+	ListBase *modifiers = ctx->modifiers;
 	FModifier *fcm = (FModifier *)fcm_v;
 
 	/* remove the given F-Modifier from the active modifier-stack */
@@ -99,6 +107,7 @@ static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v)
 	/* send notifiers */
 	// XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case
 	WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+	DEG_id_tag_update(ctx->fcurve_owner_id, ID_RECALC_COPY_ON_WRITE);
 }
 
 /* --------------- */
@@ -553,7 +562,8 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho
 
 /* --------------- */
 
-void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm)
+void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ID *fcurve_owner_id,
+                                    ListBase *modifiers, FModifier *fcm)
 {
 	const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
 	uiLayout *box, *row, *sub, *col;
@@ -604,7 +614,10 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier
 		/* delete button */
 		but = uiDefIconBut(block, UI_BTYPE_BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y,
 		                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier"));
-		UI_but_func_set(but, delete_fmodifier_cb, modifiers, fcm);
+		FModifierDeleteContext *ctx = MEM_mallocN(sizeof(FModifierDeleteContext), "fmodifier ctx");
+		ctx->fcurve_owner_id = fcurve_owner_id;
+		ctx->modifiers = modifiers;
+		UI_but_funcN_set(but, delete_fmodifier_cb, ctx, fcm);
 
 		UI_block_emboss_set(block, UI_EMBOSS);
 	}
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 4bb9960ba21..f2cf5a3ead9 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -584,7 +584,8 @@ void ANIM_draw_framerange(struct Scene *scene, struct View2D *v2d);
 /* ------------- UI Panel Drawing -------------- */
 
 /* draw a given F-Modifier for some layout/UI-Block */
-void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, ListBase *modifiers, struct FModifier *fcm);
+void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, struct ID *fcurve_owner_id,
+                                    ListBase *modifiers, struct FModifier *fcm);
 
 /* ------------- Copy/Paste Buffer -------------- */
 
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index c3d6c1f6435..ef0e4f7d6f3 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -1142,7 +1142,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
 		col = uiLayoutColumn(pa->layout, true);
 		uiLayoutSetActive(col, active);
 
-		ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
+		ANIM_uiTemplate_fmodifier_draw(col, ale->id, ale->fcurve_owner_id, &fcu->modifiers, fcm);
 	}
 
 	MEM_freeN(ale);
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index d5d50c86851..76d2c2851c1 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -495,7 +495,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
 	for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) {
 		col = uiLayoutColumn(pa->layout, true);
 
-		ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm);
+		ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, strip_ptr.id.data, &strip->modifiers, fcm);
 	}
 }



More information about the Bf-blender-cvs mailing list