Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 16:59:04 +0000 (17:59 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 16:59:04 +0000 (17:59 +0100)
1  2 
source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc

index 5f7dbb3dd840a06d5b5044e8c35d0f0bdc98e3a8,3c523b1a23c336504a87a703a5fa0d9074801dc0..408ec96f5fa87574045eebbf83564c7d8593c0bc
@@@ -65,74 -63,45 +65,61 @@@ extern "C" 
  
  namespace DEG {
  
 -void DepsgraphNodeBuilder::build_scene(Scene *scene)
 +void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
 +                                            ViewLayer *view_layer,
 +                                            eDepsNode_LinkedState_Type linked_state)
  {
-       /* scene ID block */
 +      Scene *scene_cow;
 +      ViewLayer *view_layer_cow;
 +      if (DEG_depsgraph_use_copy_on_write()) {
 +              /* Make sure we've got ID node, so we can get pointer to CoW datablock.
 +               */
 +              scene_cow = expand_cow_datablock(scene);
 +              view_layer_cow = (ViewLayer *)BLI_findstring(
 +                      &scene_cow->view_layers,
 +                      view_layer->name,
 +                      offsetof(ViewLayer, name));
 +      }
 +      else {
 +              scene_cow = scene;
 +              view_layer_cow = view_layer;
 +      }
+       /* Scene ID block. */
        add_id_node(&scene->id);
--      /* timesource */
++      /* Rimesource. */
        add_time_source();
 -      /* build subgraph for set, and link this in... */
 -      // XXX: depending on how this goes, that scene itself could probably store its
 -      //      own little partial depsgraph?
 -      if (scene->set != NULL) {
 -              build_scene(scene->set);
 -      }
        /* Setup currently building context. */
        scene_ = scene;
--      /* scene objects */
 -      LINKLIST_FOREACH (Base *, base, &scene->base) {
 -              Object *object = base->object;
 -              build_object(base, object);
++      /* Scene objects. */
 +      int select_color = 1;
 +      LINKLIST_FOREACH(Base *, base, &view_layer_cow->object_bases) {
 +              /* object itself */
 +              build_object(base, base->object, linked_state);
 +              base->object->select_color = select_color++;
 +      }
 +      if (scene->camera != NULL) {
 +              build_object(NULL, scene->camera, DEG_ID_LINKED_INDIRECTLY);
        }
-       /* rigidbody */
-       if (scene->rigidbody_world) {
+       /* Rigidbody. */
+       if (scene->rigidbody_world != NULL) {
                build_rigidbody(scene);
        }
-       /* scene's animation and drivers */
-       if (scene->adt) {
+       /* Scene's animation and drivers. */
+       if (scene->adt != NULL) {
                build_animdata(&scene->id);
        }
-       /* world */
-       if (scene->world) {
+       /* World. */
+       if (scene->world != NULL) {
                build_world(scene->world);
        }
-       /* compo nodes */
-       if (scene->nodetree) {
 -      /* Compositor nodes. */
++      /* Compositor nodes */
+       if (scene->nodetree != NULL) {
                build_compositor(scene);
        }
-       /* sequencer */
-       // XXX...
-       /* grease pencil */
-       if (scene->gpd) {
+       /* Grease pencil. */
+       if (scene->gpd != NULL) {
                build_gpencil(scene->gpd);
        }
        /* Cache file. */
        LINKLIST_FOREACH (CacheFile *, cachefile, &bmain_->cachefiles) {
                build_cachefile(cachefile);
        LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) {
                build_movieclip(clip);
        }
 +      /* Collections. */
 +      build_view_layer_collections(scene_cow, view_layer_cow);
        /* Parameters evaluation for scene relations mainly. */
        add_operation_node(&scene->id,
                           DEG_NODE_TYPE_PARAMETERS,
                           NULL,
                           DEG_OPCODE_PLACEHOLDER,
                           "Scene Eval");
 +      /* Build all set scenes. */
 +      if (scene->set != NULL) {
 +              ViewLayer *set_view_layer = BKE_view_layer_from_scene_get(scene->set);
 +              build_view_layer(scene->set, set_view_layer, DEG_ID_LINKED_VIA_SET);
 +      }
  }
  
  }  // namespace DEG
index d23fdaacf08e279ec37429c705f3d3e6735fe64a,feb32442cb7163d997679890f845e5b916e04244..2058fd37716513b40b2abcb24e98d2f242091ed7
@@@ -68,44 -67,38 +68,37 @@@ extern "C" 
  
  namespace DEG {
  
 -void DepsgraphRelationBuilder::build_scene(Scene *scene)
 +void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_layer)
  {
 -      if (scene->set != NULL) {
 -              build_scene(scene->set);
 -      }
        /* Setup currently building context. */
        scene_ = scene;
-       /* scene objects */
+       /* Scene objects. */
 -      LINKLIST_FOREACH (Base *, base, &scene->base) {
 -              Object *object = base->object;
 -              build_object(object);
 +      LINKLIST_FOREACH(Base *, base, &view_layer->object_bases) {
 +              build_object(base, base->object);
 +      }
 +      if (scene->camera != NULL) {
 +              build_object(NULL, scene->camera);
        }
-       /* rigidbody */
-       if (scene->rigidbody_world) {
+       /* Rigidbody. */
+       if (scene->rigidbody_world != NULL) {
                build_rigidbody(scene);
        }
-       /* scene's animation and drivers */
-       if (scene->adt) {
+       /* Scene's animation and drivers. */
+       if (scene->adt != NULL) {
                build_animdata(&scene->id);
        }
-       /* world */
-       if (scene->world) {
+       /* World. */
+       if (scene->world != NULL) {
                build_world(scene->world);
        }
-       /* compo nodes */
-       if (scene->nodetree) {
+       /* Compositor nodes. */
+       if (scene->nodetree != NULL) {
                build_compositor(scene);
        }
-       /* grease pencil */
-       if (scene->gpd) {
+       /* Grease pencil. */
+       if (scene->gpd != NULL) {
                build_gpencil(scene->gpd);
        }
        /* Masks. */
        LINKLIST_FOREACH (Mask *, mask, &bmain_->mask) {
                build_mask(mask);
        LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) {
                build_movieclip(clip);
        }
 -      for (Depsgraph::OperationNodes::const_iterator it_op = graph_->operations.begin();
 -           it_op != graph_->operations.end();
 -           ++it_op)
 -      {
 -              OperationDepsNode *node = *it_op;
 +      /* Collections. */
 +      build_view_layer_collections(view_layer);
 +      /* TODO(sergey): Do this flush on CoW object? */
 +      foreach (OperationDepsNode *node, graph_->operations) {
                IDDepsNode *id_node = node->owner->owner;
 -              ID *id = id_node->id;
 +              ID *id = id_node->id_orig;
                if (GS(id->name) == ID_OB) {
                        Object *object = (Object *)id;
                        object->customdata_mask |= node->customdata_mask;
                }
        }
 +      /* Build all set scenes. */
 +      if (scene->set != NULL) {
 +              ViewLayer *set_view_layer = BKE_view_layer_from_scene_get(scene->set);
 +              build_view_layer(scene->set, set_view_layer);
 +      }
 +
 +      graph_->scene = scene;
 +      graph_->view_layer = view_layer;
  }
  
  }  // namespace DEG