Blender V5.0
deg_builder_nodes_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
16#include "DNA_freestyle_types.h"
17#include "DNA_layer_types.h"
18#include "DNA_node_types.h"
19#include "DNA_object_types.h"
20#include "DNA_scene_types.h"
21
22#include "BLI_listbase.h"
23
24#include "BKE_layer.hh"
25#include "BKE_main.hh"
26#include "BKE_node.hh"
27
28#include "DEG_depsgraph.hh"
30
32#include "intern/depsgraph.hh"
36
37namespace blender::deg {
38
40{
41 const int visibility_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? COLLECTION_HIDE_VIEWPORT :
43
45 if (lc->collection->flag & visibility_flag) {
46 continue;
47 }
48 if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
49 build_collection(lc, lc->collection);
50 }
51 build_layer_collections(&lc->layer_collections);
52 }
53}
54
56{
57 if (fls->group != nullptr) {
58 build_collection(nullptr, fls->group);
59 }
60 if (fls->linestyle != nullptr) {
62 }
63}
64
66 ViewLayer *view_layer,
67 eDepsNode_LinkedState_Type linked_state)
68{
69 /* NOTE: Pass view layer index of 0 since after scene evaluated copy there is
70 * only one view layer in there. */
72 /* Scene ID block. */
73 IDNode *id_node = add_id_node(&scene->id);
74 id_node->linked_state = linked_state;
75
77
78 /* Time source. */
80 /* Setup currently building context. */
81 scene_ = scene;
82 view_layer_ = view_layer;
83 /* Get pointer to an evaluated version of scene ID. */
84 Scene *scene_cow = get_cow_datablock(scene);
85 /* Scene objects. */
86 /* NOTE: Base is used for function bindings as-is, so need to pass evaluated base,
87 * but object is expected to be an original one. Hence we go into some
88 * tricks here iterating over the view layer. */
89 int base_index = 0;
90 BKE_view_layer_synced_ensure(scene, view_layer);
92 /* object itself */
93 if (!need_pull_base_into_graph(base)) {
94 continue;
95 }
96
97 /* NOTE: We consider object visible even if it's currently
98 * restricted by the base/restriction flags. Otherwise its drivers
99 * will never be evaluated.
100 *
101 * TODO(sergey): Need to go more granular on visibility checks. */
102 build_object(base_index, base->object, linked_state, true);
103 base_index++;
104
105 if (!graph_->has_animated_visibility) {
106 graph_->has_animated_visibility |= is_object_visibility_animated(base->object);
107 }
108 }
110 build_scene_camera(scene);
111 /* Rigidbody. */
112 if (scene->rigidbody_world != nullptr) {
113 build_rigidbody(scene);
114 }
115 /* Scene's animation and drivers. */
116 if (scene->adt != nullptr) {
117 build_animdata(&scene->id);
118 }
119 /* World. */
120 if (scene->world != nullptr) {
121 build_world(scene->world);
122 }
123 /* Cache file. */
124 LISTBASE_FOREACH (CacheFile *, cachefile, &bmain_->cachefiles) {
125 build_cachefile(cachefile);
126 }
127 /* Masks. */
128 LISTBASE_FOREACH (Mask *, mask, &bmain_->masks) {
130 }
131 /* Movie clips. */
132 LISTBASE_FOREACH (MovieClip *, clip, &bmain_->movieclips) {
133 build_movieclip(clip);
134 }
135 /* Material override. */
136 if (view_layer->mat_override != nullptr) {
137 build_material(view_layer->mat_override);
138 }
139 /* World override */
140 if (view_layer->world_override != nullptr) {
141 build_world(view_layer->world_override);
142 }
143 /* Freestyle linesets. */
146 }
147 /* Sequencer. */
148 if (linked_state == DEG_ID_LINKED_DIRECTLY) {
149 build_scene_audio(scene);
151 }
152 /* Collections. */
153 add_operation_node(&scene->id,
156 [view_layer_index = view_layer_index_, scene_cow](::Depsgraph *depsgraph) {
157 BKE_layer_eval_view_layer_indexed(depsgraph, scene_cow, view_layer_index);
158 });
159 /* Parameters evaluation for scene relations mainly. */
162 /* Build all set scenes. */
163 if (scene->set != nullptr) {
164 ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
165 build_view_layer(scene->set, set_view_layer, DEG_ID_LINKED_VIA_SET);
166 }
167}
168
169} // namespace blender::deg
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
ViewLayer * BKE_view_layer_default_render(const Scene *scene)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
#define LISTBASE_FOREACH(type, var, list)
@ DAG_EVAL_VIEWPORT
Object groups, one object can be in many groups at once.
@ COLLECTION_HIDE_RENDER
@ COLLECTION_HIDE_VIEWPORT
@ LAYER_COLLECTION_EXCLUDE
Object is a sort of wrapper for general info.
BPy_StructRNA * depsgraph
virtual bool need_pull_base_into_graph(const Base *base)
virtual bool is_object_visibility_animated(const Object *object)
virtual void build_scene_parameters(Scene *scene)
virtual void build_scene_sequencer(Scene *scene)
virtual void build_world(World *world)
virtual void build_object(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state, bool is_visible)
virtual void build_freestyle_linestyle(FreestyleLineStyle *linestyle)
virtual void build_cachefile(CacheFile *cache_file)
OperationNode * add_operation_node(ComponentNode *comp_node, OperationCode opcode, const DepsEvalOperationCb &op=nullptr, const char *name="", int name_tag=-1)
virtual void build_scene_camera(Scene *scene)
virtual void build_scene_audio(Scene *scene)
virtual void build_material(Material *ma)
virtual void build_collection(LayerCollection *from_layer_collection, Collection *collection)
virtual void build_rigidbody(Scene *scene)
virtual void build_freestyle_lineset(FreestyleLineSet *fls)
virtual void build_movieclip(MovieClip *clip)
T * get_cow_datablock(const T *orig) const
virtual void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state)
virtual void build_scene_compositor(Scene *scene)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
struct Collection * group
struct FreestyleLineStyle * linestyle
struct RigidBodyWorld * rigidbody_world
struct AnimData * adt
struct World * world
struct Scene * set
struct FreestyleConfig freestyle_config
ListBase layer_collections
struct World * world_override
struct Material * mat_override
eDepsNode_LinkedState_Type linked_state