Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_nodes.cc
index 02d20913177fa03fb0fe3613969faf7c73edfb80..ec60d86ec82598db323bcbc1409284aafa06e87b 100644 (file)
@@ -86,6 +86,7 @@ extern "C" {
 #include "BKE_mesh.h"
 #include "BKE_mball.h"
 #include "BKE_modifier.h"
+#include "BKE_movieclip.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
 #include "BKE_particle.h"
@@ -174,7 +175,9 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
 
 IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag)
 {
-#ifdef WITH_COPY_ON_WRITE
+       if (!DEG_depsgraph_use_copy_on_write()) {
+               return m_graph->add_id_node(id);
+       }
        IDDepsNode *id_node = NULL;
        ID *id_cow = (ID *)BLI_ghash_lookup(m_cow_id_hash, id);
        if (id_cow != NULL) {
@@ -197,10 +200,6 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag)
                    "", -1);
                m_graph->operations.push_back(op_cow);
        }
-#else
-       IDDepsNode *id_node = m_graph->add_id_node(id);
-       UNUSED_VARS(do_tag);
-#endif
        return id_node;
 }
 
@@ -358,23 +357,25 @@ void DepsgraphNodeBuilder::begin_build(Main *bmain) {
        }
        FOREACH_NODETREE_END;
 
-#ifdef WITH_COPY_ON_WRITE
-       /* Store existing copy-on-write versions of datablock, so we can re-use
-        * them for new ID nodes.
-        */
-       m_cow_id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
-       GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, m_graph->id_hash)
-       {
-               if (GS(id_node->id_orig->name) != ID_SCE) {
-                       continue;
-               }
-               if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
-                       BLI_ghash_insert(m_cow_id_hash, id_node->id_orig, id_node->id_cow);
-                       id_node->id_cow = NULL;
+       if (DEG_depsgraph_use_copy_on_write()) {
+               /* Store existing copy-on-write versions of datablock, so we can re-use
+                * them for new ID nodes.
+                */
+               m_cow_id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
+               GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, m_graph->id_hash)
+               {
+                       if (GS(id_node->id_orig->name) != ID_SCE) {
+                               continue;
+                       }
+                       if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
+                               BLI_ghash_insert(m_cow_id_hash,
+                                                id_node->id_orig,
+                                                id_node->id_cow);
+                               id_node->id_cow = NULL;
+                       }
                }
+               GHASH_FOREACH_END();
        }
-       GHASH_FOREACH_END();
-#endif
 
        /* Make sure graph has no nodes left from previous state. */
        m_graph->clear_all_nodes();
@@ -449,7 +450,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob)
                                break;
 
                        case OB_ARMATURE: /* Pose */
-                               if (ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from != NULL) {
+                               if (ID_IS_LINKED(ob) && ob->proxy_from != NULL) {
                                        build_proxy_rig(ob);
                                }
                                else {
@@ -833,25 +834,23 @@ void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object)
 {
        Scene *scene_cow = get_cow_datablock(scene);
        Object *object_cow = get_cow_datablock(object);
-
-       ComponentDepsNode *cache_comp = add_component_node(&object->id,
-                                                          DEG_NODE_TYPE_CACHE);
-       add_operation_node(cache_comp,
+       add_operation_node(&object->id,
+                          DEG_NODE_TYPE_CACHE,
                           function_bind(BKE_object_eval_cloth,
                                         _1,
                                         scene_cow,
                                         object_cow),
-                          DEG_OPCODE_PLACEHOLDER,
-                          "Cloth Modifier");
+                          DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER);
 }
 
 /* Shapekeys */
 void DepsgraphNodeBuilder::build_shapekeys(Key *key)
 {
        build_animdata(&key->id);
-
-       add_operation_node(&key->id, DEG_NODE_TYPE_GEOMETRY, NULL,
-                          DEG_OPCODE_PLACEHOLDER, "Shapekey Eval");
+       add_operation_node(&key->id,
+                          DEG_NODE_TYPE_GEOMETRY,
+                          NULL,
+                          DEG_OPCODE_GEOMETRY_SHAPEKEY);
 }
 
 /* ObData Geometry Evaluation */
@@ -1086,7 +1085,6 @@ void DepsgraphNodeBuilder::build_lamp(Object *ob)
 
        build_animdata(&la->id);
 
-       /* node for obdata */
        add_operation_node(lamp_id,
                           DEG_NODE_TYPE_PARAMETERS,
                           NULL,
@@ -1211,8 +1209,6 @@ void DepsgraphNodeBuilder::build_image(Image *image) {
                return;
        }
        image_id->tag |= LIB_TAG_DOIT;
-       /* Image ID node itself. */
-       add_id_node(image_id);
        /* Placeholder so we can add relations and tag ID node for update. */
        add_operation_node(image_id,
                           DEG_NODE_TYPE_PARAMETERS,
@@ -1237,12 +1233,12 @@ void DepsgraphNodeBuilder::build_gpencil(bGPdata *gpd)
 {
        ID *gpd_id = &gpd->id;
 
-       /* gpencil itself */
-       // XXX: what about multiple users of same datablock? This should only get added once
-       add_id_node(gpd_id);
+       /* TODO(sergey): what about multiple users of same datablock? This should
+        * only get added once.
+        */
 
-       /* The main reason Grease Pencil is included here is because the animation (and drivers)
-        * need to be hosted somewhere...
+       /* The main reason Grease Pencil is included here is because the animation
+        * (and drivers) need to be hosted somewhere.
         */
        build_animdata(gpd_id);
 }
@@ -1250,20 +1246,17 @@ void DepsgraphNodeBuilder::build_gpencil(bGPdata *gpd)
 void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
 {
        ID *cache_file_id = &cache_file->id;
-
-       add_component_node(cache_file_id, DEG_NODE_TYPE_CACHE);
+       /* Animation, */
+       build_animdata(cache_file_id);
+       /* Cache evaluation itself. */
        add_operation_node(cache_file_id, DEG_NODE_TYPE_CACHE, NULL,
                           DEG_OPCODE_PLACEHOLDER, "Cache File Update");
-
-       add_id_node(cache_file_id);
-       build_animdata(cache_file_id);
 }
 
 void DepsgraphNodeBuilder::build_mask(Mask *mask)
 {
        ID *mask_id = &mask->id;
-       add_id_node(mask_id);
-       /* F-Curve based animation/ */
+       /* F-Curve based animation. */
        build_animdata(mask_id);
        /* Animation based on mask's shapes. */
        add_operation_node(mask_id,
@@ -1280,8 +1273,13 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
 void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
 {
        ID *clip_id = &clip->id;
-       add_id_node(clip_id);
+       /* Animation. */
        build_animdata(clip_id);
+       /* Movie clip evaluation. */
+       add_operation_node(clip_id,
+                          DEG_NODE_TYPE_PARAMETERS,
+                          function_bind(BKE_movieclip_eval_update, _1, clip),
+                          DEG_OPCODE_MOVIECLIP_EVAL);
 }
 
 void DepsgraphNodeBuilder::build_lightprobe(Object *object)