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