Rename any instance of scene layer or render layer in code with view layer
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_nodes_view_layer.cc
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2013 Blender Foundation.
19  * All rights reserved.
20  *
21  * Original Author: Joshua Leung
22  * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013)
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
28  *  \ingroup depsgraph
29  *
30  * Methods for constructing depsgraph's nodes
31  */
32
33 #include "intern/builder/deg_builder_nodes.h"
34
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 #include "MEM_guardedalloc.h"
39
40 #include "BLI_utildefines.h"
41 #include "BLI_blenlib.h"
42 #include "BLI_string.h"
43
44 extern "C" {
45 #include "DNA_node_types.h"
46 #include "DNA_layer_types.h"
47 #include "DNA_object_types.h"
48 #include "DNA_scene_types.h"
49
50 #include "BKE_layer.h"
51 #include "BKE_main.h"
52 #include "BKE_node.h"
53 } /* extern "C" */
54
55 #include "DEG_depsgraph.h"
56 #include "DEG_depsgraph_build.h"
57
58 #include "intern/builder/deg_builder.h"
59 #include "intern/nodes/deg_node.h"
60 #include "intern/nodes/deg_node_component.h"
61 #include "intern/nodes/deg_node_operation.h"
62 #include "intern/depsgraph_types.h"
63 #include "intern/depsgraph_intern.h"
64 #include "util/deg_util_foreach.h"
65
66 namespace DEG {
67
68 void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
69                                             ViewLayer *view_layer,
70                                             eDepsNode_LinkedState_Type linked_state)
71 {
72         /* scene ID block */
73         add_id_node(&scene->id);
74
75         /* timesource */
76         add_time_source();
77
78         /* build subgraph for set, and link this in... */
79         // XXX: depending on how this goes, that scene itself could probably store its
80         //      own little partial depsgraph?
81         if (scene->set != NULL) {
82                 ViewLayer *set_view_layer = BKE_view_layer_from_scene_get(scene->set);
83                 build_view_layer(scene->set, set_view_layer, DEG_ID_LINKED_VIA_SET);
84         }
85
86         /* Setup currently building context. */
87         scene_ = scene;
88
89         /* scene objects */
90         int select_color = 1;
91         LINKLIST_FOREACH(Base *, base, &view_layer->object_bases) {
92                 /* object itself */
93                 build_object(base->object, linked_state);
94                 base->object->select_color = select_color++;
95         }
96         if (scene->camera != NULL) {
97                 build_object(scene->camera, linked_state);
98         }
99
100         /* rigidbody */
101         if (scene->rigidbody_world) {
102                 build_rigidbody(scene);
103         }
104
105         /* scene's animation and drivers */
106         if (scene->adt) {
107                 build_animdata(&scene->id);
108         }
109
110         /* world */
111         if (scene->world) {
112                 build_world(scene->world);
113         }
114
115         /* compo nodes */
116         if (scene->nodetree) {
117                 build_compositor(scene);
118         }
119
120         /* sequencer */
121         // XXX...
122
123         /* grease pencil */
124         if (scene->gpd) {
125                 build_gpencil(scene->gpd);
126         }
127
128         /* Cache file. */
129         LINKLIST_FOREACH (CacheFile *, cachefile, &bmain_->cachefiles) {
130                 build_cachefile(cachefile);
131         }
132
133         /* Masks. */
134         LINKLIST_FOREACH (Mask *, mask, &bmain_->mask) {
135                 build_mask(mask);
136         }
137
138         /* Movie clips. */
139         LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) {
140                 build_movieclip(clip);
141         }
142
143         /* Collections. */
144         build_view_layer_collections(view_layer);
145
146         /* Parameters evaluation for scene relations mainly. */
147         add_operation_node(&scene->id,
148                            DEG_NODE_TYPE_PARAMETERS,
149                            NULL,
150                            DEG_OPCODE_PLACEHOLDER,
151                            "Scene Eval");
152 }
153
154 }  // namespace DEG