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