Depsgraph: Handle key->object relations from object builder
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 09:53:04 +0000 (11:53 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 10:36:51 +0000 (12:36 +0200)
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h

index 037d441269f64c984769182b8a8795d246d82c01..607e1389c5f58d7ff46d72df8f2d064568f599e1 100644 (file)
@@ -990,6 +990,9 @@ void DepsgraphNodeBuilder::build_cloth(Object *object)
 /* Shapekeys */
 void DepsgraphNodeBuilder::build_shapekeys(Key *key)
 {
+       if (built_map_.checkIsBuiltAndTag(key)) {
+               return;
+       }
        build_animdata(&key->id);
        add_operation_node(&key->id,
                           DEG_NODE_TYPE_GEOMETRY,
index 9afde9945ace6d507dc86ecd534cc76efb9d400f..d91d80cead67994a33481d7d86f085b06aee99e2 100644 (file)
@@ -1646,27 +1646,13 @@ void DepsgraphRelationBuilder::build_cloth(Object *object,
 }
 
 /* Shapekeys */
-void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key)
+void DepsgraphRelationBuilder::build_shapekeys(Key *key)
 {
-       ComponentKey obdata_key(obdata, DEG_NODE_TYPE_GEOMETRY);
-
+       if (built_map_.checkIsBuiltAndTag(key)) {
+               return;
+       }
        /* attach animdata to geometry */
        build_animdata(&key->id);
-
-       if (key->adt) {
-               // TODO: this should really be handled in build_animdata, since many of these cases will need it
-               if (key->adt->action || key->adt->nla_tracks.first) {
-                       ComponentKey adt_key(&key->id, DEG_NODE_TYPE_ANIMATION);
-                       add_relation(adt_key, obdata_key, "Animation");
-               }
-
-               /* NOTE: individual shapekey drivers are handled above already */
-       }
-
-       /* attach to geometry */
-       // XXX: aren't shapekeys now done as a pseudo-modifier on object?
-       //ComponentKey key_key(&key->id, DEG_NODE_TYPE_GEOMETRY); // FIXME: this doesn't exist
-       //add_relation(key_key, obdata_key, "Shapekeys");
 }
 
 /**
@@ -1808,6 +1794,17 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
        }
        /* Object data datablock. */
        build_object_data_geometry_datablock((ID *)object->data);
+       Key *key = BKE_key_from_object(object);
+       if (key != NULL) {
+               if (key->adt != NULL) {
+                       if (key->adt->action || key->adt->nla_tracks.first) {
+                               ComponentKey obdata_key((ID *)object->data,
+                                                       DEG_NODE_TYPE_GEOMETRY);
+                               ComponentKey adt_key(&key->id, DEG_NODE_TYPE_ANIMATION);
+                               add_relation(adt_key, obdata_key, "Animation");
+                       }
+               }
+       }
 }
 
 void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
@@ -1820,7 +1817,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
        /* ShapeKeys. */
        Key *key = BKE_key_from_id(obdata);
        if (key != NULL) {
-               build_shapekeys(obdata, key);
+               build_shapekeys(key);
        }
        /* Link object data evaluation node to exit operation. */
        OperationKey obdata_geom_eval_key(obdata,
index e61fe40d93ecaa44ec56cb61253393a736407226..ec932eccc9f1424a1a52ac6c3a4838720e969fc9 100644 (file)
@@ -248,7 +248,7 @@ struct DepsgraphRelationBuilder
                                 RootPChanMap *root_map);
        void build_rig(Object *object);
        void build_proxy_rig(Object *object);
-       void build_shapekeys(ID *obdata, Key *key);
+       void build_shapekeys(Key *key);
        void build_armature(bArmature *armature);
        void build_camera(Camera *camera);
        void build_lamp(Lamp *lamp);