Fix T53614: New Depsgraph ignores NLA strips
authorJoshua Leung <aligorith@gmail.com>
Mon, 29 Jan 2018 06:01:44 +0000 (19:01 +1300)
committerJoshua Leung <aligorith@gmail.com>
Mon, 29 Jan 2018 06:01:59 +0000 (19:01 +1300)
The new depsgraph was only considering the active action
when attaching relations from the AnimData component/operation
to the properties that are affected by the animation data.
As a result, only properties animated by the active action
were working, while those animated by NLA strips did not change
when playing back/scrubbing the timeline.

This commit fixes this introducing a recursive method to properly
visit all NLA strips, and calling DepsRelBuilder::build_animdata_curves_targets()
on each of those strips.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h

index 81daa8cfb8cd209571be7a974d7ae291f590f108..85ea2c0a8e4352eee97347b8dc7ce8083018d208 100644 (file)
@@ -916,18 +916,7 @@ void DepsgraphRelationBuilder::build_animdata_curves(ID *id)
        ComponentKey adt_key(id, DEG_NODE_TYPE_ANIMATION);
        TimeSourceKey time_src_key;
        add_relation(time_src_key, adt_key, "TimeSrc -> Animation");
-       /* Build relations from animation operation to properties it changes. */
-       build_animdata_curves_targets(id);
-}
-
-void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
-{
-       AnimData *adt = BKE_animdata_from_id(id);
-       if (adt == NULL || adt->action == NULL) {
-               return;
-       }
-       /* Get source operation. */
-       ComponentKey adt_key(id, DEG_NODE_TYPE_ANIMATION);
+       /* Get source operations. */
        DepsNode *node_from = get_node(adt_key);
        BLI_assert(node_from != NULL);
        if (node_from == NULL) {
@@ -935,10 +924,28 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
        }
        OperationDepsNode *operation_from = node_from->get_exit_operation();
        BLI_assert(operation_from != NULL);
+       /* Build relations from animation operation to properties it changes. */
+       if (adt->action != NULL) {
+               build_animdata_curves_targets(id, adt_key,
+                                     operation_from,
+                                     &adt->action->curves);
+       }
+       BLI_LISTBASE_FOREACH(NlaTrack *, nlt, &adt->nla_tracks) {
+               build_animdata_nlastrip_targets(id, adt_key,
+                                               operation_from,
+                                               &nlt->strips);
+       }
+}
+
+void DepsgraphRelationBuilder::build_animdata_curves_targets(
+        ID *id, ComponentKey &adt_key,
+        OperationDepsNode *operation_from,
+        ListBase *curves)
+{
        /* Iterate over all curves and build relations. */
        PointerRNA id_ptr;
        RNA_id_pointer_create(id, &id_ptr);
-       BLI_LISTBASE_FOREACH(FCurve *, fcu, &adt->action->curves) {
+       BLI_LISTBASE_FOREACH(FCurve *, fcu, curves) {
                PointerRNA ptr;
                PropertyRNA *prop;
                int index;
@@ -969,6 +976,25 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
        }
 }
 
+void DepsgraphRelationBuilder::build_animdata_nlastrip_targets(
+        ID *id, ComponentKey &adt_key,
+        OperationDepsNode *operation_from,
+        ListBase *strips)
+{
+       BLI_LISTBASE_FOREACH(NlaStrip *, strip, strips) {
+               if (strip->act != NULL) {
+                       build_animdata_curves_targets(id, adt_key,
+                                                     operation_from,
+                                                     &strip->act->curves);
+               }
+               else if (strip->strips.first != NULL) {
+                       build_animdata_nlastrip_targets(id, adt_key,
+                                                       operation_from,
+                                                       &strip->strips);
+               }
+       }
+}
+
 void DepsgraphRelationBuilder::build_animdata_drivers(ID *id)
 {
        AnimData *adt = BKE_animdata_from_id(id);
index de13ee191229b464745ece715f3f277f4ba589aa..aa55b9f66aed233b3a97cfda0da0045648cad0d8 100644 (file)
@@ -201,7 +201,14 @@ struct DepsgraphRelationBuilder
                               RootPChanMap *root_map);
        void build_animdata(ID *id);
        void build_animdata_curves(ID *id);
-       void build_animdata_curves_targets(ID *id);
+       void build_animdata_curves_targets(ID *id,
+                                          ComponentKey &adt_key,
+                                          OperationDepsNode *operation_from,
+                                          ListBase *curves);
+       void build_animdata_nlastrip_targets(ID *id,
+                                            ComponentKey &adt_key,
+                                            OperationDepsNode *operation_from,
+                                            ListBase *strips);
        void build_animdata_drivers(ID *id);
        void build_driver(ID *id, FCurve *fcurve);
        void build_driver_data(ID *id, FCurve *fcurve);