Commit: b1ce4ca40c03ab2562863ef8056adc3b2aff5c10
Author: Antonio Vazquez
Date:   Fri Jun 19 10:09:51 2020 +0200
Branches: master
https://developer.blender.org/rBb1ce4ca40c03ab2562863ef8056adc3b2aff5c10

Fix T77997: GPencil insert keyframe on timeline doen't update viewport

The reason was the datablock is changed but it was not tagged for depsgraph 
refresh.

In some cases it could be possible to tag several times the same datablock, but 
as this is not the case all the times and the number of tags is always very 
small, it doesn't worth a complex code to keep a memory list of the datablocks 
to tag.

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

M       source/blender/blenkernel/BKE_gpencil.h
M       source/blender/blenkernel/intern/gpencil.c
M       source/blender/editors/space_action/action_edit.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 85ba8175143..cd434566e43 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -96,6 +96,7 @@ void BKE_gpencil_free_layers(struct ListBase *list);
 void BKE_gpencil_free(struct bGPdata *gpd, bool free_all);
 void BKE_gpencil_eval_delete(struct bGPdata *gpd_eval);
 void BKE_gpencil_free_layer_masks(struct bGPDlayer *gpl);
+void BKE_gpencil_tag(struct bGPdata *gpd);
 
 void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
 void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index b460e6d6dc0..4f1ede432ea 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -289,6 +289,16 @@ void BKE_gpencil_eval_delete(bGPdata *gpd_eval)
   MEM_freeN(gpd_eval);
 }
 
+/**
+ * Tag datablock for depsgraph update.
+ * Wrapper to avoid include Depsgraph tag functions in other modules.
+ * \param gpd Grease pencil datablock
+ */
+void BKE_gpencil_tag(bGPdata *gpd)
+{
+  DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+}
+
 /* ************************************************** */
 /* Container Creation */
 
diff --git a/source/blender/editors/space_action/action_edit.c 
b/source/blender/editors/space_action/action_edit.c
index b390e4b56d6..aa44982ccc5 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -800,10 +800,17 @@ static void insert_gpencil_keys(bAnimContext *ac, short 
mode)
     add_frame_mode = GP_GETFRAME_ADD_NEW;
   }
 
-  /* insert gp frames */
+  /* Insert gp frames. */
+  bGPdata *gpd_old = NULL;
   for (ale = anim_data.first; ale; ale = ale->next) {
+    bGPdata *gpd = (bGPdata *)ale->id;
     bGPDlayer *gpl = (bGPDlayer *)ale->data;
     BKE_gpencil_layer_frame_get(gpl, CFRA, add_frame_mode);
+    /* Check if the gpd changes to tag only once. */
+    if (gpd != gpd_old) {
+      BKE_gpencil_tag(gpd);
+      gpd_old = gpd;
+    }
   }
 
   ANIM_animdata_update(ac, &anim_data);
@@ -839,6 +846,9 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator 
*op)
   }
 
   /* set notifier that keyframes have changed */
+  if (ac.datatype == ANIMCONT_GPENCIL) {
+    WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+  }
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
 
   return OPERATOR_FINISHED;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to