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