Blender V4.5
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,
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 {
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 bool rna_LayerCollection_visible_get(LayerCollection *layer_collection, bContext *C)
132{
133 View3D *v3d = CTX_wm_view3d(C);
134
135 if ((v3d == nullptr) || ((v3d->flag & V3D_LOCAL_COLLECTIONS) == 0)) {
136 return (layer_collection->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) != 0;
137 }
138
139 if (v3d->local_collections_uid & layer_collection->local_collections_bits) {
140 return (layer_collection->runtime_flag & LAYER_COLLECTION_HIDE_VIEWPORT) == 0;
141 }
142
143 return false;
144}
145
146static void rna_ViewLayer_update_render_passes(ID *id)
147{
148 Scene *scene = (Scene *)id;
149 if (scene->nodetree) {
151 }
152
153 RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
154 if (engine_type->update_render_passes) {
155 RenderEngine *engine = RE_engine_create(engine_type);
156 if (engine) {
157 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
158 BKE_view_layer_verify_aov(engine, scene, view_layer);
159 }
160 }
161 RE_engine_free(engine);
162 engine = nullptr;
163 }
164}
165
166static PointerRNA rna_ViewLayer_objects_get(CollectionPropertyIterator *iter)
167{
168 ListBaseIterator *internal = &iter->internal.listbase;
169
170 /* we are actually iterating a ObjectBase list */
171 Base *base = (Base *)internal->link;
172 return RNA_id_pointer_create(reinterpret_cast<ID *>(base->object));
173}
174
175static bool rna_ViewLayer_objects_selected_skip(CollectionPropertyIterator *iter, void * /*data*/)
176{
177 ListBaseIterator *internal = &iter->internal.listbase;
178 Base *base = (Base *)internal->link;
179
180 if ((base->flag & BASE_SELECTED) != 0) {
181 return false;
182 }
183
184 return true;
185};
186
187static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr)
188{
189 ID *id = ptr->owner_id;
190 if (GS(id->name) == ID_SCE) {
191 Scene *scene = (Scene *)id;
192 ViewLayer *view_layer = (ViewLayer *)ptr->data;
193 Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
194 return RNA_pointer_create_with_parent(*ptr, &RNA_Depsgraph, depsgraph);
195 }
196 return PointerRNA_NULL;
197}
198
199static void rna_ViewLayer_remove_aov(ViewLayer *view_layer, ReportList *reports, ViewLayerAOV *aov)
200{
201 if (BLI_findindex(&view_layer->aovs, aov) == -1) {
202 BKE_reportf(reports, RPT_ERROR, "AOV not found in view-layer '%s'", view_layer->name);
203 return;
204 }
205 BKE_view_layer_remove_aov(view_layer, aov);
206}
207
208static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
209{
210 ViewLayer *view_layer = (ViewLayer *)ptr->data;
212 iter, ptr, BKE_view_layer_object_bases_get(view_layer), rna_ViewLayer_objects_selected_skip);
213}
214
215static void rna_ViewLayer_update_tagged(ID *id_ptr,
216 ViewLayer *view_layer,
217 Main *bmain,
219{
220 Scene *scene = (Scene *)id_ptr;
221 Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
222
224 BKE_report(reports, RPT_ERROR, "Dependency graph update requested during evaluation");
225 return;
226 }
227
228# ifdef WITH_PYTHON
229 /* Allow drivers to be evaluated */
231# endif
232
233 /* NOTE: This is similar to CTX_data_depsgraph_pointer(). Ideally such access would be
234 * de-duplicated across all possible cases, but for now this is safest and easiest way to go.
235 *
236 * The reason for this is that it's possible to have Python operator which asks view layer to
237 * be updated. After re-do of such operator view layer's dependency graph will not be marked
238 * as active. */
241
242# ifdef WITH_PYTHON
244# endif
245}
246
247static void rna_ObjectBase_select_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
248{
249 Base *base = (Base *)ptr->data;
250 short mode = (base->flag & BASE_SELECTED) ? blender::ed::object::BA_SELECT :
251 blender::ed::object::BA_DESELECT;
253}
254
255static void rna_ObjectBase_hide_viewport_update(bContext *C, PointerRNA * /*ptr*/)
256{
257 Scene *scene = CTX_data_scene(C);
258 ViewLayer *view_layer = CTX_data_view_layer(C);
262}
263
264static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value)
265{
266 ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
267 strcpy(value, id->name + 2);
268}
269
270int rna_LayerCollection_name_length(PointerRNA *ptr)
271{
272 ID *id = (ID *)((LayerCollection *)ptr->data)->collection;
273 return strlen(id->name + 2);
274}
275
276static void rna_LayerCollection_flag_set(PointerRNA *ptr, const bool value, const int flag)
277{
278 LayerCollection *layer_collection = (LayerCollection *)ptr->data;
279 Collection *collection = layer_collection->collection;
280
281 if (collection->flag & COLLECTION_IS_MASTER) {
282 return;
283 }
284
285 if (value) {
286 layer_collection->flag |= flag;
287 }
288 else {
289 layer_collection->flag &= ~flag;
290 }
291}
292
293static void rna_LayerCollection_exclude_set(PointerRNA *ptr, bool value)
294{
295 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_EXCLUDE);
296}
297
298static void rna_LayerCollection_holdout_set(PointerRNA *ptr, bool value)
299{
300 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HOLDOUT);
301}
302
303static void rna_LayerCollection_indirect_only_set(PointerRNA *ptr, bool value)
304{
305 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_INDIRECT_ONLY);
306}
307
308static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value)
309{
310 rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HIDE);
311}
312
313static void rna_LayerCollection_exclude_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
314{
315 Scene *scene = (Scene *)ptr->owner_id;
316 LayerCollection *lc = (LayerCollection *)ptr->data;
317 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
318
319 /* Set/Unset it recursively to match the behavior of excluding via the menu or shortcuts. */
320 const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
322
324
326 if (!exclude) {
327 /* We need to update animation of objects added back to the scene through enabling this view
328 * layer. */
329 FOREACH_OBJECT_BEGIN (scene, view_layer, ob) {
331 }
333 }
334
337 if (exclude) {
338 blender::ed::object::base_active_refresh(bmain, scene, view_layer);
339 }
340}
341
342static void rna_LayerCollection_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
343{
344 Scene *scene = (Scene *)ptr->owner_id;
345 LayerCollection *lc = (LayerCollection *)ptr->data;
346 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
347
349
351
354}
355
356static bool rna_LayerCollection_has_objects(LayerCollection *lc)
357{
358 return (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) != 0;
359}
360
361static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc,
362 Main *bmain,
363 ViewLayer *view_layer)
364{
365 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
366 LISTBASE_FOREACH (ViewLayer *, scene_view_layer, &scene->view_layers) {
367 if (scene_view_layer == view_layer) {
368 return BKE_layer_collection_has_selected_objects(scene, view_layer, lc);
369 }
370 }
371 }
372 return false;
373}
374
375void rna_LayerCollection_children_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
376{
377 Scene *scene = (Scene *)ptr->owner_id;
378 LayerCollection *lc = (LayerCollection *)ptr->data;
379 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
380 BKE_view_layer_synced_ensure(scene, view_layer);
381
383}
384
385static bool rna_LayerCollection_children_lookupint(PointerRNA *ptr, int key, PointerRNA *r_ptr)
386{
387 Scene *scene = (Scene *)ptr->owner_id;
388 LayerCollection *lc = (LayerCollection *)ptr->data;
389 /* TODO: replace by using RNA ancestors. */
390 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
391 BKE_view_layer_synced_ensure(scene, view_layer);
392
393 LayerCollection *child = static_cast<LayerCollection *>(
395 if (!child) {
396 return false;
397 }
398 rna_pointer_create_with_ancestors(*ptr, &RNA_LayerCollection, child, *r_ptr);
399 return true;
400}
401
402static bool rna_LayerCollection_children_lookupstring(PointerRNA *ptr,
403 const char *key,
404 PointerRNA *r_ptr)
405{
406 Scene *scene = (Scene *)ptr->owner_id;
407 LayerCollection *lc = (LayerCollection *)ptr->data;
408 /* TODO: replace by using RNA ancestors. */
409 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
410 BKE_view_layer_synced_ensure(scene, view_layer);
411
413 if (STREQ(child->collection->id.name + 2, key)) {
414 rna_pointer_create_with_ancestors(*ptr, &RNA_LayerCollection, child, *r_ptr);
415 return true;
416 }
417 }
418 return false;
419}
420
421#else
422
424{
425 StructRNA *srna;
426 FunctionRNA *func;
427 PropertyRNA *prop;
428
429 srna = RNA_def_struct(brna, "LayerCollection", nullptr);
430 RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection");
431 RNA_def_struct_ui_icon(srna, ICON_OUTLINER_COLLECTION);
432
433 prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
436 RNA_def_property_struct_type(prop, "Collection");
437 RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
438
439 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
440 RNA_def_property_string_sdna(prop, nullptr, "collection->id.name");
443 prop, "Name", "Name of this layer collection (same as its collection one)");
445 prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", nullptr);
447
448 prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
449 RNA_def_property_collection_sdna(prop, nullptr, "layer_collections", nullptr);
450 RNA_def_property_struct_type(prop, "LayerCollection");
451 RNA_def_property_ui_text(prop, "Children", "Layer collection children");
453 "rna_LayerCollection_children_begin",
454 nullptr,
455 nullptr,
456 nullptr,
457 nullptr,
458 "rna_LayerCollection_children_lookupint",
459 "rna_LayerCollection_children_lookupstring",
460 nullptr);
461
462 /* Restriction flags. */
463 prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE);
465 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_exclude_set");
467 RNA_def_property_ui_text(prop, "Exclude from View Layer", "Exclude from view layer");
468 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
469 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_exclude_update");
470
471 prop = RNA_def_property(srna, "holdout", PROP_BOOLEAN, PROP_NONE);
473 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_holdout_set");
475 RNA_def_property_ui_icon(prop, ICON_HOLDOUT_OFF, 1);
476 RNA_def_property_ui_text(prop, "Holdout", "Mask out objects in collection from view layer");
477 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_update");
478
479 prop = RNA_def_property(srna, "indirect_only", PROP_BOOLEAN, PROP_NONE);
481 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_indirect_only_set");
483 RNA_def_property_ui_icon(prop, ICON_INDIRECT_ONLY_OFF, 1);
485 prop,
486 "Indirect Only",
487 "Objects in collection only contribute indirectly (through shadows and reflections) "
488 "in the view layer");
489 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_update");
490
491 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
493 RNA_def_property_boolean_funcs(prop, nullptr, "rna_LayerCollection_hide_viewport_set");
495 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
496 RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport");
497 RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_update");
498
499 func = RNA_def_function(srna, "visible_get", "rna_LayerCollection_visible_get");
501 "Whether this collection is visible, take into account the "
502 "collection parent and the viewport");
504 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
505
506 /* Run-time flags. */
507 prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
509 prop, nullptr, "runtime_flag", LAYER_COLLECTION_VISIBLE_VIEW_LAYER);
512 "Visible",
513 "Whether this collection is visible for the view layer, take into "
514 "account the collection parent");
515
516 func = RNA_def_function(srna, "has_objects", "rna_LayerCollection_has_objects");
518 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
519
520 func = RNA_def_function(
521 srna, "has_selected_objects", "rna_LayerCollection_has_selected_objects");
524 prop = RNA_def_pointer(
525 func, "view_layer", "ViewLayer", "", "View layer the layer collection belongs to");
527 RNA_def_function_return(func, RNA_def_boolean(func, "result", false, "", ""));
528}
529
531{
532 StructRNA *srna;
533 PropertyRNA *prop;
534
535 RNA_def_property_srna(cprop, "LayerObjects");
536 srna = RNA_def_struct(brna, "LayerObjects", nullptr);
537 RNA_def_struct_sdna(srna, "ViewLayer");
538 RNA_def_struct_ui_text(srna, "Layer Objects", "Collections of objects");
539
540 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
541 RNA_def_property_struct_type(prop, "Object");
543 "rna_LayerObjects_active_object_get",
544 "rna_LayerObjects_active_object_set",
545 nullptr,
546 nullptr);
548 RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
549 /* Could call: `blender::ed::object::base_activate(C, view_layer->basact);`
550 * but would be a bad level call and it seems the notifier is enough */
552
553 prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
554 RNA_def_property_collection_sdna(prop, nullptr, "object_bases", nullptr);
555 RNA_def_property_struct_type(prop, "Object");
557 "rna_LayerObjects_selected_begin",
558 "rna_iterator_listbase_next",
559 "rna_iterator_listbase_end",
560 "rna_ViewLayer_objects_get",
561 nullptr,
562 nullptr,
563 nullptr,
564 nullptr);
565 RNA_def_property_ui_text(prop, "Selected Objects", "All the selected objects of this layer");
566}
567
569{
570 StructRNA *srna;
571 PropertyRNA *prop;
572
573 srna = RNA_def_struct(brna, "ObjectBase", nullptr);
574 RNA_def_struct_sdna(srna, "Base");
576 srna,
577 "Object Base",
578 "An object instance in a View Layer (currently never exposed in Python API)");
579 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
580
581 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
582 RNA_def_property_pointer_sdna(prop, nullptr, "object");
583 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
584
585 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
586 RNA_def_property_boolean_sdna(prop, nullptr, "flag", BASE_SELECTED);
587 RNA_def_property_ui_text(prop, "Select", "Object base selection state");
588 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update");
589
590 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
591 RNA_def_property_boolean_sdna(prop, nullptr, "flag", BASE_HIDDEN);
593 RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); /* The update callback does tagging. */
595 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
596 RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport");
598 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_hide_viewport_update");
599}
600
602{
603 FunctionRNA *func;
604 StructRNA *srna;
605 PropertyRNA *prop;
606
607 srna = RNA_def_struct(brna, "ViewLayer", nullptr);
608 RNA_def_struct_ui_text(srna, "View Layer", "View layer");
609 RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT);
610 RNA_def_struct_path_func(srna, "rna_ViewLayer_path");
611 RNA_def_struct_idprops_func(srna, "rna_ViewLayer_idprops");
612
613 rna_def_view_layer_common(brna, srna, true);
614
615 func = RNA_def_function(srna, "update_render_passes", "rna_ViewLayer_update_render_passes");
617 "Requery the enabled render passes from the render engine");
619
620 prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE);
621 RNA_def_property_struct_type(prop, "LayerCollection");
622 RNA_def_property_pointer_sdna(prop, nullptr, "layer_collections.first");
625 prop,
626 "Layer Collection",
627 "Root of collections hierarchy of this view layer, "
628 "its 'collection' pointer property is the same as the scene's master collection");
629
630 prop = RNA_def_property(srna, "active_layer_collection", PROP_POINTER, PROP_NONE);
631 RNA_def_property_struct_type(prop, "LayerCollection");
633 "rna_ViewLayer_active_layer_collection_get",
634 "rna_ViewLayer_active_layer_collection_set",
635 nullptr,
636 nullptr);
639 prop, "Active Layer Collection", "Active layer collection in this view layer's hierarchy");
640 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
641
642 prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
643 RNA_def_property_collection_sdna(prop, nullptr, "object_bases", nullptr);
644 RNA_def_property_struct_type(prop, "Object");
646 nullptr,
647 nullptr,
648 nullptr,
649 "rna_ViewLayer_objects_get",
650 nullptr,
651 nullptr,
652 nullptr,
653 nullptr);
654 RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer");
655 rna_def_layer_objects(brna, prop);
656
657 /* layer options */
658 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
659 RNA_def_property_boolean_sdna(prop, nullptr, "flag", VIEW_LAYER_RENDER);
660 RNA_def_property_ui_text(prop, "Enabled", "Enable or disable rendering of this View Layer");
661 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
662
663 /* Cached flag indicating if any Collection in this ViewLayer has an Exporter set. */
664 prop = RNA_def_property(srna, "has_export_collections", PROP_BOOLEAN, PROP_NONE);
668 "Has export collections",
669 "At least one Collection in this View Layer has an exporter");
670
671 prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
673 RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
674 RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
675
676 /* Freestyle */
678
679 prop = RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE);
681 RNA_def_property_pointer_sdna(prop, nullptr, "freestyle_config");
682 RNA_def_property_struct_type(prop, "FreestyleSettings");
683 RNA_def_property_ui_text(prop, "Freestyle Settings", "");
684
685 /* Grease Pencil */
686 prop = RNA_def_property(srna, "use_pass_grease_pencil", PROP_BOOLEAN, PROP_NONE);
688 prop, nullptr, "grease_pencil_flags", GREASE_PENCIL_AS_SEPARATE_PASS);
690 prop, "Grease Pencil", "Deliver Grease Pencil render result in a separate pass");
691 RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
692
693 /* debug update routine */
694 func = RNA_def_function(srna, "update", "rna_ViewLayer_update_tagged");
697 func, "Update data tagged to be updated from previous access to data or operators");
698
699 /* Dependency Graph */
700 prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
701 RNA_def_property_struct_type(prop, "Depsgraph");
703 RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
704 RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_depsgraph_get", nullptr, nullptr, nullptr);
705
706 /* Nested Data. */
707 /* *** Non-Animated *** */
712 /* *** Animated *** */
713}
714
715#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
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition scene.cc:3427
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
Definition scene.cc:2618
Depsgraph * BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer)
Definition scene.cc:3414
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:51
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:55
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:985
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1012
@ ID_SCE
Object groups, one object can be in many groups at once.
@ COLLECTION_IS_MASTER
@ BASE_HIDDEN
@ LAYER_COLLECTION_HIDE
@ LAYER_COLLECTION_EXCLUDE
@ LAYER_COLLECTION_INDIRECT_ONLY
@ LAYER_COLLECTION_HOLDOUT
@ GREASE_PENCIL_AS_SEPARATE_PASS
@ VIEW_LAYER_HAS_EXPORT_COLLECTIONS
@ VIEW_LAYER_FREESTYLE
@ VIEW_LAYER_RENDER
@ LAYER_COLLECTION_VISIBLE_VIEW_LAYER
@ LAYER_COLLECTION_HIDE_VIEWPORT
@ LAYER_COLLECTION_HAS_OBJECTS
Object is a sort of wrapper for general info.
#define BASE_SELECTED(v3d, base)
@ V3D_LOCAL_COLLECTIONS
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_NO_SELF
Definition RNA_types.hh:798
@ FUNC_USE_MAIN
Definition RNA_types.hh:803
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:804
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:469
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:477
PropertyFlag
Definition RNA_types.hh:286
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:381
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:358
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:298
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:413
@ PROP_NONE
Definition RNA_types.hh:221
#define C
Definition RandGen.cpp:29
#define ND_DRAW
Definition WM_types.hh:458
#define ND_OB_ACTIVE
Definition WM_types.hh:437
#define ND_RENDER_OPTIONS
Definition WM_types.hh:432
#define ND_OB_SELECT
Definition WM_types.hh:439
#define NC_SCENE
Definition WM_types.hh:375
#define ND_LAYER_CONTENT
Definition WM_types.hh:450
ReportList * reports
Definition WM_types.hh:1025
#define NC_IMAGE
Definition WM_types.hh:381
#define ND_LAYER
Definition WM_types.hh:447
#define NC_OBJECT
Definition WM_types.hh:376
BPy_StructRNA * depsgraph
#define GS(a)
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_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)
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:568
static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_layer.cc:530
static void rna_def_layer_collection(BlenderRNA *brna)
Definition rna_layer.cc:423
void RNA_def_view_layer(BlenderRNA *brna)
Definition rna_layer.cc:601
ListBaseIterator listbase
Definition RNA_types.hh:572
union CollectionPropertyIterator::@277172262001176145116102322066145204253046376362 internal
Definition DNA_ID.h:404
char name[66]
Definition DNA_ID.h:415
ListBase layer_collections
unsigned short local_collections_bits
struct Collection * collection
ListBase scenes
Definition BKE_main.hh:245
char engine[32]
void(* update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition RE_engine.h:111
struct bNodeTree * nodetree
struct RenderData r
ListBase view_layers
unsigned short local_collections_uid
struct IDProperty * id_properties
struct Base * basact
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:4226
uint8_t flag
Definition wm_window.cc:139