Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_relations_scene_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_relations_scene.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 #include "BLI_utildefines.h"
42 #include "BLI_blenlib.h"
43
44 extern "C" {
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 } /* extern "C" */
53
54 #include "DEG_depsgraph.h"
55 #include "DEG_depsgraph_build.h"
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_scene_layer(Scene *scene, SceneLayer *scene_layer)
72 {
73         if (scene->set != NULL) {
74                 SceneLayer *set_scene_layer = BKE_scene_layer_from_scene_get(scene->set);
75                 build_scene_layer(scene->set, set_scene_layer);
76         }
77
78         graph_->scene = scene;
79         graph_->scene_layer = scene_layer;
80
81         /* Setup currently building context. */
82         scene_ = scene;
83
84         /* scene objects */
85         LINKLIST_FOREACH(Base *, base, &scene_layer->object_bases) {
86                 build_object(base->object);
87         }
88         if (scene->camera != NULL) {
89                 build_object(scene->camera);
90         }
91
92         /* rigidbody */
93         if (scene->rigidbody_world) {
94                 build_rigidbody(scene);
95         }
96
97         /* scene's animation and drivers */
98         if (scene->adt) {
99                 build_animdata(&scene->id);
100         }
101
102         /* world */
103         if (scene->world) {
104                 build_world(scene->world);
105         }
106
107         /* compo nodes */
108         if (scene->nodetree) {
109                 build_compositor(scene);
110         }
111
112         /* grease pencil */
113         if (scene->gpd) {
114                 build_gpencil(scene->gpd);
115         }
116
117         /* Masks. */
118         LINKLIST_FOREACH (Mask *, mask, &bmain_->mask) {
119                 build_mask(mask);
120         }
121
122         /* Movie clips. */
123         LINKLIST_FOREACH (MovieClip *, clip, &bmain_->movieclip) {
124                 build_movieclip(clip);
125         }
126
127         /* Collections. */
128         build_scene_layer_collections(scene_layer);
129
130         /* TODO(sergey): Do this flush on CoW object? */
131         foreach (OperationDepsNode *node, graph_->operations) {
132                 IDDepsNode *id_node = node->owner->owner;
133                 ID *id = id_node->id_orig;
134                 if (GS(id->name) == ID_OB) {
135                         Object *object = (Object *)id;
136                         object->customdata_mask |= node->customdata_mask;
137                 }
138         }
139 }
140
141 }  // namespace DEG