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