Blender V5.0
rna_layer.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "DNA_layer_types.h"
10
11#include "ED_object.hh"
12#include "ED_render.hh"
13
14#include "WM_api.hh"
15#include "WM_types.hh"
16
17#include "RNA_define.hh"
18
19#include "rna_internal.hh"
20
21#ifdef RNA_RUNTIME
22
23# ifdef WITH_PYTHON
24# include "BPY_extern.hh"
25# endif
26
27# include "DNA_collection_types.h"
28# include "DNA_object_types.h"
29
30# include "RNA_access.hh"
31
32# include "BKE_idprop.hh"
33# include "BKE_layer.hh"
34# include "BKE_mesh.hh"
35# include "BKE_node.hh"
36# include "BKE_scene.hh"
37
38# include "NOD_composite.hh"
39
40# include "BLI_listbase.h"
41
42# include "DEG_depsgraph_build.hh"
43# include "DEG_depsgraph_query.hh"
44
45# include "RE_engine.h"
46
47/***********************************/
48
49static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr)
50{
51 const Scene *scene = (const Scene *)ptr->owner_id;
52 ViewLayer *view_layer = (ViewLayer *)ptr->data;
53 BKE_view_layer_synced_ensure(scene, view_layer);
55 return RNA_pointer_create_with_parent(*ptr, &RNA_LayerCollection, lc);
56}
57
58static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr,
59 PointerRNA value,
60 ReportList * /*reports*/)
61{
62 const Scene *scene = (const Scene *)ptr->owner_id;
63 ViewLayer *view_layer = (ViewLayer *)ptr->data;
64 LayerCollection *lc = (LayerCollection *)value.data;
65 BKE_view_layer_synced_ensure(scene, view_layer);
66 const int index = BKE_layer_collection_findindex(view_layer, lc);
67 if (index != -1) {
68 BKE_layer_collection_activate(view_layer, lc);
69 }
70}
71
72static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
73{
74 const Scene *scene = (Scene *)ptr->owner_id;
75 ViewLayer *view_layer = (ViewLayer *)ptr->data;
76 BKE_view_layer_synced_ensure(scene, view_layer);
78 reinterpret_cast<ID *>(BKE_view_layer_active_object_get(view_layer)));
79}
80
81static void rna_LayerObjects_active_object_set(PointerRNA *ptr,
82 PointerRNA value,
83 ReportList *reports)
84{
85 const Scene *scene = (Scene *)ptr->owner_id;
86 ViewLayer *view_layer = (ViewLayer *)ptr->data;
87 if (value.data) {
88 Object *ob = static_cast<Object *>(value.data);
89 BKE_view_layer_synced_ensure(scene, view_layer);
90 Base *basact_test = BKE_view_layer_base_find(view_layer, ob);
91 if (basact_test != nullptr) {
92 view_layer->basact = basact_test;
93 }
94 else {
95 BKE_reportf(reports,
97 "ViewLayer '%s' does not contain object '%s'",
98 view_layer->name,
99 ob->id.name + 2);
100 }
101 }
102 else {
103 view_layer->basact = nullptr;
104 }
105}
106
107size_t rna_ViewLayer_path_buffer_get(const ViewLayer *view_layer,
108 char *r_rna_path,
109 const size_t rna_path_buffer_size)
110{
111 char name_esc[sizeof(view_layer->name) * 2];
112 BLI_str_escape(name_esc, view_layer->name, sizeof(name_esc));
113
114 return BLI_snprintf_rlen(r_rna_path, rna_path_buffer_size, "view_layers[\"%s\"]", name_esc);
115}
116
117static std::optional<std::string> rna_ViewLayer_path(const PointerRNA *ptr)
118{
119 const ViewLayer *view_layer = (ViewLayer *)ptr->data;
120 char rna_path[sizeof(view_layer->name) * 3];
121 rna_ViewLayer_path_buffer_get(view_layer, rna_path, sizeof(rna_path));
122 return rna_path;
123}
124
125static IDProperty **rna_ViewLayer_idprops(PointerRNA *ptr)
126{
127 ViewLayer *view_layer = (ViewLayer *)ptr->data;
128 return &view_layer->id_properties;
129}
130
131static IDProperty **rna_ViewLayer_system_idprops(PointerRNA *ptr)
132{
133 ViewLayer *view_layer = (ViewLayer *)ptr->data;
134 return &view_layer->system_properties;
135}
136
137static bool rna_LayerCollection_visible_get(LayerCollection *layer_collection, bContext *C)
138{
139 View3D *v3d = CTX_wm_view3d(C);
140
141 if ((v3d == nullptr) || ((v3d->flag & V3D_LOCAL_COLLECTIONS) == 0)) {
142 return (layer_collection->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) != 0;
143 }
144
145 if (v3d->local_collections_uid & layer_collection->local_collections_bits) {
146 return (layer_collection->runtime_flag & LAYER_COLLECTION_HIDE_VIEWPORT) == 0;
147 }
148
149 return false;
150}
151
152static void rna_ViewLayer_update_render_passes(ID *id)
153{
154 Scene *scene = (Scene *)id;
155 if (scene->compositing_node_group) {
157 }
158
159 RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
160 if (engine_type->update_render_passes) {
161 RenderEngine *engine = RE_engine_create(engine_type);
162 if (engine) {
163 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
164 BKE_view_layer_verify_aov(engine, scene, view_layer);
165 }
166 }
167 RE_engine_free(engine);
168 engine = nullptr;
169 }
170}
171
172static PointerRNA rna_ViewLayer_objects_get(CollectionPropertyIterator *iter)
173{
174 ListBaseIterator *internal = &iter->internal.listbase;
175
176 /* we are actually iterating a ObjectBase list */
177 Base *base = (Base *)internal->link;
178 return RNA_id_pointer_create(reinterpret_cast<ID *>(base->object));
179}
180
181static bool rna_ViewLayer_objects_selected_skip(CollectionPropertyIterator *iter, void * /*data*/)
182{
183 ListBaseIterator *internal = &iter->internal.listbase;
184 Base *base = (Base *)internal->link;
185
186 if ((base->flag & BASE_SELECTED) != 0) {
187 return false;
188 }
189
190 return true;
191};
192
193static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr)
194{
195 ID *id = ptr->owner_id;
196 if (GS(id->name) == ID_SCE) {
197 Scene *scene = (Scene *)id;
198 ViewLayer *view_layer = (ViewLayer *)ptr->data;
199 Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
200 return RNA_pointer_create_with_parent(*ptr, &RNA_Depsgraph, depsgraph);
201 }
202 return PointerRNA_NULL;
203}
204
205static void rna_ViewLayer_remove_aov(ViewLayer *view_layer, ReportList *reports, ViewLayerAOV *aov)
206{
207 if (BLI_findindex(&view_layer->aovs, aov) == -1) {
208 BKE_reportf(reports, RPT_ERROR, "AOV not found in view-layer '%s'", view_layer->name);
209 return;
210 }
211 BKE_view_layer_remove_aov(view_layer, aov);
212}
213
214static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
215{
216 ViewLayer *view_layer = (ViewLayer *)ptr->data;
218 iter, ptr, BKE_view_layer_object_bases_get(view_layer), rna_ViewLayer_objects_selected_skip);
219}
220
221static void rna_ViewLayer_update_tagged(ID *id_ptr,
222 ViewLayer *view_layer,
223 Main *bmain,
224 ReportList *reports)
225{
226 Scene *scene = (Scene *)id_ptr;
227 Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
228
230 BKE_report(reports, RPT_ERROR, "Dependency graph update requested during evaluation");
231 return;
232 }
233
234# ifdef WITH_PYTHON
235 /* Allow drivers to be evaluated */
237# endif
238
239 /* NOTE: This is similar to CTX_data_depsgraph_pointer(). Ideally such access would be
240 * de-duplicated across all possible cases, but for now this is safest and easiest way to go.
241 *
242 * The reason for this is that it's possible to have Python operator which asks view layer to
243 * be updated. After re-do of such operator view layer's dependency graph will not be marked
244 * as active. */
247
248# ifdef WITH_PYTHON
250# endif
251}
252
253static void rna_ObjectBase_select_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
254{
255 Base *base = (Base *)ptr->data;
256 short mode = (base->flag & BASE_SELECTED) ? blender::ed::object::BA_SELECT :
257 blender::ed::object::BA_DESELECT;
259}
260
261static void rna_ObjectBase_hide_viewport_update(bContext *C, PointerRNA * /*ptr*/)
262{
263 Scene *scene = CTX_data_scene(C);
264 ViewLayer *view_layer = CTX_data_view_layer(C);
268}
269
270static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value)
271{
272 ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
273 strcpy(value, id->name + 2);
274}
275
276int rna_LayerCollection_name_length(PointerRNA *ptr)
277{
278 ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
279 return strlen(id->name + 2);
280}
281
282static void rna_LayerCollection_flag_set(PointerRNA *ptr, const bool value, const int flag)
283{
284 LayerCollection *layer_collection = (LayerCollection *)ptr->data;
285 Collection *collection = layer_collection->collection;
286
287 if (collection->flag & COLLECTION_IS_MASTER) {
288 return;
289 }
290
291 if (value) {
292 layer_collection->flag |= flag;
293 }
294 else {
295 layer_collection->flag &= ~flag;
296 }
297}
298
299static void rna_LayerCollection_exclude_set(PointerRNA *ptr, bool value)
300{
301 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_EXCLUDE);
302}
303
304static void rna_LayerCollection_holdout_set(PointerRNA *ptr, bool value)
305{
306 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HOLDOUT);
307}
308
309static void rna_LayerCollection_indirect_only_set(PointerRNA *ptr, bool value)
310{
311 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_INDIRECT_ONLY);
312}
313
314static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value)
315{
316 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HIDE);
317}
318
319static void rna_LayerCollection_exclude_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
320{
321 Scene *scene = (Scene *)ptr->owner_id;
322 LayerCollection *lc = (LayerCollection *)ptr->data;
323 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
324
325 /* Set/Unset it recursively to match the behavior of excluding via the menu or shortcuts. */
326 const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
328
330
332 if (!exclude) {
333 /* We need to update animation of objects added back to the scene through enabling this view
334 * layer. */
335 FOREACH_OBJECT_BEGIN (scene, view_layer, ob) {
337 }
339 }
340
343 if (exclude) {
344 blender::ed::object::base_active_refresh(bmain, scene, view_layer);
345 }
346}
347
348static void rna_LayerCollection_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
349{
350 Scene *scene = (Scene *)ptr->owner_id;
351 LayerCollection *lc = (LayerCollection *)ptr->data;
352 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
353
355
357
360}
361
362static bool rna_LayerCollection_has_objects(LayerCollection *lc)
363{
364 return (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) != 0;
365}
366
367static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc,
368 Main *bmain,
369 ViewLayer *view_layer)
370{
371 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
372 LISTBASE_FOREACH (ViewLayer *, scene_view_layer, &scene->view_layers) {
373 if (scene_view_layer == view_layer) {
374 return BKE_layer_collection_has_selected_objects(scene, view_layer, lc);
375 }
376 }
377 }
378 return false;
379}
380
381void rna_LayerCollection_children_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
382{
383 Scene *scene = (Scene *)ptr->owner_id;
384 LayerCollection *lc = (LayerCollection *)ptr->data;
385 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
386 BKE_view_layer_synced_ensure(scene, view_layer);
387
389}
390
391static bool rna_LayerCollection_children_lookupint(PointerRNA *ptr, int key, PointerRNA *r_ptr)
392{
393 Scene *scene = (Scene *)ptr->owner_id;
394 LayerCollection *lc = (LayerCollection *)ptr->data;
395 /* TODO: replace by using RNA ancestors. */
396 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
397 BKE_view_layer_synced_ensure(scene, view_layer);
398
399 LayerCollection *child = static_cast<LayerCollection *>(
401 if (!child) {
402 return false;
403 }
404 rna_pointer_create_with_ancestors(*ptr, &RNA_LayerCollection, child, *r_ptr);
405 return true;
406}
407
408static bool rna_LayerCollection_children_lookupstring(PointerRNA *ptr,
409 const char *key,
410 PointerRNA *r_ptr)
411{
412 Scene *scene = (Scene *)ptr->owner_id;
413 LayerCollection *lc = (LayerCollection *)ptr->data;
414 /* TODO: replace by using RNA ancestors. */
415 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
416 BKE_view_layer_synced_ensure(scene, view_layer);
417
419 if (STREQ(child->collection->id.name + 2, key)) {
420 rna_pointer_create_with_ancestors(*ptr, &RNA_LayerCollection, child, *r_ptr);
421 return true;
422 }
423 }
424 return false;
425}
426
427#else
428
430{
431 StructRNA *srna;
432 FunctionRNA *func;
433 PropertyRNA *prop;
434
435 srna = RNA_def_struct(brna, "LayerCollection", nullptr);
436 RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection");
437 RNA_def_struct_ui_icon(srna, ICON_OUTLINER_COLLECTION);
438
439 prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
442 RNA_def_property_struct_type(prop, "Collection");
443 RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
444
445 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
446 RNA_def_property_string_sdna(prop, nullptr, "collection->id.name");
449 prop, "Name", "Name of this layer collection (same as its collection one)");
451 prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", nullptr);
453
454 prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
455 RNA_def_property_collection_sdna(prop, nullptr, "layer_collections", nullptr);
456 RNA_def_property_struct_type(prop, "LayerCollection");
457 RNA_def_property_ui_text(prop, "Children", "Layer collection children");
459 "rna_LayerCollection_children_begin",
460 nullptr,
461 nullptr,
462 nullptr,
463 nullptr,
464 "rna_LayerCollection_children_lookupint",
465 "rna_LayerCollection_children_lookupstring",
466 nullptr);
467
468 /* Restriction flags. */
469 prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE);
471 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_exclude_set");
473 RNA_def_property_ui_text(prop, "Exclude from View Layer", "Exclude from view layer");
474 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
475 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_exclude_update");
476
477 prop = RNA_def_property(srna, "holdout", PROP_BOOLEAN, PROP_NONE);
479 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_holdout_set");
481 RNA_def_property_ui_icon(prop, ICON_HOLDOUT_OFF, 1);
482 RNA_def_property_ui_text(prop, "Holdout", "Mask out objects in collection from view layer");
483 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_update");
484
485 prop = RNA_def_property(srna, "indirect_only", PROP_BOOLEAN, PROP_NONE);
487 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_indirect_only_set");
489 RNA_def_property_ui_icon(prop, ICON_INDIRECT_ONLY_OFF, 1);
491 prop,
492 "Indirect Only",
493 "Objects in collection only contribute indirectly (through shadows and reflections) "
494 "in the view layer");
495 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_update");
496
497 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
499 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_hide_viewport_set");
501 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
502 RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport");
503 RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_update");
504
505 func = RNA_def_function(srna, "visible_get", "rna_LayerCollection_visible_get");
507 "Whether this collection is visible, take into account the "
508 "collection parent and the viewport");
510 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
511
512 /* Run-time flags. */
513 prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
515 prop, nullptr, "runtime_flag", LAYER_COLLECTION_VISIBLE_VIEW_LAYER);
518 "Visible",
519 "Whether this collection is visible for the view layer, take into "
520 "account the collection parent");
521
522 func = RNA_def_function(srna, "has_objects", "rna_LayerCollection_has_objects");
524 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
525
526 func = RNA_def_function(
527 srna, "has_selected_objects", "rna_LayerCollection_has_selected_objects");
530 prop = RNA_def_pointer(
531 func, "view_layer", "ViewLayer", "", "View layer the layer collection belongs to");
533 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
534}
535
537{
538 StructRNA *srna;
539 PropertyRNA *prop;
540
541 RNA_def_property_srna(cprop, "LayerObjects");
542 srna = RNA_def_struct(brna, "LayerObjects", nullptr);
543 RNA_def_struct_sdna(srna, "ViewLayer");
544 RNA_def_struct_ui_text(srna, "Layer Objects", "Collections of objects");
545
546 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
547 RNA_def_property_struct_type(prop, "Object");
549 "rna_LayerObjects_active_object_get",
550 "rna_LayerObjects_active_object_set",
551 nullptr,
552 nullptr);
554 RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
555 /* Could call: `blender::ed::object::base_activate(C, view_layer->basact);`
556 * but would be a bad level call and it seems the notifier is enough */
558
559 prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
560 RNA_def_property_collection_sdna(prop, nullptr, "object_bases", nullptr);
561 RNA_def_property_struct_type(prop, "Object");
563 "rna_LayerObjects_selected_begin",
564 "rna_iterator_listbase_next",
565 "rna_iterator_listbase_end",
566 "rna_ViewLayer_objects_get",
567 nullptr,
568 nullptr,
569 nullptr,
570 nullptr);
571 RNA_def_property_ui_text(prop, "Selected Objects", "All the selected objects of this layer");
572}
573
575{
576 StructRNA *srna;
577 PropertyRNA *prop;
578
579 srna = RNA_def_struct(brna, "ObjectBase", nullptr);
580 RNA_def_struct_sdna(srna, "Base");
582 srna,
583 "Object Base",
584 "An object instance in a View Layer (currently never exposed in Python API)");
585 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
586
587 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
588 RNA_def_property_pointer_sdna(prop, nullptr, "object");
589 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
590
591 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
592 RNA_def_property_boolean_sdna(prop, nullptr, "flag", BASE_SELECTED);
593 RNA_def_property_ui_text(prop, "Select", "Object base selection state");
594 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update");
595
596 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
597 RNA_def_property_boolean_sdna(prop, nullptr, "flag", BASE_HIDDEN);
599 RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); /* The update callback does tagging. */
601 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
602 RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport");
604 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_hide_viewport_update");
605}
606
608{
609 FunctionRNA *func;
610 StructRNA *srna;
611 PropertyRNA *prop;
612
613 srna = RNA_def_struct(brna, "ViewLayer", nullptr);
614 RNA_def_struct_ui_text(srna, "View Layer", "View layer");
615 RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT);
616 RNA_def_struct_path_func(srna, "rna_ViewLayer_path");
617 RNA_def_struct_idprops_func(srna, "rna_ViewLayer_idprops");
618 RNA_def_struct_system_idprops_func(srna, "rna_ViewLayer_system_idprops");
619
620 rna_def_view_layer_common(brna, srna, true);
621
622 func = RNA_def_function(srna, "update_render_passes", "rna_ViewLayer_update_render_passes");
624 "Requery the enabled render passes from the render engine");
626
627 prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE);
628 RNA_def_property_struct_type(prop, "LayerCollection");
629 RNA_def_property_pointer_sdna(prop, nullptr, "layer_collections.first");
632 prop,
633 "Layer Collection",
634 "Root of collections hierarchy of this view layer, "
635 "its 'collection' pointer property is the same as the scene's master collection");
636
637 prop = RNA_def_property(srna, "active_layer_collection", PROP_POINTER, PROP_NONE);
638 RNA_def_property_struct_type(prop, "LayerCollection");
640 "rna_ViewLayer_active_layer_collection_get",
641 "rna_ViewLayer_active_layer_collection_set",
642 nullptr,
643 nullptr);
646 prop, "Active Layer Collection", "Active layer collection in this view layer's hierarchy");
647 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
648
649 prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
650 RNA_def_property_collection_sdna(prop, nullptr, "object_bases", nullptr);
651 RNA_def_property_struct_type(prop, "Object");
653 nullptr,
654 nullptr,
655 nullptr,
656 "rna_ViewLayer_objects_get",
657 nullptr,
658 nullptr,
659 nullptr,
660 nullptr);
661 RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer");
662 rna_def_layer_objects(brna, prop);
663
664 /* layer options */
665 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
666 RNA_def_property_boolean_sdna(prop, nullptr, "flag", VIEW_LAYER_RENDER);
667 RNA_def_property_ui_text(prop, "Enabled", "Enable or disable rendering of this View Layer");
668 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
669
670 /* Cached flag indicating if any Collection in this ViewLayer has an Exporter set. */
671 prop = RNA_def_property(srna, "has_export_collections", PROP_BOOLEAN, PROP_NONE);
675 "Has export collections",
676 "At least one Collection in this View Layer has an exporter");
677
678 prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
680 RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
681 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
682
683 /* Freestyle */
685
686 prop = RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE);
688 RNA_def_property_pointer_sdna(prop, nullptr, "freestyle_config");
689 RNA_def_property_struct_type(prop, "FreestyleSettings");
690 RNA_def_property_ui_text(prop, "Freestyle Settings", "");
691
692 /* Grease Pencil */
693 prop = RNA_def_property(srna, "use_pass_grease_pencil", PROP_BOOLEAN, PROP_NONE);
695 prop, nullptr, "grease_pencil_flags", GREASE_PENCIL_AS_SEPARATE_PASS);
697 prop, "Grease Pencil", "Deliver Grease Pencil render result in a separate pass");
698 RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
699
700 /* debug update routine */
701 func = RNA_def_function(srna, "update", "rna_ViewLayer_update_tagged");
704 func, "Update data tagged to be updated from previous access to data or operators");
705
706 /* Dependency Graph */
707 prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
708 RNA_def_property_struct_type(prop, "Depsgraph");
711 RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
712 RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_depsgraph_get", nullptr, nullptr, nullptr);
713
714 /* Nested Data. */
715 /* *** Non-Animated *** */
720 /* *** Animated *** */
721}
722
723#endif
Scene * CTX_data_scene(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
LayerCollection * BKE_view_layer_active_collection_get(ViewLayer *view_layer)
void BKE_view_layer_remove_aov(ViewLayer *view_layer, ViewLayerAOV *aov)
#define FOREACH_OBJECT_END
Definition BKE_layer.hh:432
#define FOREACH_OBJECT_BEGIN(scene, view_layer, _instance)
Definition BKE_layer.hh:422
bool BKE_layer_collection_has_selected_objects(const Scene *scene, ViewLayer *view_layer, LayerCollection *lc)
void BKE_view_layer_verify_aov(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_layer_collection_set_flag(LayerCollection *lc, int flag, bool value)
int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection *lc)
bool BKE_layer_collection_activate(ViewLayer *view_layer, LayerCollection *lc)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
ViewLayer * BKE_view_layer_find_from_collection(const Scene *scene, LayerCollection *lc)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition scene.cc:3416
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
Definition scene.cc:2621
Depsgraph * BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer)
Definition scene.cc:3403
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
#define LISTBASE_FOREACH(type, var, list)
size_t BLI_snprintf_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STREQ(a, b)
#define BPy_BEGIN_ALLOW_THREADS
Definition BPY_extern.hh:52
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:56
void DEG_id_tag_update(ID *id, unsigned int flags)
bool DEG_is_evaluating(const Depsgraph *depsgraph)
Definition depsgraph.cc:317
void DEG_make_active(Depsgraph *depsgraph)
Definition depsgraph.cc:336
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
@ ID_SCE
Object groups, one object can be in many groups at once.
@ COLLECTION_IS_MASTER
@ LAYER_COLLECTION_HIDE
@ LAYER_COLLECTION_EXCLUDE
@ LAYER_COLLECTION_INDIRECT_ONLY
@ LAYER_COLLECTION_HOLDOUT
@ BASE_HIDDEN
@ LAYER_COLLECTION_VISIBLE_VIEW_LAYER
@ LAYER_COLLECTION_HIDE_VIEWPORT
@ LAYER_COLLECTION_HAS_OBJECTS
@ GREASE_PENCIL_AS_SEPARATE_PASS
@ VIEW_LAYER_HAS_EXPORT_COLLECTIONS
@ VIEW_LAYER_FREESTYLE
@ VIEW_LAYER_RENDER
Object is a sort of wrapper for general info.
#define BASE_SELECTED(v3d, base)
@ V3D_LOCAL_COLLECTIONS
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_NO_SELF
Definition RNA_types.hh:907
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:511
PropertyFlag
Definition RNA_types.hh:300
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:407
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:384
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:312
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:439
@ PROP_NONE
Definition RNA_types.hh:233
#define C
Definition RandGen.cpp:29
#define ND_DRAW
Definition WM_types.hh:461
#define ND_OB_ACTIVE
Definition WM_types.hh:440
#define ND_RENDER_OPTIONS
Definition WM_types.hh:435
#define ND_OB_SELECT
Definition WM_types.hh:442
#define NC_SCENE
Definition WM_types.hh:378
#define ND_LAYER_CONTENT
Definition WM_types.hh:453
#define NC_IMAGE
Definition WM_types.hh:384
#define ND_LAYER
Definition WM_types.hh:450
#define NC_OBJECT
Definition WM_types.hh:379
BPy_StructRNA * depsgraph
#define GS(x)
RenderEngineType * RE_engines_find(const char *idname)
RenderEngine * RE_engine_create(RenderEngineType *type)
void RE_engine_free(RenderEngine *engine)
void base_select(Base *base, eObjectSelect_Mode mode)
void base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer)
void ntreeCompositUpdateRLayers(bNodeTree *ntree)
const PointerRNA PointerRNA_NULL
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, ListBase *lb, IteratorSkipFunc skip)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_define_animate_sdna(bool animate)
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_flag_hide_from_ui_workaround(PropertyRNA *prop)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void rna_def_freestyle_settings(BlenderRNA *brna)
size_t rna_ViewLayer_path_buffer_get(const ViewLayer *view_layer, char *r_rna_path, const size_t rna_path_buffer_size)
void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, bool scene)
static void rna_def_object_base(BlenderRNA *brna)
Definition rna_layer.cc:574
static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_layer.cc:536
static void rna_def_layer_collection(BlenderRNA *brna)
Definition rna_layer.cc:429
void RNA_def_view_layer(BlenderRNA *brna)
Definition rna_layer.cc:607
union CollectionPropertyIterator::@220100362304005352221007113371015217044252346141 internal
ListBaseIterator listbase
Definition RNA_types.hh:606
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
ListBase layer_collections
unsigned short local_collections_bits
struct Collection * collection
ListBase scenes
Definition BKE_main.hh:278
char engine[32]
void(* update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition RE_engine.h:110
struct bNodeTree * compositing_node_group
struct RenderData r
ListBase view_layers
unsigned short local_collections_uid
struct IDProperty * id_properties
struct Base * basact
struct IDProperty * system_properties
ListBase aovs
char name[64]
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238
uint8_t flag
Definition wm_window.cc:145