[Bf-blender-cvs] [9a88bd55903] master: Fix T65802: F-curves modifiers in nodes doesn't updates properly

Sebastian Parborg noreply at git.blender.org
Thu Jun 20 17:48:43 CEST 2019


Commit: 9a88bd55903a5c7df0365007bef8dd182f6eb481
Author: Sebastian Parborg
Date:   Thu Jun 20 17:46:57 2019 +0200
Branches: master
https://developer.blender.org/rB9a88bd55903a5c7df0365007bef8dd182f6eb481

Fix T65802: F-curves modifiers in nodes doesn't updates properly

The other built in modifiers, except the generator modifier, seems to
update the depsgraph thought some RNA magic.
However the generator seem to be a bit special and doesn't get included
into this. Now we manually update the depsgraph on value changes to the
generator modifier.

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

M	source/blender/editors/animation/fmodifier_ui.c

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

diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index f4e1268ab77..b42e8102c5b 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -70,8 +70,18 @@
 #define B_REDR 1
 #define B_FMODIFIER_REDRAW 20
 
+/* callback to update depsgraph on value changes */
+static void deg_update(bContext *C, void *owner_id, void *UNUSED(var2))
+{
+  /* 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(owner_id, ID_RECALC_ANIMATION);
+}
+
 /* callback to verify modifier data */
-static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg))
+static void validate_fmodifier_cb(bContext *C, void *fcm_v, void *owner_id)
 {
   FModifier *fcm = (FModifier *)fcm_v;
   const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
@@ -80,6 +90,9 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
   if (fmi && fmi->verify_data) {
     fmi->verify_data(fcm);
   }
+  if (owner_id) {
+    deg_update(C, owner_id, NULL);
+  }
 }
 
 /* callback to remove the given modifier  */
@@ -98,13 +111,8 @@ static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v)
 
   ED_undo_push(C, "Delete F-Curve Modifier");
 
-  /* 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_ANIMATION);
+  deg_update(C, ctx->fcurve_owner_id, NULL);
 }
-
 /* --------------- */
 
 /* draw settings for generator modifier */
@@ -176,6 +184,7 @@ static void draw_modifier__generator(uiLayout *layout,
       /* draw polynomial order selector */
       row = uiLayoutRow(layout, false);
       block = uiLayoutGetBlock(row);
+
       but = uiDefButI(
           block,
           UI_BTYPE_NUM,
@@ -191,7 +200,7 @@ static void draw_modifier__generator(uiLayout *layout,
           0,
           0,
           TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
-      UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
+      UI_but_func_set(but, validate_fmodifier_cb, fcm, fcurve_owner_id);
 
       /* calculate maximum width of label for "x^n" labels */
       if (data->arraysize > 2) {
@@ -208,6 +217,9 @@ static void draw_modifier__generator(uiLayout *layout,
       row = uiLayoutRow(layout, true);
       block = uiLayoutGetBlock(row);
 
+      /* Update depsgraph when values change */
+      UI_block_func_set(block, deg_update, fcurve_owner_id, NULL);
+
       cp = data->coefficients;
       for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
         /* To align with first line... */
@@ -310,6 +322,7 @@ static void draw_modifier__generator(uiLayout *layout,
       /* draw polynomial order selector */
       row = uiLayoutRow(layout, false);
       block = uiLayoutGetBlock(row);
+
       but = uiDefButI(
           block,
           UI_BTYPE_NUM,
@@ -325,12 +338,15 @@ static void draw_modifier__generator(uiLayout *layout,
           0,
           0,
           TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
-      UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL);
+      UI_but_func_set(but, validate_fmodifier_cb, fcm, fcurve_owner_id);
 
       /* draw controls for each pair of coefficients */
       row = uiLayoutRow(layout, true);
       block = uiLayoutGetBlock(row);
 
+      /* Update depsgraph when values change */
+      UI_block_func_set(block, deg_update, fcurve_owner_id, NULL);
+
       cp = data->coefficients;
       for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) {
         /* To align with first line */



More information about the Bf-blender-cvs mailing list