Rename any instance of scene layer or render layer in code with view layer
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_relations_layer_collection.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_relations_layer.cc
28  *  \ingroup depsgraph
29  *
30  * Methods for constructing depsgraph
31  */
32
33 #include "intern/builder/deg_builder_relations.h"
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <cstring>  /* required for STREQ later on. */
38
39 #include "MEM_guardedalloc.h"
40
41 extern "C" {
42 #include "BLI_blenlib.h"
43 #include "BLI_utildefines.h"
44
45 #include "DNA_node_types.h"
46 #include "DNA_object_types.h"
47 #include "DNA_scene_types.h"
48
49 #include "BKE_layer.h"
50 #include "BKE_main.h"
51 #include "BKE_node.h"
52
53 #include "DEG_depsgraph.h"
54 #include "DEG_depsgraph_build.h"
55 } /* extern "C" */
56
57 #include "intern/builder/deg_builder.h"
58 #include "intern/builder/deg_builder_pchanmap.h"
59
60 #include "intern/nodes/deg_node.h"
61 #include "intern/nodes/deg_node_component.h"
62 #include "intern/nodes/deg_node_operation.h"
63
64 #include "intern/depsgraph_intern.h"
65 #include "intern/depsgraph_types.h"
66
67 #include "util/deg_util_foreach.h"
68
69 namespace DEG {
70
71 void DepsgraphRelationBuilder::build_layer_collection(
72         LayerCollection *layer_collection,
73         LayerCollectionState *state)
74 {
75         OperationKey layer_key(&scene_->id,
76                                DEG_NODE_TYPE_LAYER_COLLECTIONS,
77                                DEG_OPCODE_VIEW_LAYER_EVAL,
78                                layer_collection->scene_collection->name,
79                                state->index);
80         add_relation(state->prev_key, layer_key, "Layer collection order");
81
82         ++state->index;
83         state->prev_key = layer_key;
84
85         /* Recurs into nested layer collections. */
86         build_layer_collections(&layer_collection->layer_collections, state);
87 }
88
89 void DepsgraphRelationBuilder::build_layer_collections(
90         ListBase *layer_collections,
91         LayerCollectionState *state)
92 {
93         LINKLIST_FOREACH (LayerCollection *, layer_collection, layer_collections) {
94                 /* Recurs into the layer. */
95                 build_layer_collection(layer_collection, state);
96         }
97 }
98
99 void DepsgraphRelationBuilder::build_view_layer_collections(
100         ViewLayer *view_layer)
101 {
102         LayerCollectionState state;
103         state.index = 0;
104
105         OperationKey init_key(&scene_->id,
106                               DEG_NODE_TYPE_LAYER_COLLECTIONS,
107                               DEG_OPCODE_VIEW_LAYER_INIT,
108                               view_layer->name);
109         OperationKey done_key(&scene_->id,
110                               DEG_NODE_TYPE_LAYER_COLLECTIONS,
111                               DEG_OPCODE_VIEW_LAYER_DONE,
112                               view_layer->name);
113
114         state.init_key = init_key;
115         state.done_key = done_key;
116         state.prev_key = init_key;
117
118         build_layer_collections(&view_layer->layer_collections, &state);
119
120         add_relation(state.prev_key, done_key, "Layer collection order");
121 }
122
123 }  // namespace DEG