Commit: aee0446b6bdc6ff384e9d66a917f6cb06f620c0a
Author: Alexander Gavrilov
Date:   Mon Nov 12 16:17:57 2018 +0300
Branches: blender2.8
https://developer.blender.org/rBaee0446b6bdc6ff384e9d66a917f6cb06f620c0a

Add a lot of update tagging to operations with NLA tracks and strips.

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

M       source/blender/editors/animation/anim_deps.c
M       source/blender/editors/include/ED_anim_api.h
M       source/blender/editors/space_nla/CMakeLists.txt
M       source/blender/editors/space_nla/nla_channels.c
M       source/blender/editors/space_nla/nla_edit.c
M       source/blender/editors/transform/transform_generics.c
M       source/blender/makesrna/intern/rna_animation.c
M       source/blender/makesrna/intern/rna_nla.c

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

diff --git a/source/blender/editors/animation/anim_deps.c 
b/source/blender/editors/animation/anim_deps.c
index bfc3caecfee..2ed5d35b613 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -84,6 +84,12 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, 
bAnimListElem *ale)
                }
        }
 
+       /* Tag copy on the main object if updating anything directly inside 
AnimData */
+       if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, 
ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
+               DEG_id_tag_update(id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+               return;
+       }
+
        /* update data */
        fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL;
 
@@ -108,7 +114,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, 
bAnimListElem *ale)
 
 /* tags the given ID block for refreshes (if applicable) due to
  * Animation Editor editing */
-void ANIM_id_update(Scene *UNUSED(scene), ID *id)
+void ANIM_id_update(Main *bmain, ID *id)
 {
        if (id) {
                AnimData *adt = BKE_animdata_from_id(id);
@@ -118,7 +124,7 @@ void ANIM_id_update(Scene *UNUSED(scene), ID *id)
                        adt->recalc |= ADT_RECALC_ANIM;
 
                /* set recalc flags */
-               DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | 
OB_RECALC_TIME); // XXX or do we want something more restrictive?
+               DEG_id_tag_update_ex(bmain, id, OB_RECALC_OB | OB_RECALC_DATA | 
OB_RECALC_TIME); // XXX or do we want something more restrictive?
        }
 }
 
@@ -433,7 +439,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase 
*anim_data)
                                ANIM_list_elem_update(ac->bmain, ac->scene, 
ale);
                        }
                }
-               else if (ale->datatype == ALE_NLASTRIP) {
+               else if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, 
ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
                        if (ale->update & ANIM_UPDATE_DEPS) {
                                ale->update &= ~ANIM_UPDATE_DEPS;
                                ANIM_list_elem_update(ac->bmain, ac->scene, 
ale);
diff --git a/source/blender/editors/include/ED_anim_api.h 
b/source/blender/editors/include/ED_anim_api.h
index ae86e4a5fbf..a2be7622537 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -688,7 +688,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, 
struct ID *id, struct FC
 
 /* --------- anim_deps.c, animation updates -------- */
 
-void ANIM_id_update(struct Scene *scene, struct ID *id);
+void ANIM_id_update(struct Main *bmain, struct ID *id);
 void ANIM_list_elem_update(struct Main *bmain, struct Scene *scene, 
bAnimListElem *ale);
 
 /* data -> channels syncing */
diff --git a/source/blender/editors/space_nla/CMakeLists.txt 
b/source/blender/editors/space_nla/CMakeLists.txt
index c8c64a79945..a6b80a9a587 100644
--- a/source/blender/editors/space_nla/CMakeLists.txt
+++ b/source/blender/editors/space_nla/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
        ../../blenkernel
        ../../blenlib
        ../../blentranslation
+       ../../depsgraph
        ../../gpu
        ../../makesdna
        ../../makesrna
diff --git a/source/blender/editors/space_nla/nla_channels.c 
b/source/blender/editors/space_nla/nla_channels.c
index 002eeea9746..132a296d5a3 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -60,6 +60,9 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
 #include "UI_view2d.h"
 
 #include "nla_intern.h" // own include
@@ -235,6 +238,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext 
*ac, float x, int channe
 
                                /* notifier flags - channel was edited */
                                notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+                               ale->update |= ANIM_UPDATE_DEPS;
                        }
                        else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) 
{
                                /* toggle 'solo' */
@@ -242,6 +246,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext 
*ac, float x, int channe
 
                                /* notifier flags - channel was edited */
                                notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+                               ale->update |= ANIM_UPDATE_DEPS;
                        }
                        else if (nlaedit_is_tweakmode_on(ac) == 0) {
                                /* set selection */
@@ -284,6 +289,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext 
*ac, float x, int channe
 
                                /* changes to NLA-Action occurred */
                                notifierFlags |= ND_NLA_ACTCHANGE;
+                               ale->update |= ANIM_UPDATE_DEPS;
                        }
                        /* OR rest of name... */
                        else {
@@ -301,6 +307,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext 
*ac, float x, int channe
 
                                        /* changes to NLA-Action occurred */
                                        notifierFlags |= ND_NLA_ACTCHANGE;
+                                       ale->update |= ANIM_UPDATE_DEPS;
                                }
                                else {
                                        /* select/deselect */
@@ -330,6 +337,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext 
*ac, float x, int channe
        }
 
        /* free channels */
