Commit: ca2484e09005207e7bad90f484de6cbba1013833
Author: Sergey Sharybin
Date:   Tue Apr 10 15:07:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBca2484e09005207e7bad90f484de6cbba1013833

Depsgraph: Remove function bindings with collections

Use single function to evaluate all the collections for the given view layer.

This way we avoid need to get scene ID sub-data. Similar to pchan index, this
allows us to avoid build-time scene expansion, which also simplifies update of
the scene datablock.

Well, sort of. There is still work to be done to get rid of build-time scene
datablock expansion, which includes:

- Need to pass view layer by index.

  Annoying part would be to get actual view layer for that index. In practice
  doing list lookup might not be such a bad idea, since such lookup will not
  happen very often, and it is unlikely to have more than handful of view
  layer anyway.

  Other idea could be to use view layer from evaluation context.
  Or maybe from depsgraph, which is supposed to be in the context. Can have
  some assert statements to make sure everything is good.

- Need to get id of base binding for flags flush.

  We can replace that with index-based lookup from an array created by view
  layer evaluation.

Reviewers: dfelinto

Differential Revision: https://developer.blender.org/D3141

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

M       source/blender/blenkernel/BKE_layer.h
M       source/blender/blenkernel/intern/group.c
M       source/blender/blenkernel/intern/layer.c
M       source/blender/depsgraph/CMakeLists.txt
M       source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M       source/blender/depsgraph/intern/builder/deg_builder_nodes.h
D       
source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc
M       source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
M       source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M       source/blender/depsgraph/intern/builder/deg_builder_relations.h
D       
source/blender/depsgraph/intern/builder/deg_builder_relations_layer_collection.cc
M       
source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
M       source/blender/depsgraph/intern/depsgraph_tag.cc
M       source/blender/depsgraph/intern/depsgraph_type_defines.cc
M       source/blender/depsgraph/intern/depsgraph_types.h

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

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index 8140dc5b31d..7542e9da2d5 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -169,14 +169,9 @@ void BKE_collection_engine_property_value_set_bool(struct 
IDProperty *props, con
 
 /* evaluation */
 
-void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext 
*eval_ctx,
-                                         struct ID *owner_id,
-                                         struct ViewLayer *view_layer);
-void BKE_layer_eval_layer_collection(const struct EvaluationContext *eval_ctx,
-                                     struct LayerCollection *layer_collection,
-                                     struct LayerCollection 
*parent_layer_collection);
-void BKE_layer_eval_layer_collection_post(const struct EvaluationContext 
*eval_ctx,
-                                          struct ViewLayer *view_layer);
+void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx,
+                               struct ID *owner_id,
+                               struct ViewLayer *view_layer);
 
 /* iterators */
 
diff --git a/source/blender/blenkernel/intern/group.c 
b/source/blender/blenkernel/intern/group.c
index 20da1e7b7ac..7566d370c45 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -381,33 +381,9 @@ void BKE_group_handle_recalc_and_update(const struct 
EvaluationContext *eval_ctx
 
 /* ******** Dependency graph evaluation ******** */
 
-static void group_eval_layer_collections(
-        const struct EvaluationContext *eval_ctx,
-        Group *group,
-        ListBase *layer_collections,
-        LayerCollection *parent_layer_collection)
-{
-       LISTBASE_FOREACH (LayerCollection *, layer_collection, 
layer_collections) {
-               /* Evaluate layer collection itself. */
-               BKE_layer_eval_layer_collection(eval_ctx,
-                                               layer_collection,
-                                               parent_layer_collection);
-               /* Evaluate nested collections. */
-               group_eval_layer_collections(eval_ctx,
-                                            group,
-                                            
&layer_collection->layer_collections,
-                                            layer_collection);
-       }
-}
-
 void BKE_group_eval_view_layers(const struct EvaluationContext *eval_ctx,
                                 Group *group)
 {
        DEG_debug_print_eval(__func__, group->id.name, group);
-       BKE_layer_eval_layer_collection_pre(eval_ctx, &group->id, 
group->view_layer);
-       group_eval_layer_collections(eval_ctx,
-                                    group,
-                                    &group->view_layer->layer_collections,
-                                    NULL);
-       BKE_layer_eval_layer_collection_post(eval_ctx, group->view_layer);
+       BKE_layer_eval_view_layer(eval_ctx, &group->id, group->view_layer);
 }
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index 65e76e619f2..8e53dea0c24 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -2253,8 +2253,7 @@ static void idproperty_reset(IDProperty **props, 
IDProperty *props_ref)
        }
 }
 
-void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext 
*UNUSED(eval_ctx),
-                                         ID *owner_id, ViewLayer *view_layer)
+static void layer_eval_layer_collection_pre(ID *owner_id, ViewLayer 
*view_layer)
 {
        DEG_debug_print_eval(__func__, view_layer->name, view_layer);
        Scene *scene = (GS(owner_id->name) == ID_SCE) ? (Scene *)owner_id : 
NULL;
@@ -2296,9 +2295,9 @@ static bool layer_collection_visible_get(const 
EvaluationContext *eval_ctx, Laye
        }
 }
 
