efa05ed5b92b63dcb43ef51500356980d78b4d11
[blender.git] / source / blender / makesrna / intern / rna_layer.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Foundation.
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/makesrna/intern/rna_layer.c
24  *  \ingroup RNA
25  */
26
27 #include "DNA_scene_types.h"
28 #include "DNA_layer_types.h"
29
30 #include "BLI_math.h"
31 #include "BLI_string_utils.h"
32
33 #include "BLT_translation.h"
34
35 #include "ED_object.h"
36 #include "ED_render.h"
37
38 #include "RE_engine.h"
39
40 #include "DRW_engine.h"
41
42 #include "WM_api.h"
43 #include "WM_types.h"
44
45 #include "RNA_define.h"
46
47 #include "rna_internal.h"
48
49 const EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
50         {COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""},
51         {COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""},
52         {COLLECTION_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""},
53         {COLLECTION_MODE_PAINT_WEIGHT, "PAINT_VERTEX", 0, "Vertex Paint", ""},
54         {0, NULL, 0, NULL, NULL}
55 };
56
57 const EnumPropertyItem rna_enum_collection_type_items[] = {
58         {COLLECTION_TYPE_NONE, "NONE", 0, "Normal", ""},
59         {COLLECTION_TYPE_GROUP_INTERNAL, "GROUP_INTERNAL", 0, "Group Internal", ""},
60         {0, NULL, 0, NULL, NULL}
61 };
62
63 #ifdef RNA_RUNTIME
64
65 #include "DNA_group_types.h"
66 #include "DNA_object_types.h"
67 #include "DNA_workspace_types.h"
68
69 #include "RNA_access.h"
70
71 #include "BKE_idprop.h"
72 #include "BKE_layer.h"
73 #include "BKE_node.h"
74 #include "BKE_scene.h"
75 #include "BKE_mesh.h"
76 #include "BKE_workspace.h"
77
78 #include "DEG_depsgraph_build.h"
79 #include "DEG_depsgraph_query.h"
80
81 static StructRNA *rna_SceneCollection_refine(PointerRNA *ptr)
82 {
83         SceneCollection *scene_collection = (SceneCollection *)ptr->data;
84         switch (scene_collection->type) {
85                 case COLLECTION_TYPE_GROUP_INTERNAL:
86                 case COLLECTION_TYPE_NONE:
87                         return &RNA_SceneCollection;
88                 default:
89                         BLI_assert(!"Collection type not fully implemented");
90                         break;
91         }
92         return &RNA_SceneCollection;
93 }
94
95 static void rna_SceneCollection_name_set(PointerRNA *ptr, const char *value)
96 {
97         Scene *scene = (Scene *)ptr->id.data;
98         SceneCollection *sc = (SceneCollection *)ptr->data;
99         BKE_collection_rename(scene, sc, value);
100 }
101
102 static PointerRNA rna_SceneCollection_objects_get(CollectionPropertyIterator *iter)
103 {
104         ListBaseIterator *internal = &iter->internal.listbase;
105
106         /* we are actually iterating a LinkData list, so override get */
107         return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((LinkData *)internal->link)->data);
108 }
109
110 static int rna_SceneCollection_move_above(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
111 {
112         if (!BKE_collection_move_above(id, sc_dst, sc_src)) {
113                 return 0;
114         }
115
116         DEG_relations_tag_update(bmain);
117         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
118
119         return 1;
120 }
121
122 static int rna_SceneCollection_move_below(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
123 {
124         if (!BKE_collection_move_below(id, sc_dst, sc_src)) {
125                 return 0;
126         }
127
128         DEG_relations_tag_update(bmain);
129         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
130
131         return 1;
132 }
133
134 static int rna_SceneCollection_move_into(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
135 {
136         if (!BKE_collection_move_into(id, sc_dst, sc_src)) {
137                 return 0;
138         }
139
140         DEG_relations_tag_update(bmain);
141         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
142
143         return 1;
144 }
145
146 static SceneCollection *rna_SceneCollection_duplicate(
147         ID *id, SceneCollection *scene_collection, Main *bmain, bContext *C, ReportList *reports)
148 {
149         if (scene_collection == BKE_collection_master(id)) {
150                 BKE_report(reports, RPT_ERROR, "The master collection can't be duplicated");
151                 return NULL;
152         }
153
154         SceneCollection *scene_collection_new = BKE_collection_duplicate(id, scene_collection);
155
156         DEG_relations_tag_update(bmain);
157         /* Don't use id here, since the layer collection may come from a group. */
158         WM_event_add_notifier(C, NC_SCENE | ND_LAYER, CTX_data_scene(C));
159
160         return scene_collection_new;
161 }
162
163 static SceneCollection *rna_SceneCollection_new(
164         ID *id, SceneCollection *sc_parent, Main *bmain, const char *name)
165 {
166         SceneCollection *sc = BKE_collection_add(id, sc_parent, COLLECTION_TYPE_NONE, name);
167
168         DEG_relations_tag_update(bmain);
169         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
170
171         return sc;
172 }
173
174 static void rna_SceneCollection_remove(
175         ID *id, SceneCollection *sc_parent, Main *bmain, ReportList *reports, PointerRNA *sc_ptr)
176 {
177         SceneCollection *sc = sc_ptr->data;
178
179         const int index = BLI_findindex(&sc_parent->scene_collections, sc);
180         if (index == -1) {
181                 BKE_reportf(reports, RPT_ERROR, "Collection '%s' is not a sub-collection of '%s'",
182                             sc->name, sc_parent->name);
183                 return;
184         }
185
186         if (!BKE_collection_remove(id, sc)) {
187                 BKE_reportf(reports, RPT_ERROR, "Collection '%s' could not be removed from collection '%s'",
188                             sc->name, sc_parent->name);
189                 return;
190         }
191
192         RNA_POINTER_INVALIDATE(sc_ptr);
193
194         DEG_relations_tag_update(bmain);
195         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
196 }
197
198 static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr)
199 {
200         SceneCollection *sc = (SceneCollection *)ptr->data;
201         return sc->active_object_index;
202 }
203
204 static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int value)
205 {
206         SceneCollection *sc = (SceneCollection *)ptr->data;
207         sc->active_object_index = value;
208 }
209
210 static void rna_SceneCollection_objects_active_index_range(
211         PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
212 {
213         SceneCollection *sc = (SceneCollection *)ptr->data;
214         *min = 0;
215         *max = max_ii(0, BLI_listbase_count(&sc->objects) - 1);
216 }
217
218 void rna_SceneCollection_object_link(
219         ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob)
220 {
221         Scene *scene = (Scene *)id;
222
223         if (BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) {
224                 BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in collection '%s'", ob->id.name + 2, sc->name);
225                 return;
226         }
227
228         BKE_collection_object_add(&scene->id, sc, ob);
229
230         /* TODO(sergey): Only update relations for the current scene. */
231         DEG_relations_tag_update(bmain);
232
233         /* TODO(sergey): Use proper flag for tagging here. */
234         DEG_id_tag_update(&scene->id, 0);
235
236         DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
237
238         WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
239 }
240
241 static void rna_SceneCollection_object_unlink(
242         ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob)
243 {
244         Scene *scene = (Scene *)id;
245
246         if (!BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) {
247                 BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in collection '%s'", ob->id.name + 2, sc->name);
248                 return;
249         }
250
251         BKE_collection_object_remove(bmain, &scene->id, sc, ob, false);
252
253         /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */
254         DEG_relations_tag_update(bmain);
255
256         WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
257 }
258
259 /****** layer collection engine settings *******/
260
261 #define RNA_LAYER_ENGINE_GET_SET(_TYPE_, _ENGINE_, _MODE_, _NAME_)                 \
262 static _TYPE_ rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_get(PointerRNA *ptr) \
263 {                                                                                  \
264         IDProperty *props = (IDProperty *)ptr->data;                                   \
265         return BKE_collection_engine_property_value_get_##_TYPE_(props, #_NAME_);      \
266 }                                                                                  \
267                                                                                        \
268 static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr, _TYPE_ value)  \
269 {                                                                                  \
270         IDProperty *props = (IDProperty *)ptr->data;                                   \
271         BKE_collection_engine_property_value_set_##_TYPE_(props, #_NAME_, value);      \
272 }
273
274 #define RNA_LAYER_ENGINE_GET_SET_ARRAY(_TYPE_, _ENGINE_, _MODE_, _NAME_, _LEN_)    \
275 static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_get(PointerRNA *ptr, _TYPE_ *values) \
276 {                                                                                  \
277         IDProperty *props = (IDProperty *)ptr->data;                                   \
278         IDProperty *idprop = IDP_GetPropertyFromGroup(props, #_NAME_);                 \
279         if (idprop != NULL) {                                                          \
280                 memcpy(values, IDP_Array(idprop), sizeof(_TYPE_) * idprop->len);           \
281         }                                                                              \
282 }                                                                                  \
283                                                                                        \
284 static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr, const _TYPE_ *values) \
285 {                                                                                  \
286         IDProperty *props = (IDProperty *)ptr->data;                                   \
287         BKE_collection_engine_property_value_set_##_TYPE_##_array(props, #_NAME_, values); \
288 }
289
290 #define RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(_NAME_) \
291         RNA_LAYER_ENGINE_GET_SET(float, Clay, COLLECTION_MODE_NONE, _NAME_)
292
293 #define RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
294         RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Clay, COLLECTION_MODE_NONE, _NAME_, _LEN_)
295
296 #define RNA_LAYER_ENGINE_CLAY_GET_SET_INT(_NAME_) \
297         RNA_LAYER_ENGINE_GET_SET(int, Clay, COLLECTION_MODE_NONE, _NAME_)
298
299 #define RNA_LAYER_ENGINE_CLAY_GET_SET_BOOL(_NAME_) \
300         RNA_LAYER_ENGINE_GET_SET(bool, Clay, COLLECTION_MODE_NONE, _NAME_)
301
302 #define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(_NAME_) \
303         RNA_LAYER_ENGINE_GET_SET(float, Eevee, COLLECTION_MODE_NONE, _NAME_)
304
305 #define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
306         RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Eevee, COLLECTION_MODE_NONE, _NAME_, _LEN_)
307
308 #define RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(_NAME_) \
309         RNA_LAYER_ENGINE_GET_SET(int, Eevee, COLLECTION_MODE_NONE, _NAME_)
310
311 #define RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(_NAME_) \
312         RNA_LAYER_ENGINE_GET_SET(bool, Eevee, COLLECTION_MODE_NONE, _NAME_)
313
314 /* mode engines */
315
316 #define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \
317         RNA_LAYER_ENGINE_GET_SET(float, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_)
318
319 #define RNA_LAYER_MODE_OBJECT_GET_SET_INT(_NAME_) \
320         RNA_LAYER_ENGINE_GET_SET(int, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_)
321
322 #define RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(_NAME_) \
323         RNA_LAYER_ENGINE_GET_SET(bool, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_)
324
325 #define RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(_NAME_) \
326         RNA_LAYER_ENGINE_GET_SET(float, EditMode, COLLECTION_MODE_EDIT, _NAME_)
327
328 #define RNA_LAYER_MODE_EDIT_GET_SET_INT(_NAME_) \
329         RNA_LAYER_ENGINE_GET_SET(int, EditMode, COLLECTION_MODE_EDIT, _NAME_)
330
331 #define RNA_LAYER_MODE_EDIT_GET_SET_BOOL(_NAME_) \
332         RNA_LAYER_ENGINE_GET_SET(bool, EditMode, COLLECTION_MODE_EDIT, _NAME_)
333
334 #define RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(_NAME_) \
335         RNA_LAYER_ENGINE_GET_SET(bool, PaintWeightMode, COLLECTION_MODE_PAINT_WEIGHT, _NAME_)
336
337 #define RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(_NAME_) \
338         RNA_LAYER_ENGINE_GET_SET(bool, PaintVertexMode, COLLECTION_MODE_PAINT_VERTEX, _NAME_)
339
340 /* clay engine */
341 #ifdef WITH_CLAY_ENGINE
342 /* ViewLayer settings. */
343 RNA_LAYER_ENGINE_CLAY_GET_SET_INT(ssao_samples)
344
345 /* LayerCollection settings. */
346 RNA_LAYER_ENGINE_CLAY_GET_SET_INT(matcap_icon)
347 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_rotation)
348 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_hue)
349 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_saturation)
350 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_value)
351 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_cavity)
352 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_edge)
353 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_distance)
354 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_attenuation)
355 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
356 #endif /* WITH_CLAY_ENGINE */
357
358 /* eevee engine */
359 /* ViewLayer settings. */
360 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_enable)
361 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_use_bent_normals)
362 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_bounce)
363 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_factor)
364 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_quality)
365 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_distance)
366 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(dof_enable)
367 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_max_size)
368 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_threshold)
369 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(bloom_enable)
370 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_threshold)
371 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(bloom_color, 3)
372 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_knee)
373 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_radius)
374 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_clamp)
375 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_intensity)
376 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(motion_blur_enable)
377 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(motion_blur_samples)
378 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(motion_blur_shutter)
379 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_enable)
380 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_start)
381 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_end)
382 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_tile_size)
383 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_samples)
384 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_sample_distribution)
385 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_lights)
386 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_light_clamp)
387 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_shadows)
388 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_shadow_samples)
389 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_colored_transmittance)
390 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(sss_enable)
391 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(sss_samples)
392 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(sss_jitter_threshold)
393 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(sss_separate_albedo)
394 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_refraction)
395 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_enable)
396 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_halfres)
397 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_quality)
398 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_max_roughness)
399 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_thickness)
400 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_border_fade)
401 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_firefly_fac)
402 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_method)
403 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
404 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(shadow_high_bitdepth)
405 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_samples)
406 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_render_samples)
407 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_diffuse_bounces)
408 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_cubemap_resolution)
409 RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_visibility_resolution)
410
411 /* object engine */
412 RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire)
413 RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_backface_culling)
414
415 /* mesh engine */
416 RNA_LAYER_MODE_EDIT_GET_SET_BOOL(show_occlude_wire)
417 RNA_LAYER_MODE_EDIT_GET_SET_BOOL(show_weight)
418 RNA_LAYER_MODE_EDIT_GET_SET_BOOL(face_normals_show)
419 RNA_LAYER_MODE_EDIT_GET_SET_BOOL(vert_normals_show)
420 RNA_LAYER_MODE_EDIT_GET_SET_BOOL(loop_normals_show)
421 RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(normals_length)
422 RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(backwire_opacity)
423
424 /* weight paint engine */
425 RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_shading)
426 RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_wire)
427
428 /* vertex paint engine */
429 RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_shading)
430 RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_wire)
431
432 #undef RNA_LAYER_ENGINE_GET_SET
433
434 static void rna_ViewLayerEngineSettings_update(bContext *C, PointerRNA *UNUSED(ptr))
435 {
436         Scene *scene = CTX_data_scene(C);
437         /* TODO(sergey): Use proper flag for tagging here. */
438         DEG_id_tag_update(&scene->id, 0);
439 }
440
441 static void rna_LayerCollectionEngineSettings_update(bContext *UNUSED(C), PointerRNA *ptr)
442 {
443         ID *id = ptr->id.data;
444         /* TODO(sergey): Use proper flag for tagging here. */
445         DEG_id_tag_update(id, 0);
446
447         /* Instead of passing 'noteflag' to the rna update function, we handle the notifier ourselves.
448          * We need to do this because the LayerCollection may be coming from different ID types (Scene or Group)
449          * and when using NC_SCENE the id most match the active scene for the listener to receive the notification.*/
450
451         WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
452 }
453
454 static void rna_LayerCollectionEngineSettings_wire_update(bContext *C, PointerRNA *UNUSED(ptr))
455 {
456         Scene *scene = CTX_data_scene(C);
457         ViewLayer *view_layer = CTX_data_view_layer(C);
458         Object *ob = OBACT(view_layer);
459
460         if (ob != NULL && ob->type == OB_MESH) {
461                 BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
462         }
463
464         /* TODO(sergey): Use proper flag for tagging here. */
465         DEG_id_tag_update(&scene->id, 0);
466 }
467
468 /***********************************/
469
470 static void engine_settings_use(IDProperty *root, IDProperty *props, PointerRNA *props_ptr, const char *identifier)
471 {
472         PropertyRNA *prop = RNA_struct_find_property(props_ptr, identifier);
473
474         switch (RNA_property_type(prop)) {
475                 case PROP_FLOAT:
476                 {
477                         float value = BKE_collection_engine_property_value_get_float(props, identifier);
478                         BKE_collection_engine_property_add_float(root, identifier, value);
479                         break;
480                 }
481                 case PROP_ENUM:
482                 {
483                         int value = BKE_collection_engine_property_value_get_int(props, identifier);
484                         BKE_collection_engine_property_add_int(root, identifier, value);
485                         break;
486                 }
487                 case PROP_INT:
488                 {
489                         int value = BKE_collection_engine_property_value_get_int(props, identifier);
490                         BKE_collection_engine_property_add_int(root, identifier, value);
491                         break;
492                 }
493                 case PROP_BOOLEAN:
494                 {
495                         int value = BKE_collection_engine_property_value_get_int(props, identifier);
496                         BKE_collection_engine_property_add_bool(root, identifier, value);
497                         break;
498                 }
499                 case PROP_STRING:
500                 case PROP_POINTER:
501                 case PROP_COLLECTION:
502                 default:
503                         break;
504         }
505 }
506
507 static StructRNA *rna_ViewLayerSettings_refine(PointerRNA *ptr)
508 {
509         IDProperty *props = (IDProperty *)ptr->data;
510         BLI_assert(props && props->type == IDP_GROUP);
511
512         switch (props->subtype) {
513                 case IDP_GROUP_SUB_ENGINE_RENDER:
514 #ifdef WITH_CLAY_ENGINE
515                         if (STREQ(props->name, RE_engine_id_BLENDER_CLAY)) {
516                                 return &RNA_ViewLayerEngineSettingsClay;
517                         }
518 #endif
519                         if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
520                                 return &RNA_ViewLayerEngineSettingsEevee;
521                         }
522                         break;
523                 case IDP_GROUP_SUB_MODE_OBJECT:
524                 case IDP_GROUP_SUB_MODE_EDIT:
525                 case IDP_GROUP_SUB_MODE_PAINT_WEIGHT:
526                 case IDP_GROUP_SUB_MODE_PAINT_VERTEX:
527                 default:
528                         BLI_assert(!"Mode not fully implemented");
529                         break;
530         }
531
532         return &RNA_ViewLayerSettings;
533 }
534
535 static void rna_ViewLayerSettings_name_get(PointerRNA *ptr, char *value)
536 {
537         IDProperty *props = (IDProperty *)ptr->data;
538         strcpy(value, props->name);
539 }
540
541 static int rna_ViewLayerSettings_name_length(PointerRNA *ptr)
542 {
543         IDProperty *props = (IDProperty *)ptr->data;
544         return strnlen(props->name, sizeof(props->name));
545 }
546
547 static void rna_ViewLayerSettings_use(ID *id, IDProperty *props, const char *identifier)
548 {
549         Scene *scene = (Scene *)id;
550         PointerRNA scene_props_ptr;
551         IDProperty *scene_props;
552
553         scene_props = BKE_view_layer_engine_scene_get(scene, COLLECTION_MODE_NONE, props->name);
554         RNA_pointer_create(id, &RNA_ViewLayerSettings, scene_props, &scene_props_ptr);
555
556         engine_settings_use(props, scene_props, &scene_props_ptr, identifier);
557
558         /* TODO(sergey): Use proper flag for tagging here. */
559         DEG_id_tag_update(id, 0);
560 }
561
562 static void rna_ViewLayerSettings_unuse(ID *id, IDProperty *props, const char *identifier)
563 {
564         IDProperty *prop_to_remove = IDP_GetPropertyFromGroup(props, identifier);
565         IDP_FreeFromGroup(props, prop_to_remove);
566
567         /* TODO(sergey): Use proper flag for tagging here. */
568         DEG_id_tag_update(id, 0);
569 }
570
571 static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr)
572 {
573         IDProperty *props = (IDProperty *)ptr->data;
574         BLI_assert(props && props->type == IDP_GROUP);
575
576         switch (props->subtype) {
577                 case IDP_GROUP_SUB_ENGINE_RENDER:
578 #ifdef WITH_CLAY_ENGINE
579                         if (STREQ(props->name, RE_engine_id_BLENDER_CLAY)) {
580                                 return &RNA_LayerCollectionEngineSettingsClay;
581                         }
582 #endif
583                         if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
584                                 /* printf("Mode not fully implemented\n"); */
585                                 return &RNA_LayerCollectionSettings;
586                         }
587                         break;
588                 case IDP_GROUP_SUB_MODE_OBJECT:
589                         return &RNA_LayerCollectionModeSettingsObject;
590                         break;
591                 case IDP_GROUP_SUB_MODE_EDIT:
592                         return &RNA_LayerCollectionModeSettingsEdit;
593                         break;
594                 case IDP_GROUP_SUB_MODE_PAINT_WEIGHT:
595                         return &RNA_LayerCollectionModeSettingsPaintWeight;
596                         break;
597                 case IDP_GROUP_SUB_MODE_PAINT_VERTEX:
598                         return &RNA_LayerCollectionModeSettingsPaintVertex;
599                         break;
600                 default:
601                         BLI_assert(!"Mode not fully implemented");
602                         break;
603         }
604
605         return &RNA_LayerCollectionSettings;
606 }
607
608 static void rna_LayerCollectionSettings_name_get(PointerRNA *ptr, char *value)
609 {
610         IDProperty *props = (IDProperty *)ptr->data;
611         strcpy(value, props->name);
612 }
613
614 static int rna_LayerCollectionSettings_name_length(PointerRNA *ptr)
615 {
616         IDProperty *props = (IDProperty *)ptr->data;
617         return strnlen(props->name, sizeof(props->name));
618 }
619
620 static void rna_LayerCollectionSettings_use(ID *id, IDProperty *props, const char *identifier)
621 {
622         Scene *scene = (Scene *)id;
623         PointerRNA scene_props_ptr;
624         IDProperty *scene_props;
625
626         scene_props = BKE_layer_collection_engine_scene_get(scene, COLLECTION_MODE_NONE, props->name);
627         RNA_pointer_create(id, &RNA_LayerCollectionSettings, scene_props, &scene_props_ptr);
628         engine_settings_use(props, scene_props, &scene_props_ptr, identifier);
629
630         /* TODO(sergey): Use proper flag for tagging here. */
631         DEG_id_tag_update(id, 0);
632 }
633
634 static void rna_LayerCollectionSettings_unuse(ID *id, IDProperty *props, const char *identifier)
635 {
636         IDProperty *prop_to_remove = IDP_GetPropertyFromGroup(props, identifier);
637         IDP_FreeFromGroup(props, prop_to_remove);
638
639         /* TODO(sergey): Use proper flag for tagging here. */
640         DEG_id_tag_update(id, 0);
641 }
642
643 static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value)
644 {
645         SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
646         strcpy(value, sc->name);
647 }
648
649 static int rna_LayerCollection_name_length(PointerRNA *ptr)
650 {
651         SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
652         return strnlen(sc->name, sizeof(sc->name));
653 }
654
655 static void rna_LayerCollection_name_set(PointerRNA *ptr, const char *value)
656 {
657         Scene *scene = (Scene *)ptr->id.data;
658         SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
659         BKE_collection_rename(scene, sc, value);
660 }
661
662 static PointerRNA rna_LayerCollection_objects_get(CollectionPropertyIterator *iter)
663 {
664         ListBaseIterator *internal = &iter->internal.listbase;
665         Base *base = ((LinkData *)internal->link)->data;
666         return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object);
667 }
668
669 static int rna_LayerCollection_move_above(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
670 {
671         if (!BKE_layer_collection_move_above(id, lc_dst, lc_src)) {
672                 return 0;
673         }
674
675         DEG_relations_tag_update(bmain);
676         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
677
678         return 1;
679 }
680
681 static int rna_LayerCollection_move_below(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
682 {
683         if (!BKE_layer_collection_move_below(id, lc_dst, lc_src)) {
684                 return 0;
685         }
686
687         DEG_relations_tag_update(bmain);
688         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
689
690         return 1;
691 }
692
693 static int rna_LayerCollection_move_into(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
694 {
695         if (!BKE_layer_collection_move_into(id, lc_dst, lc_src)) {
696                 return 0;
697         }
698
699         DEG_relations_tag_update(bmain);
700         WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
701
702         return 1;
703 }
704
705 static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *ptr)
706 {
707         ID *id = ptr->id.data;
708         /* TODO(sergey): Use proper flag for tagging here. */
709         DEG_id_tag_update(id, 0);
710         WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
711 }
712
713 static Group *rna_LayerCollection_create_group(
714         ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports)
715 {
716         Group *group;
717         Scene *scene = (Scene *)id;
718         SceneCollection *scene_collection = layer_collection->scene_collection;
719
720         /* The master collection can't be converted. */
721         if (scene_collection == BKE_collection_master(&scene->id)) {
722                 BKE_report(reports, RPT_ERROR, "The master collection can't be converted to group");
723                 return NULL;
724         }
725
726         group = BKE_collection_group_create(bmain, scene, layer_collection);
727         if (group == NULL) {
728                 BKE_reportf(reports, RPT_ERROR, "Failed to convert collection %s", scene_collection->name);
729                 return NULL;
730         }
731
732         DEG_relations_tag_update(bmain);
733         /* TODO(sergey): Use proper flag for tagging here. */
734         DEG_id_tag_update(&scene->id, 0);
735         WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
736         return group;
737 }
738
739 static LayerCollection *rna_LayerCollection_duplicate(
740         ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports)
741 {
742         if (layer_collection->scene_collection == BKE_collection_master(id)) {
743                 BKE_report(reports, RPT_ERROR, "The master collection can't be duplicated");
744                 return NULL;
745         }
746
747         LayerCollection *layer_collection_new = BKE_layer_collection_duplicate(id, layer_collection);
748
749         DEG_relations_tag_update(bmain);
750         /* Don't use id here, since the layer collection may come from a group. */
751         WM_event_add_notifier(C, NC_SCENE | ND_LAYER, CTX_data_scene(C));
752
753         return layer_collection_new;
754 }
755
756 static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr)
757 {
758         ViewLayer *view_layer = (ViewLayer *)ptr->data;
759         return view_layer->active_collection;
760 }
761
762 static void rna_LayerCollections_active_collection_index_set(PointerRNA *ptr, int value)
763 {
764         ViewLayer *view_layer = (ViewLayer *)ptr->data;
765         int num_collections = BKE_layer_collection_count(view_layer);
766         view_layer->active_collection = min_ff(value, num_collections - 1);
767 }
768
769 static void rna_LayerCollections_active_collection_index_range(
770         PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
771 {
772         ViewLayer *view_layer = (ViewLayer *)ptr->data;
773         *min = 0;
774         *max = max_ii(0, BKE_layer_collection_count(view_layer) - 1);
775 }
776
777 static PointerRNA rna_LayerCollections_active_collection_get(PointerRNA *ptr)
778 {
779         ViewLayer *view_layer = (ViewLayer *)ptr->data;
780         LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
781         return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc);
782 }
783
784 static void rna_LayerCollections_active_collection_set(PointerRNA *ptr, PointerRNA value)
785 {
786         ViewLayer *view_layer = (ViewLayer *)ptr->data;
787         LayerCollection *lc = (LayerCollection *)value.data;
788         const int index = BKE_layer_collection_findindex(view_layer, lc);
789         if (index != -1) view_layer->active_collection = index;
790 }
791
792 LayerCollection * rna_ViewLayer_collection_link(
793         ID *id, ViewLayer *view_layer, Main *bmain, SceneCollection *sc)
794 {
795         Scene *scene = (Scene *)id;
796         LayerCollection *lc = BKE_collection_link(view_layer, sc);
797
798         DEG_relations_tag_update(bmain);
799         /* TODO(sergey): Use proper flag for tagging here. */
800         DEG_id_tag_update(id, 0);
801         WM_main_add_notifier(NC_SCENE | ND_LAYER, scene);
802
803         return lc;
804 }
805
806 static void rna_ViewLayer_collection_unlink(
807         ID *id, ViewLayer *view_layer, Main *bmain, ReportList *reports, LayerCollection *lc)
808 {
809         Scene *scene = (Scene *)id;
810
811         if (BLI_findindex(&view_layer->layer_collections, lc) == -1) {
812                 BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is not in '%s'",
813                             lc->scene_collection->name, view_layer->name);
814                 return;
815         }
816
817         BKE_collection_unlink(view_layer, lc);
818
819         DEG_relations_tag_update(bmain);
820         /* TODO(sergey): Use proper flag for tagging here. */
821         DEG_id_tag_update(id, 0);
822         WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
823 }
824
825 static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
826 {
827         ViewLayer *view_layer = (ViewLayer *)ptr->data;
828         return rna_pointer_inherit_refine(ptr, &RNA_Object, view_layer->basact ? view_layer->basact->object : NULL);
829 }
830
831 static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value)
832 {
833         ViewLayer *view_layer = (ViewLayer *)ptr->data;
834         if (value.data)
835                 view_layer->basact = BKE_view_layer_base_find(view_layer, (Object *)value.data);
836         else
837                 view_layer->basact = NULL;
838 }
839
840 static void rna_LayerObjects_active_object_update(struct bContext *C, PointerRNA *ptr)
841 {
842         wmWindow *win = CTX_wm_window(C);
843         Scene *scene = WM_window_get_active_scene(win);
844
845         if (scene != ptr->id.data) {
846                 return;
847         }
848
849         ViewLayer *view_layer = (ViewLayer *)ptr->data;
850         if (scene->obedit) {
851                 ED_object_editmode_exit(C, EM_FREEDATA);
852         }
853         ED_object_base_activate(C, view_layer->basact);
854 }
855
856 static IDProperty *rna_ViewLayer_idprops(PointerRNA *ptr, bool create)
857 {
858         ViewLayer *view_layer = (ViewLayer *)ptr->data;
859
860         if (create && !view_layer->id_properties) {
861                 IDPropertyTemplate val = {0};
862                 view_layer->id_properties = IDP_New(IDP_GROUP, &val, "ViewLayer ID properties");
863         }
864
865         return view_layer->id_properties;
866 }
867
868 static void rna_ViewLayer_update_render_passes(ID *id)
869 {
870         Scene *scene = (Scene *)id;
871         if (scene->nodetree)
872                 ntreeCompositUpdateRLayers(scene->nodetree);
873 }
874
875 static PointerRNA rna_ViewLayer_objects_get(CollectionPropertyIterator *iter)
876 {
877         ListBaseIterator *internal = &iter->internal.listbase;
878
879         /* we are actually iterating a ObjectBase list, so override get */
880         Base *base = (Base *)internal->link;
881         return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object);
882 }
883
884 static int rna_ViewLayer_objects_selected_skip(CollectionPropertyIterator *iter, void *UNUSED(data))
885 {
886         ListBaseIterator *internal = &iter->internal.listbase;
887         Base *base = (Base *)internal->link;
888
889         if ((base->flag & BASE_SELECTED) != 0) {
890                 return 0;
891         }
892
893         return 1;
894 };
895
896 static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr)
897 {
898         ID *id = ptr->id.data;
899         if (GS(id->name) == ID_SCE) {
900                 Scene *scene = (Scene *)id;
901                 ViewLayer *view_layer = (ViewLayer *)ptr->data;
902                 Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
903                 return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, depsgraph);
904         }
905         return PointerRNA_NULL;
906 }
907
908 static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
909 {
910         ViewLayer *view_layer = (ViewLayer *)ptr->data;
911         rna_iterator_listbase_begin(iter, &view_layer->object_bases, rna_ViewLayer_objects_selected_skip);
912 }
913
914 static void rna_ViewLayer_update_tagged(ViewLayer *UNUSED(view_layer), bContext *C)
915 {
916         Depsgraph *graph = CTX_data_depsgraph(C);
917         DEG_OBJECT_ITER(graph, ob, DEG_ITER_OBJECT_MODE_VIEWPORT,
918                         DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
919                         DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
920                         DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY |
921                         DEG_ITER_OBJECT_FLAG_VISIBLE |
922                         DEG_ITER_OBJECT_FLAG_DUPLI)
923         {
924                 /* Don't do anything, we just need to run the iterator to flush
925                  * the base info to the objects. */
926                 UNUSED_VARS(ob);
927         }
928         DEG_OBJECT_ITER_END
929 }
930
931 static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
932 {
933         Base *base = (Base *)ptr->data;
934         short mode = (base->flag & BASE_SELECTED) ? BA_SELECT : BA_DESELECT;
935         ED_object_base_select(base, mode);
936 }
937
938 static char *rna_ViewRenderSettings_path(PointerRNA *UNUSED(ptr))
939 {
940         return BLI_sprintfN("viewport_render");
941 }
942
943 static void rna_ViewRenderSettings_engine_set(PointerRNA *ptr, int value)
944 {
945         ViewRender *view_render = (ViewRender *)ptr->data;
946         RenderEngineType *type = BLI_findlink(&R_engines, value);
947
948         if (type) {
949                 BLI_strncpy_utf8(view_render->engine_id, type->idname, sizeof(view_render->engine_id));
950                 DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
951         }
952 }
953
954 static const EnumPropertyItem *rna_ViewRenderSettings_engine_itemf(
955         bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
956 {
957         RenderEngineType *type;
958         EnumPropertyItem *item = NULL;
959         EnumPropertyItem tmp = {0, "", 0, "", ""};
960         int a = 0, totitem = 0;
961
962         for (type = R_engines.first; type; type = type->next, a++) {
963                 tmp.value = a;
964                 tmp.identifier = type->idname;
965                 tmp.name = type->name;
966                 RNA_enum_item_add(&item, &totitem, &tmp);
967         }
968
969         RNA_enum_item_end(&item, &totitem);
970         *r_free = true;
971
972         return item;
973 }
974
975 static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr)
976 {
977         ViewRender *view_render = (ViewRender *)ptr->data;
978         RenderEngineType *type;
979         int a = 0;
980
981         for (type = R_engines.first; type; type = type->next, a++)
982                 if (STREQ(type->idname, view_render->engine_id))
983                         return a;
984
985         return 0;
986 }
987
988 static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
989 {
990         ED_render_engine_changed(bmain);
991 }
992
993 static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
994 {
995         return (BLI_listbase_count(&R_engines) > 1);
996 }
997
998 static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr)
999 {
1000         ViewRender *view_render = (ViewRender *)ptr->data;
1001         return BKE_viewrender_use_new_shading_nodes(view_render);
1002 }
1003
1004 static int rna_ViewRenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
1005 {
1006         ViewRender *view_render = (ViewRender *)ptr->data;
1007         return BKE_viewrender_use_spherical_stereo(view_render);
1008 }
1009
1010 static int rna_ViewRenderSettings_use_game_engine_get(PointerRNA *ptr)
1011 {
1012         ViewRender *view_render = (ViewRender *)ptr->data;
1013         RenderEngineType *type;
1014
1015         for (type = R_engines.first; type; type = type->next)
1016                 if (STREQ(type->idname, view_render->engine_id))
1017                         return (type->flag & RE_GAME) != 0;
1018
1019         return 0;
1020 }
1021
1022 #else
1023
1024 static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop)
1025 {
1026         StructRNA *srna;
1027         FunctionRNA *func;
1028         PropertyRNA *parm;
1029
1030         RNA_def_property_srna(cprop, "SceneCollections");
1031         srna = RNA_def_struct(brna, "SceneCollections", NULL);
1032         RNA_def_struct_sdna(srna, "SceneCollection");
1033         RNA_def_struct_ui_text(srna, "Scene Collection", "Collection of scene collections");
1034
1035         func = RNA_def_function(srna, "new", "rna_SceneCollection_new");
1036         RNA_def_function_ui_description(func, "Add a collection to scene");
1037         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1038         parm = RNA_def_string(func, "name", NULL, 0, "", "New name for the collection (not unique)");
1039         parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
1040         RNA_def_function_return(func, parm);
1041
1042         func = RNA_def_function(srna, "remove", "rna_SceneCollection_remove");
1043         RNA_def_function_ui_description(func, "Remove a collection and move its objects to the master collection");
1044         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
1045         parm = RNA_def_pointer(func, "collection", "SceneCollection", "", "Collection to remove");
1046         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1047         RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1048 }
1049
1050 static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
1051 {
1052         StructRNA *srna;
1053         FunctionRNA *func;
1054         PropertyRNA *parm;
1055         PropertyRNA *prop;
1056
1057         RNA_def_property_srna(cprop, "CollectionObjects");
1058         srna = RNA_def_struct(brna, "CollectionObjects", NULL);
1059         RNA_def_struct_sdna(srna, "SceneCollection");
1060         RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection");
1061
1062         prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1063         RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get",
1064                                    "rna_SceneCollection_objects_active_index_set",
1065                                    "rna_SceneCollection_objects_active_index_range");
1066         RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array");
1067         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1068
1069         func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link");
1070         RNA_def_function_ui_description(func, "Link an object to collection");
1071         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
1072         parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to collection");
1073         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1074
1075         func = RNA_def_function(srna, "unlink", "rna_SceneCollection_object_unlink");
1076         RNA_def_function_ui_description(func, "Unlink object from collection");
1077         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
1078         parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from collection");
1079         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1080 }
1081
1082 static void rna_def_scene_collection(BlenderRNA *brna)
1083 {
1084         StructRNA *srna;
1085         PropertyRNA *prop;
1086
1087         FunctionRNA *func;
1088         PropertyRNA *parm;
1089
1090         srna = RNA_def_struct(brna, "SceneCollection", NULL);
1091         RNA_def_struct_ui_text(srna, "Scene Collection", "Collection");
1092         RNA_def_struct_refine_func(srna, "rna_SceneCollection_refine");
1093
1094         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1095         RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_name_set");
1096         RNA_def_property_ui_text(prop, "Name", "Collection name");
1097         RNA_def_struct_name_property(srna, prop);
1098         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1099
1100         prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1101         RNA_def_property_enum_items(prop, rna_enum_collection_type_items);
1102         RNA_def_property_ui_text(prop, "Type", "Type of collection");
1103         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1104
1105         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
1106         RNA_def_property_collection_sdna(prop, NULL, "scene_collections", NULL);
1107         RNA_def_property_struct_type(prop, "SceneCollection");
1108         RNA_def_property_ui_text(prop, "SceneCollections", "");
1109         rna_def_scene_collections(brna, prop);
1110
1111         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
1112         RNA_def_property_collection_sdna(prop, NULL, "objects", NULL);
1113         RNA_def_property_struct_type(prop, "Object");
1114         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL);
1115         RNA_def_property_ui_text(prop, "Objects", "All the objects directly added to this collection (not including sub-collection objects)");
1116         rna_def_collection_objects(brna, prop);
1117
1118         /* Functions */
1119         func = RNA_def_function(srna, "move_above", "rna_SceneCollection_move_above");
1120         RNA_def_function_ui_description(func, "Move collection after another");
1121         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1122         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection above which the collection will move");
1123         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1124         RNA_def_function_return(func, parm);
1125
1126         func = RNA_def_function(srna, "move_below", "rna_SceneCollection_move_below");
1127         RNA_def_function_ui_description(func, "Move collection before another");
1128         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1129         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection below which the collection will move");
1130         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1131         RNA_def_function_return(func, parm);
1132
1133         func = RNA_def_function(srna, "move_into", "rna_SceneCollection_move_into");
1134         RNA_def_function_ui_description(func, "Move collection into another");
1135         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1136         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Collection to insert into");
1137         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1138         RNA_def_function_return(func, parm);
1139
1140         func = RNA_def_function(srna, "duplicate", "rna_SceneCollection_duplicate");
1141         RNA_def_function_ui_description(func, "Create a copy of the collection");
1142         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1143         parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
1144         RNA_def_function_return(func, parm);
1145 }
1146
1147 static void rna_def_layer_collection_override(BlenderRNA *brna)
1148 {
1149         StructRNA *srna;
1150         PropertyRNA *prop;
1151
1152         srna = RNA_def_struct(brna, "LayerCollectionOverride", NULL);
1153         RNA_def_struct_sdna(srna, "CollectionOverride");
1154         RNA_def_struct_ui_text(srna, "Collection Override", "Collection Override");
1155
1156         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1157         RNA_def_property_ui_text(prop, "Name", "Collection name");
1158         RNA_def_struct_name_property(srna, prop);
1159         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1160 }
1161
1162
1163 #ifdef WITH_CLAY_ENGINE
1164 static void rna_def_view_layer_engine_settings_clay(BlenderRNA *brna)
1165 {
1166         StructRNA *srna;
1167         PropertyRNA *prop;
1168
1169         srna = RNA_def_struct(brna, "ViewLayerEngineSettingsClay", "ViewLayerSettings");
1170         RNA_def_struct_ui_text(srna, "Clay Scene Layer Settings", "Clay Engine settings");
1171
1172         RNA_define_verify_sdna(0); /* not in sdna */
1173
1174         /* see RNA_LAYER_ENGINE_GET_SET macro */
1175         prop = RNA_def_property(srna, "ssao_samples", PROP_INT, PROP_NONE);
1176         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_samples_get",
1177                                    "rna_LayerEngineSettings_Clay_ssao_samples_set", NULL);
1178         RNA_def_property_ui_text(prop, "Samples", "Number of samples");
1179         RNA_def_property_range(prop, 1, 500);
1180         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1181         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1182
1183         RNA_define_verify_sdna(1); /* not in sdna */
1184 }
1185 #endif /* WITH_CLAY_ENGINE */
1186
1187 static void rna_def_view_layer_engine_settings_eevee(BlenderRNA *brna)
1188 {
1189         StructRNA *srna;
1190         PropertyRNA *prop;
1191
1192         /* Keep in sync with eevee_private.h */
1193         static const  EnumPropertyItem eevee_shadow_method_items[] = {
1194                 {1, "ESM", 0, "ESM", "Exponential Shadow Mapping"},
1195                 {2, "VSM", 0, "VSM", "Variance Shadow Mapping"},
1196                 {0, NULL, 0, NULL, NULL}
1197         };
1198
1199         static const EnumPropertyItem eevee_shadow_size_items[] = {
1200                 {64, "64", 0, "64px", ""},
1201                 {128, "128", 0, "128px", ""},
1202                 {256, "256", 0, "256px", ""},
1203                 {512, "512", 0, "512px", ""},
1204                 {1024, "1024", 0, "1024px", ""},
1205                 {2048, "2048", 0, "2048px", ""},
1206                 {4096, "4096", 0, "4096px", ""},
1207                 {8192, "8192", 0, "8192px", ""},
1208                 {0, NULL, 0, NULL, NULL}
1209         };
1210
1211         static const EnumPropertyItem eevee_gi_visibility_size_items[] = {
1212                 {8, "8", 0, "8px", ""},
1213                 {16, "16", 0, "16px", ""},
1214                 {32, "32", 0, "32px", ""},
1215                 {64, "64", 0, "64px", ""},
1216                 {0, NULL, 0, NULL, NULL}
1217         };
1218
1219         static const EnumPropertyItem eevee_volumetric_tile_size_items[] = {
1220                 {2, "2", 0, "2px", ""},
1221                 {4, "4", 0, "4px", ""},
1222                 {8, "8", 0, "8px", ""},
1223                 {16, "16", 0, "16px", ""},
1224                 {0, NULL, 0, NULL, NULL}
1225         };
1226
1227         srna = RNA_def_struct(brna, "ViewLayerEngineSettingsEevee", "ViewLayerSettings");
1228         RNA_def_struct_ui_text(srna, "Eevee Scene Layer Settings", "Eevee Engine settings");
1229
1230         RNA_define_verify_sdna(0); /* not in sdna */
1231
1232         /* see RNA_LAYER_ENGINE_GET_SET macro */
1233
1234         /* Indirect Lighting */
1235         prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE);
1236         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_get",
1237                                        "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_set", NULL);
1238         RNA_def_property_ui_text(prop, "Diffuse Bounces", "Number of time the light is reinjected inside light grids, "
1239                                                           "0 disable indirect diffuse light");
1240         RNA_def_property_range(prop, 0, INT_MAX);
1241         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1242         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1243
1244         prop = RNA_def_property(srna, "gi_cubemap_resolution", PROP_ENUM, PROP_NONE);
1245         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_cubemap_resolution_get",
1246                                           "rna_LayerEngineSettings_Eevee_gi_cubemap_resolution_set", NULL);
1247         RNA_def_property_enum_items(prop, eevee_shadow_size_items);
1248         RNA_def_property_ui_text(prop, "Cubemap Size", "Size of every cubemaps");
1249         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1250         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1251
1252         prop = RNA_def_property(srna, "gi_visibility_resolution", PROP_ENUM, PROP_NONE);
1253         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_visibility_resolution_get",
1254                                           "rna_LayerEngineSettings_Eevee_gi_visibility_resolution_set", NULL);
1255         RNA_def_property_enum_items(prop, eevee_gi_visibility_size_items);
1256         RNA_def_property_ui_text(prop, "Irradiance Visibility Size",
1257                                        "Size of the shadow map applied to each irradiance sample");
1258         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1259         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1260
1261         /* Temporal Anti-Aliasing (super sampling) */
1262         prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
1263         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_samples_get",
1264                                        "rna_LayerEngineSettings_Eevee_taa_samples_set", NULL);
1265         RNA_def_property_ui_text(prop, "Viewport Samples", "Number of samples, unlimited if 0");
1266         RNA_def_property_range(prop, 0, INT_MAX);
1267         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1268         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1269
1270         prop = RNA_def_property(srna, "taa_render_samples", PROP_INT, PROP_NONE);
1271         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_render_samples_get",
1272                                        "rna_LayerEngineSettings_Eevee_taa_render_samples_set", NULL);
1273         RNA_def_property_ui_text(prop, "Render Samples", "Number of samples per pixels for rendering");
1274         RNA_def_property_range(prop, 1, INT_MAX);
1275         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1276         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1277
1278         /* Screen Space Subsurface Scattering */
1279         prop = RNA_def_property(srna, "sss_enable", PROP_BOOLEAN, PROP_NONE);
1280         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_sss_enable_get",
1281                                        "rna_LayerEngineSettings_Eevee_sss_enable_set");
1282         RNA_def_property_ui_text(prop, "Subsurface Scattering", "Enable screen space subsurface scattering");
1283         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1284         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1285
1286         prop = RNA_def_property(srna, "sss_samples", PROP_INT, PROP_NONE);
1287         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_sss_samples_get",
1288                                        "rna_LayerEngineSettings_Eevee_sss_samples_set", NULL);
1289         RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute the scattering effect");
1290         RNA_def_property_range(prop, 1, 32);
1291         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1292         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1293
1294         prop = RNA_def_property(srna, "sss_jitter_threshold", PROP_FLOAT, PROP_FACTOR);
1295         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_sss_jitter_threshold_get",
1296                                        "rna_LayerEngineSettings_Eevee_sss_jitter_threshold_set", NULL);
1297         RNA_def_property_ui_text(prop, "Jitter Threshold", "Rotate samples that are below this threshold");
1298         RNA_def_property_range(prop, 0.0f, 1.0f);
1299         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1300         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1301
1302         prop = RNA_def_property(srna, "sss_separate_albedo", PROP_BOOLEAN, PROP_NONE);
1303         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_sss_separate_albedo_get",
1304                                        "rna_LayerEngineSettings_Eevee_sss_separate_albedo_set");
1305         RNA_def_property_ui_text(prop, "Separate Albedo", "Avoid albedo being blured by the subsurface scattering "
1306                                                           "but uses more video memory");
1307         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1308         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1309
1310         /* Screen Space Reflection */
1311         prop = RNA_def_property(srna, "ssr_enable", PROP_BOOLEAN, PROP_NONE);
1312         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_enable_get",
1313                                        "rna_LayerEngineSettings_Eevee_ssr_enable_set");
1314         RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection");
1315         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1316         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1317
1318         prop = RNA_def_property(srna, "ssr_refraction", PROP_BOOLEAN, PROP_NONE);
1319         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_refraction_get",
1320                                        "rna_LayerEngineSettings_Eevee_ssr_refraction_set");
1321         RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions");
1322         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1323         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1324
1325         prop = RNA_def_property(srna, "ssr_halfres", PROP_BOOLEAN, PROP_NONE);
1326         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_halfres_get",
1327                                        "rna_LayerEngineSettings_Eevee_ssr_halfres_set");
1328         RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution");
1329         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1330         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1331
1332         prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR);
1333         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_quality_get",
1334                                        "rna_LayerEngineSettings_Eevee_ssr_quality_set", NULL);
1335         RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the screen space raytracing");
1336         RNA_def_property_range(prop, 0.0f, 1.0f);
1337         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1338         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1339
1340         prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR);
1341         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_max_roughness_get",
1342                                        "rna_LayerEngineSettings_Eevee_ssr_max_roughness_set", NULL);
1343         RNA_def_property_ui_text(prop, "Max Roughness", "Do not raytrace reflections for roughness above this value");
1344         RNA_def_property_range(prop, 0.0f, 1.0f);
1345         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1346         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1347
1348         prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE);
1349         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_thickness_get",
1350                                        "rna_LayerEngineSettings_Eevee_ssr_thickness_set", NULL);
1351         RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection");
1352         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1353         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3);
1354         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1355         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1356
1357         prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR);
1358         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_border_fade_get",
1359                                        "rna_LayerEngineSettings_Eevee_ssr_border_fade_set", NULL);
1360         RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR");
1361         RNA_def_property_range(prop, 0.0f, 0.5f);
1362         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1363         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1364
1365         prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE);
1366         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_get",
1367                                        "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_set", NULL);
1368         RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)");
1369         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1370         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1371         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1372
1373         /* Volumetrics */
1374         prop = RNA_def_property(srna, "volumetric_enable", PROP_BOOLEAN, PROP_NONE);
1375         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_enable_get",
1376                                        "rna_LayerEngineSettings_Eevee_volumetric_enable_set");
1377         RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material");
1378         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1379         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1380
1381         prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE);
1382         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_start_get",
1383                                        "rna_LayerEngineSettings_Eevee_volumetric_start_set", NULL);
1384         RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect");
1385         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1386         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
1387         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1388         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1389
1390         prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE);
1391         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_end_get",
1392                                        "rna_LayerEngineSettings_Eevee_volumetric_end_set", NULL);
1393         RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect");
1394         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1395         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
1396         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1397         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1398
1399         prop = RNA_def_property(srna, "volumetric_tile_size", PROP_ENUM, PROP_NONE);
1400         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_tile_size_get",
1401                                           "rna_LayerEngineSettings_Eevee_volumetric_tile_size_set", NULL);
1402         RNA_def_property_enum_items(prop, eevee_volumetric_tile_size_items);
1403         RNA_def_property_ui_text(prop, "Tile Size", "Control the quality of the volumetric effects "
1404                                                     "(lower size increase vram usage and quality)");
1405         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1406         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1407
1408         prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE);
1409         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_samples_get",
1410                                        "rna_LayerEngineSettings_Eevee_volumetric_samples_set", NULL);
1411         RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects");
1412         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1413         RNA_def_property_range(prop, 1, 256);
1414         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1415
1416         prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR);
1417         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_get",
1418                                        "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_set", NULL);
1419         RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera");
1420         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1421         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1422
1423         prop = RNA_def_property(srna, "volumetric_lights", PROP_BOOLEAN, PROP_NONE);
1424         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_lights_get",
1425                                        "rna_LayerEngineSettings_Eevee_volumetric_lights_set");
1426         RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics");
1427         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1428         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1429
1430         prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
1431         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_get",
1432                                        "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_set", NULL);
1433         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1434         RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise");
1435         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1436         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1437
1438         prop = RNA_def_property(srna, "volumetric_shadows", PROP_BOOLEAN, PROP_NONE);
1439         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadows_get",
1440                                        "rna_LayerEngineSettings_Eevee_volumetric_shadows_set");
1441         RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)");
1442         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1443         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1444
1445         prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE);
1446         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_get",
1447                                        "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_set", NULL);
1448         RNA_def_property_range(prop, 1, 128);
1449         RNA_def_property_ui_text(prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing");
1450         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1451         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1452
1453         prop = RNA_def_property(srna, "volumetric_colored_transmittance", PROP_BOOLEAN, PROP_NONE);
1454         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_get",
1455                                        "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_set");
1456         RNA_def_property_ui_text(prop, "Colored Transmittance", "Enable wavelength dependent volumetric transmittance");
1457         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1458         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1459
1460         /* Ambient Occlusion */
1461         prop = RNA_def_property(srna, "gtao_enable", PROP_BOOLEAN, PROP_NONE);
1462         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_enable_get",
1463                                        "rna_LayerEngineSettings_Eevee_gtao_enable_set");
1464         RNA_def_property_ui_text(prop, "Ambient Occlusion", "Enable ambient occlusion to simulate medium scale indirect shadowing");
1465         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1466         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1467
1468         prop = RNA_def_property(srna, "gtao_use_bent_normals", PROP_BOOLEAN, PROP_NONE);
1469         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_get",
1470                                        "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_set");
1471         RNA_def_property_ui_text(prop, "Bent Normals", "Compute main non occluded direction to sample the environment");
1472         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1473         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1474
1475         prop = RNA_def_property(srna, "gtao_bounce", PROP_BOOLEAN, PROP_NONE);
1476         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_bounce_get",
1477                                        "rna_LayerEngineSettings_Eevee_gtao_bounce_set");
1478         RNA_def_property_ui_text(prop, "Bounces Approximation", "An approximation to simulate light bounces "
1479                                                                 "giving less occlusion on brighter objects");
1480         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1481         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1482
1483         prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR);
1484         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_factor_get", "rna_LayerEngineSettings_Eevee_gtao_factor_set", NULL);
1485         RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
1486         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1487         RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2);
1488         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1489         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1490
1491         prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
1492         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_quality_get", "rna_LayerEngineSettings_Eevee_gtao_quality_set", NULL);
1493         RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the horizon search");
1494         RNA_def_property_range(prop, 0.0f, 1.0f);
1495         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1496         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1497
1498         prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE);
1499         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_distance_get", "rna_LayerEngineSettings_Eevee_gtao_distance_set", NULL);
1500         RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
1501         RNA_def_property_range(prop, 0.0f, 100000.0f);
1502         RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1503         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1504         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1505
1506         /* Depth of Field */
1507         prop = RNA_def_property(srna, "dof_enable", PROP_BOOLEAN, PROP_NONE);
1508         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_dof_enable_get",
1509                                        "rna_LayerEngineSettings_Eevee_dof_enable_set");
1510         RNA_def_property_ui_text(prop, "Depth of Field", "Enable depth of field using the values from the active camera");
1511         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1512         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1513
1514         prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_FACTOR);
1515         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_max_size_get",
1516                                      "rna_LayerEngineSettings_Eevee_bokeh_max_size_set", NULL);
1517         RNA_def_property_ui_text(prop, "Max Size", "Max size of the bokeh shape for the depth of field (lower is faster)");
1518         RNA_def_property_range(prop, 0.0f, 2000.0f);
1519         RNA_def_property_ui_range(prop, 2.0f, 200.0f, 1, 3);
1520         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1521         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1522
1523         prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR);
1524         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_threshold_get",
1525                                      "rna_LayerEngineSettings_Eevee_bokeh_threshold_set", NULL);
1526         RNA_def_property_ui_text(prop, "Sprite Threshold", "Brightness threshold for using sprite base depth of field");
1527         RNA_def_property_range(prop, 0.0f, 100000.0f);
1528         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1529         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1530         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1531
1532         /* Bloom */
1533         prop = RNA_def_property(srna, "bloom_enable", PROP_BOOLEAN, PROP_NONE);
1534         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_enable_get",
1535                                        "rna_LayerEngineSettings_Eevee_bloom_enable_set");
1536         RNA_def_property_ui_text(prop, "Bloom", "High brighness pixels generate a glowing effect");
1537         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1538         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1539
1540         prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR);
1541         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_threshold_get",
1542                                      "rna_LayerEngineSettings_Eevee_bloom_threshold_set", NULL);
1543         RNA_def_property_ui_text(prop, "Threshold", "Filters out pixels under this level of brightness");
1544         RNA_def_property_range(prop, 0.0f, 100000.0f);
1545         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1546         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1547         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1548
1549         prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR);
1550         RNA_def_property_array(prop, 3);
1551         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_color_get",
1552                                      "rna_LayerEngineSettings_Eevee_bloom_color_set", NULL);
1553         RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
1554         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1555         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1556
1557         prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR);
1558         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_knee_get",
1559                                      "rna_LayerEngineSettings_Eevee_bloom_knee_set", NULL);
1560         RNA_def_property_ui_text(prop, "Knee", "Makes transition between under/over-threshold gradual");
1561         RNA_def_property_range(prop, 0.0f, 1.0f);
1562         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1563         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1564
1565         prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR);
1566         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_radius_get",
1567                                      "rna_LayerEngineSettings_Eevee_bloom_radius_set", NULL);
1568         RNA_def_property_ui_text(prop, "Radius", "Bloom spread distance");
1569         RNA_def_property_range(prop, 0.0f, 100.0f);
1570         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1571         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1572         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1573
1574         prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
1575         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_clamp_get",
1576                                      "rna_LayerEngineSettings_Eevee_bloom_clamp_set", NULL);
1577         RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have");
1578         RNA_def_property_range(prop, 0.0f, 1000.0f);
1579         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1580         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1581         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1582
1583         prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED);
1584         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_intensity_get",
1585                                      "rna_LayerEngineSettings_Eevee_bloom_intensity_set", NULL);
1586         RNA_def_property_ui_text(prop, "Intensity", "Blend factor");
1587         RNA_def_property_range(prop, 0.0f, 10000.0f);
1588         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1589         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1590         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1591
1592         /* Motion blur */
1593         prop = RNA_def_property(srna, "motion_blur_enable", PROP_BOOLEAN, PROP_NONE);
1594         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_enable_get",
1595                                        "rna_LayerEngineSettings_Eevee_motion_blur_enable_set");
1596         RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)");
1597         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1598         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1599
1600         prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED);
1601         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_samples_get",
1602                                    "rna_LayerEngineSettings_Eevee_motion_blur_samples_set", NULL);
1603         RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur");
1604         RNA_def_property_range(prop, 1, 64);
1605         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1606         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1607
1608         prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
1609         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_shutter_get",
1610                                      "rna_LayerEngineSettings_Eevee_motion_blur_shutter_set", NULL);
1611         RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
1612         RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
1613         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1614         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1615
1616         /* Shadows */
1617         prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
1618         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_method_get", "rna_LayerEngineSettings_Eevee_shadow_method_set", NULL);
1619         RNA_def_property_enum_items(prop, eevee_shadow_method_items);
1620         RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows");
1621         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1622         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1623
1624         prop = RNA_def_property(srna, "shadow_size", PROP_ENUM, PROP_NONE);
1625         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_size_get", "rna_LayerEngineSettings_Eevee_shadow_size_set", NULL);
1626         RNA_def_property_enum_items(prop, eevee_shadow_size_items);
1627         RNA_def_property_ui_text(prop, "Size", "Size of every shadow maps");
1628         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1629         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1630
1631         prop = RNA_def_property(srna, "shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
1632         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_get", "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_set");
1633         RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
1634         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1635         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
1636
1637         RNA_define_verify_sdna(1); /* not in sdna */
1638 }
1639
1640 #ifdef WITH_CLAY_ENGINE
1641 static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
1642 {
1643         StructRNA *srna;
1644         PropertyRNA *prop;
1645
1646         static const EnumPropertyItem clay_matcap_items[] = {
1647             {ICON_MATCAP_01, "01", ICON_MATCAP_01, "", ""},
1648             {ICON_MATCAP_02, "02", ICON_MATCAP_02, "", ""},
1649             {ICON_MATCAP_03, "03", ICON_MATCAP_03, "", ""},
1650             {ICON_MATCAP_04, "04", ICON_MATCAP_04, "", ""},
1651             {ICON_MATCAP_05, "05", ICON_MATCAP_05, "", ""},
1652             {ICON_MATCAP_06, "06", ICON_MATCAP_06, "", ""},
1653             {ICON_MATCAP_07, "07", ICON_MATCAP_07, "", ""},
1654             {ICON_MATCAP_08, "08", ICON_MATCAP_08, "", ""},
1655             {ICON_MATCAP_09, "09", ICON_MATCAP_09, "", ""},
1656             {ICON_MATCAP_10, "10", ICON_MATCAP_10, "", ""},
1657             {ICON_MATCAP_11, "11", ICON_MATCAP_11, "", ""},
1658             {ICON_MATCAP_12, "12", ICON_MATCAP_12, "", ""},
1659             {ICON_MATCAP_13, "13", ICON_MATCAP_13, "", ""},
1660             {ICON_MATCAP_14, "14", ICON_MATCAP_14, "", ""},
1661             {ICON_MATCAP_15, "15", ICON_MATCAP_15, "", ""},
1662             {ICON_MATCAP_16, "16", ICON_MATCAP_16, "", ""},
1663             {ICON_MATCAP_17, "17", ICON_MATCAP_17, "", ""},
1664             {ICON_MATCAP_18, "18", ICON_MATCAP_18, "", ""},
1665             {ICON_MATCAP_19, "19", ICON_MATCAP_19, "", ""},
1666             {ICON_MATCAP_20, "20", ICON_MATCAP_20, "", ""},
1667             {ICON_MATCAP_21, "21", ICON_MATCAP_21, "", ""},
1668             {ICON_MATCAP_22, "22", ICON_MATCAP_22, "", ""},
1669             {ICON_MATCAP_23, "23", ICON_MATCAP_23, "", ""},
1670             {ICON_MATCAP_24, "24", ICON_MATCAP_24, "", ""},
1671             {0, NULL, 0, NULL, NULL}
1672         };
1673
1674         srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsClay", "LayerCollectionSettings");
1675         RNA_def_struct_ui_text(srna, "Collections Clay Engine Settings", "Engine specific settings for this collection");
1676
1677         RNA_define_verify_sdna(0); /* not in sdna */
1678
1679         /* see RNA_LAYER_ENGINE_GET_SET macro */
1680         prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE);
1681         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_icon_get", "rna_LayerEngineSettings_Clay_matcap_icon_set", NULL);
1682         RNA_def_property_enum_items(prop, clay_matcap_items);
1683         RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture by this material");
1684         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1685         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1686
1687         prop = RNA_def_property(srna, "matcap_rotation", PROP_FLOAT, PROP_FACTOR);
1688         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_rotation_get", "rna_LayerEngineSettings_Clay_matcap_rotation_set", NULL);
1689         RNA_def_property_range(prop, 0.0f, 1.0f);
1690         RNA_def_property_ui_text(prop, "Matcap Rotation", "Orientation of the matcap on the model");
1691         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1692         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1693
1694         prop = RNA_def_property(srna, "matcap_hue", PROP_FLOAT, PROP_FACTOR);
1695         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_hue_get", "rna_LayerEngineSettings_Clay_matcap_hue_set", NULL);
1696         RNA_def_property_range(prop, 0.0f, 1.0f);
1697         RNA_def_property_ui_text(prop, "Matcap Hue Shift", "Hue correction of the matcap");
1698         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1699         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1700
1701         prop = RNA_def_property(srna, "matcap_saturation", PROP_FLOAT, PROP_FACTOR);
1702         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_saturation_get", "rna_LayerEngineSettings_Clay_matcap_saturation_set", NULL);
1703         RNA_def_property_range(prop, 0.0f, 1.0f);
1704         RNA_def_property_ui_text(prop, "Matcap Saturation", "Saturation correction of the matcap");
1705         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1706         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1707
1708         prop = RNA_def_property(srna, "matcap_value", PROP_FLOAT, PROP_FACTOR);
1709         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_value_get", "rna_LayerEngineSettings_Clay_matcap_value_set", NULL);
1710         RNA_def_property_range(prop, 0.0f, 1.0f);
1711         RNA_def_property_ui_text(prop, "Matcap Value", "Value correction of the matcap");
1712         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1713         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1714
1715         prop = RNA_def_property(srna, "ssao_factor_cavity", PROP_FLOAT, PROP_NONE);
1716         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_cavity_get", "rna_LayerEngineSettings_Clay_ssao_factor_cavity_set", NULL);
1717         RNA_def_property_ui_text(prop, "Cavity Strength", "Strength of the Cavity effect");
1718         RNA_def_property_range(prop, 0.0f, 250.0f);
1719         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1720         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1721
1722         prop = RNA_def_property(srna, "ssao_factor_edge", PROP_FLOAT, PROP_NONE);
1723         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_edge_get", "rna_LayerEngineSettings_Clay_ssao_factor_edge_set", NULL);
1724         RNA_def_property_ui_text(prop, "Edge Strength", "Strength of the Edge effect");
1725         RNA_def_property_range(prop, 0.0f, 250.0f);
1726         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1727         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1728
1729         prop = RNA_def_property(srna, "ssao_distance", PROP_FLOAT, PROP_NONE);
1730         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_distance_get", "rna_LayerEngineSettings_Clay_ssao_distance_set", NULL);
1731         RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect");
1732         RNA_def_property_range(prop, 0.0f, 100000.0f);
1733         RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1734         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1735         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1736
1737         prop = RNA_def_property(srna, "ssao_attenuation", PROP_FLOAT, PROP_NONE);
1738         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_attenuation_get", "rna_LayerEngineSettings_Clay_ssao_attenuation_set", NULL);
1739         RNA_def_property_ui_text(prop, "Attenuation", "Attenuation constant");
1740         RNA_def_property_range(prop, 1.0f, 100000.0f);
1741         RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3);
1742         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1743         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1744
1745         prop = RNA_def_property(srna, "hair_brightness_randomness", PROP_FLOAT, PROP_NONE);
1746         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_hair_brightness_randomness_get", "rna_LayerEngineSettings_Clay_hair_brightness_randomness_set", NULL);
1747         RNA_def_property_ui_text(prop, "Hair Brightness Randomness", "Brightness randomness for hair");
1748         RNA_def_property_range(prop, 0.0f, 1.0f);
1749         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1750         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1751
1752         RNA_define_verify_sdna(1); /* not in sdna */
1753 }
1754 #endif /* WITH_CLAY_ENGINE */
1755
1756 static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna)
1757 {
1758         StructRNA *srna;
1759         PropertyRNA *prop;
1760
1761         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsObject", "LayerCollectionSettings");
1762         RNA_def_struct_ui_text(srna, "Collections Object Mode Settings", "Object Mode specific settings for this collection");
1763         RNA_define_verify_sdna(0); /* not in sdna */
1764
1765         /* see RNA_LAYER_ENGINE_GET_SET macro */
1766
1767         prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
1768         RNA_def_property_ui_text(prop, "Wire", "Add the object's wireframe over solid drawing");
1769         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_wire_get", "rna_LayerEngineSettings_ObjectMode_show_wire_set");
1770         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1771         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1772
1773         prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE);
1774         RNA_def_property_ui_text(prop, "Backface Culling", "");
1775         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_backface_culling_get", "rna_LayerEngineSettings_ObjectMode_show_backface_culling_set");
1776         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1777         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1778
1779         RNA_define_verify_sdna(1); /* not in sdna */
1780 }
1781
1782 static void rna_def_layer_collection_mode_settings_edit(BlenderRNA *brna)
1783 {
1784         StructRNA *srna;
1785         PropertyRNA *prop;
1786
1787         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsEdit", "LayerCollectionSettings");
1788         RNA_def_struct_ui_text(srna, "Collections Edit Mode Settings", "Edit Mode specific settings to be overridden per collection");
1789         RNA_define_verify_sdna(0); /* not in sdna */
1790
1791         /* see RNA_LAYER_ENGINE_GET_SET macro */
1792
1793         prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);
1794         RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display");
1795         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_occlude_wire_get", "rna_LayerEngineSettings_EditMode_show_occlude_wire_set");
1796         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1797         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1798
1799         prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE);
1800         RNA_def_property_ui_text(prop, "Show Weights", "Draw weights in editmode");
1801         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_weight_get", "rna_LayerEngineSettings_EditMode_show_weight_set");
1802         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1803         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1804
1805         prop = RNA_def_property(srna, "face_normals_show", PROP_BOOLEAN, PROP_NONE);
1806         RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines");
1807         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_face_normals_show_get", "rna_LayerEngineSettings_EditMode_face_normals_show_set");
1808         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1809         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1810
1811         prop = RNA_def_property(srna, "vert_normals_show", PROP_BOOLEAN, PROP_NONE);
1812         RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");
1813         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_vert_normals_show_get", "rna_LayerEngineSettings_EditMode_vert_normals_show_set");
1814         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1815         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1816
1817         prop = RNA_def_property(srna, "loop_normals_show", PROP_BOOLEAN, PROP_NONE);
1818         RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines");
1819         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_loop_normals_show_get", "rna_LayerEngineSettings_EditMode_loop_normals_show_set");
1820         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1821         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1822
1823         prop = RNA_def_property(srna, "normals_length", PROP_FLOAT, PROP_FACTOR);
1824         RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view");
1825         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_normals_length_get", "rna_LayerEngineSettings_EditMode_normals_length_set", NULL);
1826         RNA_def_property_range(prop, 0.00001, 1000.0);
1827         RNA_def_property_ui_range(prop, 0.01, 10.0, 10.0, 2);
1828         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1829         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1830
1831         prop = RNA_def_property(srna, "backwire_opacity", PROP_FLOAT, PROP_FACTOR);
1832         RNA_def_property_ui_text(prop, "Backwire Opacity", "Opacity when rendering transparent wires");
1833         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_backwire_opacity_get", "rna_LayerEngineSettings_EditMode_backwire_opacity_set", NULL);
1834         RNA_def_property_range(prop, 0.0f, 1.0f);
1835         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1836         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1837
1838         RNA_define_verify_sdna(1); /* not in sdna */
1839 }
1840
1841 static void rna_def_layer_collection_mode_settings_paint_weight(BlenderRNA *brna)
1842 {
1843         StructRNA *srna;
1844         PropertyRNA *prop;
1845
1846         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintWeight", "LayerCollectionSettings");
1847         RNA_def_struct_ui_text(srna, "Collections Weight Paint Mode Settings", "Weight Paint Mode specific settings to be overridden per collection");
1848         RNA_define_verify_sdna(0); /* not in sdna */
1849
1850         /* see RNA_LAYER_ENGINE_GET_SET macro */
1851
1852         prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE);
1853         RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing");
1854         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_shading_get", "rna_LayerEngineSettings_PaintWeightMode_use_shading_set");
1855         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1856         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1857
1858         prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE);
1859         RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
1860         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_wire_get", "rna_LayerEngineSettings_PaintWeightMode_use_wire_set");
1861         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1862         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
1863
1864         RNA_define_verify_sdna(1); /* not in sdna */
1865 }
1866
1867 static void rna_def_layer_collection_mode_settings_paint_vertex(BlenderRNA *brna)
1868 {
1869         StructRNA *srna;
1870         PropertyRNA *prop;
1871
1872         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintVertex", "LayerCollectionSettings");
1873         RNA_def_struct_ui_text(srna, "Collections Vertex Paint Mode Settings", "Vertex Paint Mode specific settings to be overridden per collection");
1874         RNA_define_verify_sdna(0); /* not in sdna */
1875
1876         /* see RNA_LAYER_ENGINE_GET_SET macro */
1877
1878         prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE);
1879         RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing");
1880         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_shading_get", "rna_LayerEngineSettings_PaintVertexMode_use_shading_set");
1881         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1882         RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
1883
1884         prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE);
1885         RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
1886         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_wire_get", "rna_LayerEngineSettings_PaintVertexMode_use_wire_set");
1887         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1888         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
1889
1890         RNA_define_verify_sdna(1); /* not in sdna */
1891 }
1892
1893 static void rna_def_view_layer_settings(BlenderRNA *brna)
1894 {
1895         StructRNA *srna;
1896         PropertyRNA *prop;
1897         FunctionRNA *func;
1898         PropertyRNA *parm;
1899
1900         srna = RNA_def_struct(brna, "ViewLayerSettings", NULL);
1901         RNA_def_struct_sdna(srna, "IDProperty");
1902         RNA_def_struct_ui_text(srna, "Scene Layer Settings",
1903                                "Engine specific settings that can be overriden by ViewLayer");
1904         RNA_def_struct_refine_func(srna, "rna_ViewLayerSettings_refine");
1905
1906         RNA_define_verify_sdna(0);
1907
1908         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1909         RNA_def_property_string_funcs(prop, "rna_ViewLayerSettings_name_get", "rna_ViewLayerSettings_name_length", NULL);
1910         RNA_def_property_ui_text(prop, "Name", "Engine Name");
1911         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1912         RNA_def_struct_name_property(srna, prop);
1913
1914         func = RNA_def_function(srna, "use", "rna_ViewLayerSettings_use");
1915         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1916         RNA_def_function_ui_description(func, "Initialize this property to use");
1917         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set");
1918         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1919
1920         func = RNA_def_function(srna, "unuse", "rna_ViewLayerSettings_unuse");
1921         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1922         RNA_def_function_ui_description(func, "Remove the property");
1923         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset");
1924         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1925
1926 #ifdef WITH_CLAY_ENGINE
1927         rna_def_view_layer_engine_settings_clay(brna);
1928 #endif
1929         rna_def_view_layer_engine_settings_eevee(brna);
1930
1931 #if 0
1932         rna_def_view_layer_mode_settings_object(brna);
1933         rna_def_view_layer_mode_settings_edit(brna);
1934         rna_def_view_layer_mode_settings_paint_weight(brna);
1935         rna_def_view_layer_mode_settings_paint_vertex(brna);
1936 #endif
1937
1938         RNA_define_verify_sdna(1);
1939 }
1940
1941 static void rna_def_layer_collection_settings(BlenderRNA *brna)
1942 {
1943         StructRNA *srna;
1944         PropertyRNA *prop;
1945         FunctionRNA *func;
1946         PropertyRNA *parm;
1947
1948         srna = RNA_def_struct(brna, "LayerCollectionSettings", NULL);
1949         RNA_def_struct_sdna(srna, "IDProperty");
1950         RNA_def_struct_ui_text(srna, "Layer Collection Settings",
1951                                "Engine specific settings that can be overriden by LayerCollection");
1952         RNA_def_struct_refine_func(srna, "rna_LayerCollectionSettings_refine");
1953
1954         RNA_define_verify_sdna(0);
1955
1956         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1957         RNA_def_property_string_funcs(prop, "rna_LayerCollectionSettings_name_get", "rna_LayerCollectionSettings_name_length", NULL);
1958         RNA_def_property_ui_text(prop, "Name", "Engine Name");
1959         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1960         RNA_def_struct_name_property(srna, prop);
1961
1962         func = RNA_def_function(srna, "use", "rna_LayerCollectionSettings_use");
1963         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1964         RNA_def_function_ui_description(func, "Initialize this property to use");
1965         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set");
1966         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1967
1968         func = RNA_def_function(srna, "unuse", "rna_LayerCollectionSettings_unuse");
1969         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1970         RNA_def_function_ui_description(func, "Remove the property");
1971         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset");
1972         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1973
1974 #ifdef WITH_CLAY_ENGINE
1975         rna_def_layer_collection_engine_settings_clay(brna);
1976 #endif
1977
1978         rna_def_layer_collection_mode_settings_object(brna);
1979         rna_def_layer_collection_mode_settings_edit(brna);
1980         rna_def_layer_collection_mode_settings_paint_weight(brna);
1981         rna_def_layer_collection_mode_settings_paint_vertex(brna);
1982
1983         RNA_define_verify_sdna(1);
1984 }
1985
1986 static void rna_def_layer_collection(BlenderRNA *brna)
1987 {
1988         StructRNA *srna;
1989         PropertyRNA *prop;
1990
1991         FunctionRNA *func;
1992         PropertyRNA *parm;
1993
1994         srna = RNA_def_struct(brna, "LayerCollection", NULL);
1995         RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection");
1996
1997         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1998         RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", "rna_LayerCollection_name_set");
1999         RNA_def_property_ui_text(prop, "Name", "Collection name");
2000         RNA_def_struct_name_property(srna, prop);
2001         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
2002
2003         prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
2004         RNA_def_property_flag(prop, PROP_NEVER_NULL);
2005         RNA_def_property_pointer_sdna(prop, NULL, "scene_collection");
2006         RNA_def_property_struct_type(prop, "SceneCollection");
2007         RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
2008
2009         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
2010         RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
2011         RNA_def_property_struct_type(prop, "LayerCollection");
2012         RNA_def_property_ui_text(prop, "Layer Collections", "");
2013
2014         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
2015         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
2016         RNA_def_property_struct_type(prop, "Object");
2017         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_LayerCollection_objects_get", NULL, NULL, NULL, NULL);
2018         RNA_def_property_ui_text(prop, "Objects", "All the objects directly or indirectly added to this collection (not including sub-collection objects)");
2019
2020         prop = RNA_def_property(srna, "overrides", PROP_COLLECTION, PROP_NONE);
2021         RNA_def_property_collection_sdna(prop, NULL, "overrides", NULL);
2022         RNA_def_property_struct_type(prop, "LayerCollectionOverride");
2023         RNA_def_property_ui_text(prop, "Collection Overrides", "");
2024
2025         /* Override settings */
2026         prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE);
2027         RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL);
2028         RNA_def_property_struct_type(prop, "LayerCollectionSettings");
2029         RNA_def_property_ui_text(prop, "Collection Settings", "Override of engine specific render settings");
2030
2031         /* Functions */
2032         func = RNA_def_function(srna, "move_above", "rna_LayerCollection_move_above");
2033         RNA_def_function_ui_description(func, "Move collection after another");
2034         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2035         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection above which the collection will move");
2036         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
2037         RNA_def_function_return(func, parm);
2038
2039         func = RNA_def_function(srna, "move_below", "rna_LayerCollection_move_below");
2040         RNA_def_function_ui_description(func, "Move collection before another");
2041         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2042         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection below which the collection will move");
2043         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
2044         RNA_def_function_return(func, parm);
2045
2046         func = RNA_def_function(srna, "move_into", "rna_LayerCollection_move_into");
2047         RNA_def_function_ui_description(func, "Move collection into another");
2048         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2049         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Collection to insert into");
2050         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
2051         RNA_def_function_return(func, parm);
2052
2053         func = RNA_def_function(srna, "create_group", "rna_LayerCollection_create_group");
2054         RNA_def_function_ui_description(func, "Enable or disable a collection");
2055         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2056         parm = RNA_def_pointer(func, "result", "Group", "", "Newly created Group");
2057         RNA_def_function_return(func, parm);
2058
2059         func = RNA_def_function(srna, "duplicate", "rna_LayerCollection_duplicate");
2060         RNA_def_function_ui_description(func, "Create a copy of the collection");
2061         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2062         parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created collection");
2063         RNA_def_function_return(func, parm);
2064
2065         /* Flags */
2066         prop = RNA_def_property(srna, "selectable", PROP_BOOLEAN, PROP_NONE);
2067         RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE);
2068         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2069         RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
2070         RNA_def_property_ui_text(prop, "Selectable", "Restrict selection");
2071         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
2072
2073         prop = RNA_def_property(srna, "visible_viewport", PROP_BOOLEAN, PROP_NONE);
2074         RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_VIEWPORT);
2075         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2076         RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
2077         RNA_def_property_ui_text(prop, "Viewport Visibility", "");
2078         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
2079
2080         prop = RNA_def_property(srna, "visible_render", PROP_BOOLEAN, PROP_NONE);
2081         RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RENDER);
2082         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2083         RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
2084         RNA_def_property_ui_text(prop, "Render Visibility", "Control");
2085         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
2086
2087         prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
2088         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED);
2089         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2090         RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection");
2091         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
2092 }
2093
2094 static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop)
2095 {
2096         StructRNA *srna;
2097         FunctionRNA *func;
2098         PropertyRNA *prop;
2099         PropertyRNA *parm;
2100
2101         RNA_def_property_srna(cprop, "LayerCollections");
2102         srna = RNA_def_struct(brna, "LayerCollections", NULL);
2103         RNA_def_struct_sdna(srna, "ViewLayer");
2104         RNA_def_struct_ui_text(srna, "Layer Collections", "Collections of render layer");
2105
2106         prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2107         RNA_def_property_int_sdna(prop, NULL, "active_collection");
2108         RNA_def_property_int_funcs(prop, "rna_LayerCollections_active_collection_index_get",
2109                                    "rna_LayerCollections_active_collection_index_set",
2110                                    "rna_LayerCollections_active_collection_index_range");
2111         RNA_def_property_ui_text(prop, "Active Collection Index", "Active index in layer collection array");
2112         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2113
2114         prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2115         RNA_def_property_struct_type(prop, "LayerCollection");
2116         RNA_def_property_pointer_funcs(prop, "rna_LayerCollections_active_collection_get",
2117                                        "rna_LayerCollections_active_collection_set", NULL, NULL);
2118         RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
2119         RNA_def_property_ui_text(prop, "Active Layer Collection", "Active Layer Collection");
2120         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2121
2122         func = RNA_def_function(srna, "link", "rna_ViewLayer_collection_link");
2123         RNA_def_function_ui_description(func, "Link a collection to render layer");
2124         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2125         parm = RNA_def_pointer(func, "scene_collection", "SceneCollection", "", "Collection to add to render layer");
2126         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
2127         parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created layer collection");
2128         RNA_def_function_return(func, parm);
2129
2130         func = RNA_def_function(srna, "unlink", "rna_ViewLayer_collection_unlink");
2131         RNA_def_function_ui_description(func, "Unlink a collection from render layer");
2132         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
2133         parm = RNA_def_pointer(func, "layer_collection", "LayerCollection", "", "Layer collection to remove from render layer");
2134         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
2135 }
2136
2137 static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
2138 {
2139         StructRNA *srna;
2140         PropertyRNA *prop;
2141
2142         RNA_def_property_srna(cprop, "LayerObjects");
2143         srna = RNA_def_struct(brna, "LayerObjects", NULL);
2144         RNA_def_struct_sdna(srna, "ViewLayer");
2145         RNA_def_struct_ui_text(srna, "Layer Objects", "Collections of objects");
2146
2147         prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2148         RNA_def_property_struct_type(prop, "Object");
2149         RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", "rna_LayerObjects_active_object_set", NULL, NULL);
2150         RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK | PROP_CONTEXT_UPDATE);
2151         RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
2152         /* Could call: ED_object_base_activate(C, rl->basact);
2153          * but would be a bad level call and it seems the notifier is enough */
2154         RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, "rna_LayerObjects_active_object_update");
2155
2156         prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
2157         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
2158         RNA_def_property_struct_type(prop, "Object");
2159         RNA_def_property_collection_funcs(prop, "rna_LayerObjects_selected_begin", "rna_iterator_listbase_next",
2160                                           "rna_iterator_listbase_end", "rna_ViewLayer_objects_get",
2161                                           NULL, NULL, NULL, NULL);
2162         RNA_def_property_ui_text(prop, "Selected Objects", "All the selected objects of this layer");
2163 }
2164
2165 static void rna_def_object_base(BlenderRNA *brna)
2166 {
2167         StructRNA *srna;
2168         PropertyRNA *prop;
2169
2170         srna = RNA_def_struct(brna, "ObjectBase", NULL);
2171         RNA_def_struct_sdna(srna, "Base");
2172         RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a render layer");
2173         RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2174
2175         prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2176         RNA_def_property_pointer_sdna(prop, NULL, "object");
2177         RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2178
2179         prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2180         RNA_def_property_boolean_sdna(prop, NULL, "flag", BASE_SELECTED);
2181         RNA_def_property_ui_text(prop, "Select", "Object base selection state");
2182         RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update");
2183 }
2184
2185 static void rna_def_scene_view_render(BlenderRNA *brna)
2186 {
2187         StructRNA *srna;
2188         PropertyRNA *prop;
2189
2190         static const EnumPropertyItem engine_items[] = {
2191                 {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
2192                 {0, NULL, 0, NULL, NULL}
2193         };
2194
2195         srna = RNA_def_struct(brna, "ViewRenderSettings", NULL);
2196         RNA_def_struct_sdna(srna, "ViewRender");
2197         RNA_def_struct_path_func(srna, "rna_ViewRenderSettings_path");
2198         RNA_def_struct_ui_text(srna, "View Render", "Rendering settings related to viewport drawing/rendering");
2199
2200         /* engine */
2201         prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
2202         RNA_def_property_enum_items(prop, engine_items);
2203         RNA_def_property_enum_funcs(prop, "rna_ViewRenderSettings_engine_get", "rna_ViewRenderSettings_engine_set",
2204                                     "rna_ViewRenderSettings_engine_itemf");
2205         RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2206         RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
2207         RNA_def_property_update(prop, NC_WINDOW, "rna_ViewRenderSettings_engine_update");
2208
2209         prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
2210         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_multiple_engines_get", NULL);
2211         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2212         RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
2213
2214         prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
2215         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_shading_nodes_get", NULL);
2216         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2217         RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system");
2218
2219         prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
2220         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_spherical_stereo_get", NULL);
2221         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2222         RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
2223
2224         prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE);
2225         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_game_engine_get", NULL);
2226         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2227         RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine");
2228 }
2229
2230 void RNA_def_view_layer(BlenderRNA *brna)
2231 {
2232         FunctionRNA *func;
2233         StructRNA *srna;
2234         PropertyRNA *prop;
2235
2236         srna = RNA_def_struct(brna, "ViewLayer", NULL);
2237         RNA_def_struct_ui_text(srna, "Render Layer", "Render layer");
2238         RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
2239         RNA_def_struct_idprops_func(srna, "rna_ViewLayer_idprops");
2240
2241         rna_def_view_layer_common(srna, 1);
2242
2243         func = RNA_def_function(srna, "update_render_passes", "rna_ViewLayer_update_render_passes");
2244         RNA_def_function_ui_description(func, "Requery the enabled render passes from the render engine");
2245         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF);
2246
2247         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
2248         RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
2249         RNA_def_property_struct_type(prop, "LayerCollection");
2250         RNA_def_property_ui_text(prop, "Layer Collections", "");
2251         rna_def_layer_collections(brna, prop);
2252
2253         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
2254         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
2255         RNA_def_property_struct_type(prop, "Object");
2256         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_ViewLayer_objects_get", NULL, NULL, NULL, NULL);
2257         RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer");
2258         rna_def_layer_objects(brna, prop);
2259
2260         /* layer options */
2261         prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
2262         RNA_def_property_boolean_sdna(prop, NULL, "flag", VIEW_LAYER_RENDER);
2263         RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render layer");
2264         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2265
2266         prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
2267         RNA_def_property_boolean_sdna(prop, NULL, "flag", VIEW_LAYER_FREESTYLE);
2268         RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
2269         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2270
2271         /* Freestyle */
2272         rna_def_freestyle_settings(brna);
2273
2274         prop = RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE);
2275         RNA_def_property_flag(prop, PROP_NEVER_NULL);
2276         RNA_def_property_pointer_sdna(prop, NULL, "freestyle_config");
2277         RNA_def_property_struct_type(prop, "FreestyleSettings");
2278         RNA_def_property_ui_text(prop, "Freestyle Settings", "");
2279
2280         /* Override settings */
2281         prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE);
2282         RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL);
2283         RNA_def_property_struct_type(prop, "ViewLayerSettings");
2284         RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings");
2285
2286         /* debug update routine */
2287         func = RNA_def_function(srna, "update", "rna_ViewLayer_update_tagged");
2288         RNA_def_function_flag(func, FUNC_USE_CONTEXT);
2289         RNA_def_function_ui_description(func,
2290                                         "Update data tagged to be updated from previous access to data or operators");
2291
2292         /* Dependency Graph */
2293         prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
2294         RNA_def_property_struct_type(prop, "Depsgraph");
2295         RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
2296         RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_depsgraph_get", NULL, NULL, NULL);
2297
2298         /* Nested Data  */
2299         /* *** Non-Animated *** */
2300         RNA_define_animate_sdna(false);
2301         rna_def_scene_collection(brna);
2302         rna_def_layer_collection(brna);
2303         rna_def_layer_collection_override(brna);
2304         rna_def_object_base(brna);
2305         RNA_define_animate_sdna(true);
2306         /* *** Animated *** */
2307         rna_def_view_layer_settings(brna);
2308         rna_def_layer_collection_settings(brna);
2309         rna_def_scene_view_render(brna);
2310 }
2311
2312 #endif