+       ANIM_animdata_update(ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        /* return the notifier-flags set */
@@ -411,6 +419,7 @@ void NLA_OT_channels_click(wmOperatorType *ot)
 static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
 {
        bAnimContext ac;
+       ID *id = NULL;
        AnimData *adt = NULL;
        int channel_index = RNA_int_get(op->ptr, "channel_index");
 
@@ -429,6 +438,7 @@ static int nlachannels_pushdown_exec(bContext *C, 
wmOperator *op)
                        return OPERATOR_CANCELLED;
                }
                else {
+                       id = adt_ptr.id.data;
                        adt = adt_ptr.data;
                }
        }
@@ -457,6 +467,7 @@ static int nlachannels_pushdown_exec(bContext *C, 
wmOperator *op)
 
                /* grab AnimData from the channel */
                adt = ale->adt;
+               id = ale->id;
 
                /* we don't need anything here anymore, so free it all */
                ANIM_animdata_freelist(&anim_data);
@@ -479,6 +490,8 @@ static int nlachannels_pushdown_exec(bContext *C, 
wmOperator *op)
        else {
                /* 'push-down' action - only usable when not in TweakMode */
                BKE_nla_action_pushdown(adt);
+
+               DEG_id_tag_update_ex(CTX_data_main(C), id, DEG_TAG_TIME | 
DEG_TAG_COPY_ON_WRITE);
        }
 
        /* set notifier that things have changed */
@@ -597,18 +610,21 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool 
above_sel)
                        if (above_sel) {
                                /* just add a new one above this one */
                                BKE_nlatrack_add(adt, nlt);
+                               ale->update = ANIM_UPDATE_DEPS;
                                added = true;
                        }
                        else if ((lastAdt == NULL) || (adt != lastAdt)) {
                                /* add one track to the top of the owning 
AnimData's stack, then don't add anymore to this stack */
                                BKE_nlatrack_add(adt, NULL);
                                lastAdt = adt;
+                               ale->update = ANIM_UPDATE_DEPS;
                                added = true;
                        }
                }
        }
 
        /* free temp data */
+       ANIM_animdata_update(ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        return added;
@@ -637,11 +653,13 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac)
                if (BLI_listbase_is_empty(&adt->nla_tracks)) {
                        /* add new track to this AnimData block then */
                        BKE_nlatrack_add(adt, NULL);
+                       ale->update = ANIM_UPDATE_DEPS;
                        added = true;
                }
        }
 
        /* cleanup */
+       ANIM_animdata_update(ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        return added;
@@ -665,6 +683,8 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator 
*op)
 
        /* done? */
        if (op_done) {
+               DEG_relations_tag_update(CTX_data_main(C));
+
                /* set notifier that things have changed */
                WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, 
NULL);
 
@@ -732,12 +752,16 @@ static int nlaedit_delete_tracks_exec(bContext *C, 
wmOperator *UNUSED(op))
 
                        /* call delete on this track - deletes all strips too */
                        BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
+                       ale->update = ANIM_UPDATE_DEPS;
                }
        }
 
        /* free temp data */
+       ANIM_animdata_update(&ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
+       DEG_relations_tag_update(ac.bmain);
+
        /* set notifier that things have changed */
        WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
 
diff --git a/source/blender/editors/space_nla/nla_edit.c 
b/source/blender/editors/space_nla/nla_edit.c
index edbdefdcf22..387560c3f6c 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -67,6 +67,8 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "DEG_depsgraph_build.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -90,9 +92,12 @@ void ED_nla_postop_refresh(bAnimContext *ac)
        for (ale = anim_data.first; ale; ale = ale->next) {
                /* performing auto-blending, extend-mode validation, etc. */
                BKE_nla_validate_state(ale->data);
+
+               ale->update |= ANIM_UPDATE_DEPS;
        }
 
        /* free temp memory */
+       ANIM_animdata_update(ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 }
 
@@ -144,9 +149,12 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, 
wmOperator *op)
                                BKE_nlatrack_solo_toggle(adt, nlt);
                        }
                }
+
+               ale->update |= ANIM_UPDATE_DEPS;
        }
 
        /* free temp data */
+       ANIM_animdata_update(&ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        /* if we managed to enter tweakmode on at least one AnimData block,
@@ -223,9 +231,12 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool 
do_solo)
 
                /* to be sure that we're doing everything right, just exit 
tweakmode... */
                BKE_nla_tweakmode_exit(adt);
+
+               ale->update |= ANIM_UPDATE_DEPS;
        }
 
        /* free temp data */
+       ANIM_animdata_update(ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        /* if we managed to enter tweakmode on at least one AnimData block,
@@ -669,6 +680,8 @@ static int nlaedit_add_actionclip_exec(bContext *C, 
wmOperator *op)
        /* refresh auto strip properties */
        ED_nla_postop_refresh(&ac);
 
+       DEG_relations_tag_update(ac.bmain);
+
        /* set notifier that things have changed */
        WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
 
@@ -939,9 +952,12 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator 
*UNUSED(op))
                        if (strip->flag & NLASTRIP_FLAG_SELECT)
                                BKE_nlastrip_validate_name(adt, strip);
                }
+
+               ale->update |= ANIM_UPDATE_DEPS;
        }
 
        /* free temp data */
+       ANIM_animdata_update(&ac, &anim_data);
        ANIM_animdata_freelist(&anim_data);
 
        /* set notifier that things have changed */
@@ -991,9 +1007,12 @@ static int nlaedit_remove_meta_exec(bContext *C, 
wmOperator *UNUSED(op))
 
                /* clear all selected meta-strips, regardless of whether they 
are temporary or not */
                BKE_nlastrips_clear_metas(&nlt->strips, 1, 0);
+
+               ale->update |= ANIM_UPDATE_D

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to