-void BKE_layer_eval_layer_collection(const EvaluationContext *eval_ctx,
-                                     LayerCollection *layer_collection,
-                                     LayerCollection *parent_layer_collection)
+static void layer_eval_layer_collection(const EvaluationContext *eval_ctx,
+                                        LayerCollection *layer_collection,
+                                        LayerCollection 
*parent_layer_collection)
 {
        if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) {
                /* TODO)sergey): Try to make it more generic and handled by 
depsgraph messaging. */
@@ -2356,8 +2355,7 @@ void BKE_layer_eval_layer_collection(const 
EvaluationContext *eval_ctx,
        }
 }
 
-void BKE_layer_eval_layer_collection_post(const struct EvaluationContext 
*UNUSED(eval_ctx),
-                                          ViewLayer *view_layer)
+static void layer_eval_layer_collection_post(ViewLayer *view_layer)
 {
        DEG_debug_print_eval(__func__, view_layer->name, view_layer);
        /* if base is not selectabled, clear select */
@@ -2368,6 +2366,34 @@ void BKE_layer_eval_layer_collection_post(const struct 
EvaluationContext *UNUSED
        }
 }
 
+static void layer_eval_collections_recurse(const EvaluationContext *eval_ctx,
+                                           ListBase *layer_collections,
+                                           LayerCollection 
*parent_layer_collection)
+{
+       for (LayerCollection *layer_collection = layer_collections->first;
+            layer_collection != NULL;
+            layer_collection = layer_collection->next)
+       {
+               layer_eval_layer_collection(eval_ctx,
+                                           layer_collection,
+                                           parent_layer_collection);
+               layer_eval_collections_recurse(eval_ctx,
+                                              
&layer_collection->layer_collections,
+                                              layer_collection);
+       }
+}
+
+void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx,
+                               struct ID *owner_id,
+                               struct ViewLayer *view_layer)
+{
+       layer_eval_layer_collection_pre(owner_id, view_layer);
+       layer_eval_collections_recurse(eval_ctx,
+                                      &view_layer->layer_collections,
+                                      NULL);
+       layer_eval_layer_collection_post(view_layer);
+}
+
 /**
  * Free any static allocated memory.
  */
diff --git a/source/blender/depsgraph/CMakeLists.txt 
b/source/blender/depsgraph/CMakeLists.txt
index c2f69343456..8f6eee244f7 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -44,13 +44,11 @@ set(SRC
        intern/builder/deg_builder_cycle.cc
        intern/builder/deg_builder_map.cc
        intern/builder/deg_builder_nodes.cc
-       intern/builder/deg_builder_nodes_layer_collection.cc
        intern/builder/deg_builder_nodes_rig.cc
        intern/builder/deg_builder_nodes_view_layer.cc
        intern/builder/deg_builder_pchanmap.cc
        intern/builder/deg_builder_relations.cc
        intern/builder/deg_builder_relations_keys.cc
-       intern/builder/deg_builder_relations_layer_collection.cc
        intern/builder/deg_builder_relations_rig.cc
        intern/builder/deg_builder_relations_view_layer.cc
        intern/builder/deg_builder_transitive.cc
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index eff6b34fee6..338d1bc7572 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -414,7 +414,7 @@ void DepsgraphNodeBuilder::build_group(Group *group)
                           function_bind(BKE_group_eval_view_layers,
                                         _1,
                                         group_cow),
-                          DEG_OPCODE_VIEW_LAYER_DONE);
+                          DEG_OPCODE_VIEW_LAYER_EVAL);
 }
 
 void DepsgraphNodeBuilder::build_object(Base *base,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h 
b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index fd72ae527b8..8c2885614fb 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -214,17 +214,6 @@ struct DepsgraphNodeBuilder {
        void build_movieclip(MovieClip *clip);
        void build_lightprobe(Object *object);
 
-       struct LayerCollectionState {
-               int index;
-               LayerCollection *parent;
-       };
-       void build_layer_collection(ID *owner_id,
-                                   LayerCollection *layer_collection,
-                                   LayerCollectionState *state);
-       void build_layer_collections(ID *owner_id,
-                                    ListBase *layer_collections,
-                                    LayerCollectionState *state);
-       void build_view_layer_collections(ID *owner_id, ViewLayer *view_layer);
 protected:
        struct SavedEntryTag {
                ID *id;
diff --git 
a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc
deleted file mode 100644
index 2ee526b7128..00000000000
--- 
a/source/blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2013 Blender Foundation.
- * All rights reserved.
- *
- * Original Author: Joshua Leung
- * Contributor(s): Based on original depsgraph.c code - Blender Foundation 
(2005-2013)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file 
blender/depsgraph/intern/builder/deg_builder_nodes_layer_collection.cc
- *  \ingroup depsgraph
- *
- * Methods for constructing depsgraph's nodes
- */
-
-#include "intern/builder/deg_builder_nodes.h"
-
-#include <stdio.h>
-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to