Blender V5.3
deg_builder_relations_view_layer.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
12
13#include <cstdlib>
14#include <cstring> /* required for STREQ later on. */
15
17#include "DNA_scene_types.h"
18
19#include "BLI_listbase.hh"
20
21#include "BKE_layer.hh"
22#include "BKE_main.hh"
23#include "BKE_node.hh"
24
25#include "DEG_depsgraph.hh"
27
29
35
36namespace blender::deg {
37
39 const ComponentKey &parent_hierarchy_key)
40{
41 const int hide_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? COLLECTION_HIDE_VIEWPORT :
43
44 Collection *collection = layer_collection->collection;
45
46 if (collection->flag & hide_flag) {
47 return;
48 }
49
50 /* Exclude is not inherited: an excluded layer is skipped but its children are still built. */
51 ComponentKey child_hierarchy_key = parent_hierarchy_key;
52 if ((layer_collection->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
53 build_collection(layer_collection, collection);
54
55 /* A collection that is linked multiple times can end up with the same parent hierarchy key
56 * more than once, for example when linked directly into the scene as well as under an
57 * excluded collection. Check for an existing relation to avoid duplicates. */
58 const ComponentKey collection_hierarchy_key{&collection->id, NodeType::HIERARCHY};
59 add_relation(parent_hierarchy_key,
60 collection_hierarchy_key,
61 "Collection hierarchy",
63 child_hierarchy_key = collection_hierarchy_key;
64 }
65
66 for (LayerCollection &child : layer_collection->layer_collections) {
67 build_layer_collections(&child, child_hierarchy_key);
68 }
69}
70
72{
73 const ComponentKey scene_hierarchy_key{&scene_->id, NodeType::HIERARCHY};
74
75 for (LayerCollection &layer_collection : view_layer->layer_collections) {
76 build_layer_collections(&layer_collection, scene_hierarchy_key);
77 }
78}
79
81{
82 if (fls->group != nullptr) {
83 build_collection(nullptr, fls->group);
84 }
85 if (fls->linestyle != nullptr) {
87 }
88}
89
91 ViewLayer *view_layer,
92 eDepsNode_LinkedState_Type linked_state)
93{
94 /* Setup currently building context. */
95 scene_ = scene;
96 BKE_view_layer_synced_ensure(*bmain_, scene, view_layer);
97 /* Scene objects. */
98 /* NOTE: Nodes builder requires us to pass evaluated base because it's being
99 * passed to the evaluation functions. During relations builder we only
100 * do nullptr-pointer check of the base, so it's fine to pass original one. */
101 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
102 if (need_pull_base_into_graph(&base)) {
104 }
105 }
106
108
109 build_scene_camera(scene);
110 /* Rigidbody. */
111 if (scene->rigidbody_world != nullptr) {
112 build_rigidbody(scene);
113 }
114 /* Scene's animation and drivers. */
115 if (scene->adt != nullptr) {
116 build_animdata(&scene->id);
117 }
118 /* World. */
119 if (scene->world != nullptr) {
120 build_world(scene->world);
121 }
122 /* Cache file. */
123 for (CacheFile &cachefile : bmain_->cachefiles) {
124 build_cachefile(&cachefile);
125 }
126 /* Masks. */
127 for (Mask &mask : bmain_->masks) {
129 }
130 /* Movie clips. */
131 for (MovieClip &clip : bmain_->movieclips) {
132 build_movieclip(&clip);
133 }
134 /* Material override. */
135 if (view_layer->mat_override != nullptr) {
136 build_material(view_layer->mat_override);
137 }
138 /* World override */
139 if (view_layer->world_override != nullptr) {
140 build_world(view_layer->world_override);
141 }
142 /* Freestyle linesets. */
143 for (FreestyleLineSet &fls : view_layer->freestyle_config.linesets) {
145 }
146 /* Scene parameters, compositor and such. */
149 /* Make final scene evaluation dependent on view layer evaluation. */
150 OperationKey scene_view_layer_key(
152 ComponentKey scene_eval_key(&scene->id, NodeType::SCENE);
153 add_relation(scene_view_layer_key, scene_eval_key, "View Layer -> Scene Eval");
154 /* Sequencer. */
155 if (linked_state == DEG_ID_LINKED_DIRECTLY) {
156 build_scene_audio(scene);
158 }
159 /* Build all set scenes. */
160 if (scene->set != nullptr) {
161 ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
162 build_view_layer(scene->set, set_view_layer, DEG_ID_LINKED_VIA_SET);
163 }
164}
165
166} // namespace blender::deg
Object groups, one object can be in many groups at once.
virtual bool need_pull_base_into_graph(const Base *base)
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle)
virtual void build_collection(LayerCollection *from_layer_collection, Collection *collection)
virtual void build_object_from_view_layer_base(Object *object)
virtual void build_material(Material *ma, ID *owner=nullptr)
virtual void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state)
virtual void build_view_layer_collections(ViewLayer *view_layer)
virtual void build_movieclip(MovieClip *clip)
Relation * add_relation(const KeyFrom &key_from, const KeyTo &key_to, const char *description, int flags=0)
virtual void build_layer_collections(LayerCollection *layer_collection, const ComponentKey &parent_hierarchy_key)
virtual void build_freestyle_lineset(FreestyleLineSet *fls)
virtual void build_cachefile(CacheFile *cache_file)
@ LAYER_COLLECTION_EXCLUDE
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
@ DAG_EVAL_VIEWPORT
ViewLayer * BKE_view_layer_default_render(const Scene *scene)
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
ListBaseT< FreestyleLineSet > linesets
struct FreestyleLineStyle * linestyle
eLayerCollection_Flag flag
struct Collection * collection
ListBaseT< LayerCollection > layer_collections
ListBaseT< MovieClip > movieclips
Definition BKE_main.hh:419
ListBaseT< CacheFile > cachefiles
Definition BKE_main.hh:422
ListBaseT< Mask > masks
Definition BKE_main.hh:420
struct World * world
struct Scene * set
struct AnimData * adt
struct RigidBodyWorld * rigidbody_world
struct FreestyleConfig freestyle_config
ListBaseT< LayerCollection > layer_collections
struct World * world_override
struct Material * mat_override
eEvaluationMode mode
Definition depsgraph.hh:145