2fffc3a6c8f5743db4f1ce6b3aab276bafd84e8c
[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 *sl = CTX_data_scene_layer(C);
427         Object *ob = OBACT_NEW(sl);
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 *sl = (SceneLayer *)ptr->data;
724         return sl->active_collection;
725 }
726
727 static void rna_LayerCollections_active_collection_index_set(PointerRNA *ptr, int value)
728 {
729         SceneLayer *sl = (SceneLayer *)ptr->data;
730         int num_collections = BKE_layer_collection_count(sl);
731         sl->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 *sl = (SceneLayer *)ptr->data;
738         *min = 0;
739         *max = max_ii(0, BKE_layer_collection_count(sl) - 1);
740 }
741
742 static PointerRNA rna_LayerCollections_active_collection_get(PointerRNA *ptr)
743 {
744         SceneLayer *sl = (SceneLayer *)ptr->data;
745         LayerCollection *lc = BKE_layer_collection_get_active(sl);
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 *sl = (SceneLayer *)ptr->data;
752         LayerCollection *lc = (LayerCollection *)value.data;
753         const int index = BKE_layer_collection_findindex(sl, lc);
754         if (index != -1) sl->active_collection = index;
755 }
756
757 LayerCollection * rna_SceneLayer_collection_link(
758         ID *id, SceneLayer *sl, Main *bmain, SceneCollection *sc)
759 {
760         Scene *scene = (Scene *)id;
761         LayerCollection *lc = BKE_collection_link(sl, 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 *sl, Main *bmain, ReportList *reports, LayerCollection *lc)
773 {
774         Scene *scene = (Scene *)id;
775
776         if (BLI_findindex(&sl->layer_collections, lc) == -1) {
777                 BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is not in '%s'", lc->scene_collection->name, sl->name);
778                 return;
779         }
780
781         BKE_collection_unlink(sl, lc);
782
783         DEG_relations_tag_update(bmain);
784         /* TODO(sergey): Use proper flag for tagging here. */
785         DEG_id_tag_update(id, 0);
786         WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
787 }
788
789 static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
790 {
791         SceneLayer *sl = (SceneLayer *)ptr->data;
792         return rna_pointer_inherit_refine(ptr, &RNA_Object, sl->basact ? sl->basact->object : NULL);
793 }
794
795 static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value)
796 {
797         SceneLayer *sl = (SceneLayer *)ptr->data;
798         if (value.data)
799                 sl->basact = BKE_scene_layer_base_find(sl, (Object *)value.data);
800         else
801                 sl->basact = NULL;
802 }
803
804 static void rna_SceneLayer_name_set(PointerRNA *ptr, const char *value)
805 {
806         Scene *scene = (Scene *)ptr->id.data;
807         SceneLayer *sl = (SceneLayer *)ptr->data;
808         char oldname[sizeof(sl->name)];
809
810         BLI_strncpy(oldname, sl->name, sizeof(sl->name));
811
812         BLI_strncpy_utf8(sl->name, value, sizeof(sl->name));
813         BLI_uniquename(&scene->render_layers, sl, DATA_("SceneLayer"), '.', offsetof(SceneLayer, name), sizeof(sl->name));
814
815         if (scene->nodetree) {
816                 bNode *node;
817                 int index = BLI_findindex(&scene->render_layers, sl);
818
819                 for (node = scene->nodetree->nodes.first; node; node = node->next) {
820                         if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) {
821                                 if (node->custom1 == index)
822                                         BLI_strncpy(node->name, sl->name, NODE_MAXSTR);
823                         }
824                 }
825         }
826 }
827
828 static PointerRNA rna_SceneLayer_objects_get(CollectionPropertyIterator *iter)
829 {
830         ListBaseIterator *internal = &iter->internal.listbase;
831
832         /* we are actually iterating a ObjectBase list, so override get */
833         Base *base = (Base *)internal->link;
834         return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object);
835 }
836
837 static int rna_SceneLayer_objects_selected_skip(CollectionPropertyIterator *iter, void *UNUSED(data))
838 {
839         ListBaseIterator *internal = &iter->internal.listbase;
840         Base *base = (Base *)internal->link;
841
842         if ((base->flag & BASE_SELECTED) != 0) {
843                 return 0;
844         }
845
846         return 1;
847 };
848
849 static PointerRNA rna_SceneLayer_depsgraph_get(PointerRNA *ptr)
850 {
851         Scene *scene = (Scene *)ptr->id.data;
852         SceneLayer *scene_layer = (SceneLayer *)ptr->data;
853         Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer, false);
854         return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, depsgraph);
855 }
856
857 static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
858 {
859         SceneLayer *sl = (SceneLayer *)ptr->data;
860         rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip);
861 }
862
863 static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C)
864 {
865         Depsgraph *graph = CTX_data_depsgraph(C);
866         DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL)
867         {
868                 /* Don't do anything, we just need to run the iterator to flush
869                  * the base info to the objects. */
870                 UNUSED_VARS(ob);
871         }
872         DEG_OBJECT_ITER_END
873 }
874
875 static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
876 {
877         Base *base = (Base *)ptr->data;
878         short mode = (base->flag & BASE_SELECTED) ? BA_SELECT : BA_DESELECT;
879         ED_object_base_select(base, mode);
880 }
881
882 static char *rna_ViewRenderSettings_path(PointerRNA *UNUSED(ptr))
883 {
884         return BLI_sprintfN("viewport_render");
885 }
886
887 static void rna_ViewRenderSettings_engine_set(PointerRNA *ptr, int value)
888 {
889         ViewRender *view_render = (ViewRender *)ptr->data;
890         RenderEngineType *type = BLI_findlink(&R_engines, value);
891
892         if (type) {
893                 BLI_strncpy_utf8(view_render->engine_id, type->idname, sizeof(view_render->engine_id));
894                 DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
895         }
896 }
897
898 static const EnumPropertyItem *rna_ViewRenderSettings_engine_itemf(
899         bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
900 {
901         RenderEngineType *type;
902         EnumPropertyItem *item = NULL;
903         EnumPropertyItem tmp = {0, "", 0, "", ""};
904         int a = 0, totitem = 0;
905
906         for (type = R_engines.first; type; type = type->next, a++) {
907                 tmp.value = a;
908                 tmp.identifier = type->idname;
909                 tmp.name = type->name;
910                 RNA_enum_item_add(&item, &totitem, &tmp);
911         }
912
913         RNA_enum_item_end(&item, &totitem);
914         *r_free = true;
915
916         return item;
917 }
918
919 static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr)
920 {
921         ViewRender *view_render = (ViewRender *)ptr->data;
922         RenderEngineType *type;
923         int a = 0;
924
925         for (type = R_engines.first; type; type = type->next, a++)
926                 if (STREQ(type->idname, view_render->engine_id))
927                         return a;
928
929         return 0;
930 }
931
932 static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
933 {
934         ED_render_engine_changed(bmain);
935 }
936
937 static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
938 {
939         return (BLI_listbase_count(&R_engines) > 1);
940 }
941
942 static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr)
943 {
944         ViewRender *view_render = (ViewRender *)ptr->data;
945         return BKE_viewrender_use_new_shading_nodes(view_render);
946 }
947
948 static int rna_ViewRenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
949 {
950         ViewRender *view_render = (ViewRender *)ptr->data;
951         return BKE_viewrender_use_spherical_stereo(view_render);
952 }
953
954 static int rna_ViewRenderSettings_use_game_engine_get(PointerRNA *ptr)
955 {
956         ViewRender *view_render = (ViewRender *)ptr->data;
957         RenderEngineType *type;
958
959         for (type = R_engines.first; type; type = type->next)
960                 if (STREQ(type->idname, view_render->engine_id))
961                         return (type->flag & RE_GAME) != 0;
962
963         return 0;
964 }
965
966 #else
967
968 static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop)
969 {
970         StructRNA *srna;
971         FunctionRNA *func;
972         PropertyRNA *parm;
973
974         RNA_def_property_srna(cprop, "SceneCollections");
975         srna = RNA_def_struct(brna, "SceneCollections", NULL);
976         RNA_def_struct_sdna(srna, "SceneCollection");
977         RNA_def_struct_ui_text(srna, "Scene Collection", "Collection of scene collections");
978
979         func = RNA_def_function(srna, "new", "rna_SceneCollection_new");
980         RNA_def_function_ui_description(func, "Add a collection to scene");
981         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
982         parm = RNA_def_string(func, "name", "SceneCollection", 0, "", "New name for the collection (not unique)");
983         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
984         parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
985         RNA_def_function_return(func, parm);
986
987         func = RNA_def_function(srna, "remove", "rna_SceneCollection_remove");
988         RNA_def_function_ui_description(func, "Remove a collection layer");
989         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
990         parm = RNA_def_pointer(func, "layer", "SceneCollection", "", "Collection to remove");
991         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
992         RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
993 }
994
995 static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
996 {
997         StructRNA *srna;
998         FunctionRNA *func;
999         PropertyRNA *parm;
1000         PropertyRNA *prop;
1001
1002         RNA_def_property_srna(cprop, "CollectionObjects");
1003         srna = RNA_def_struct(brna, "CollectionObjects", NULL);
1004         RNA_def_struct_sdna(srna, "SceneCollection");
1005         RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection");
1006
1007         prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1008         RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get",
1009                                    "rna_SceneCollection_objects_active_index_set",
1010                                    "rna_SceneCollection_objects_active_index_range");
1011         RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array");
1012         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1013
1014         func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link");
1015         RNA_def_function_ui_description(func, "Link an object to collection");
1016         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
1017         parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to collection");
1018         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1019
1020         func = RNA_def_function(srna, "unlink", "rna_SceneCollection_object_unlink");
1021         RNA_def_function_ui_description(func, "Unlink object from collection");
1022         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
1023         parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from collection");
1024         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1025 }
1026
1027 static void rna_def_scene_collection(BlenderRNA *brna)
1028 {
1029         StructRNA *srna;
1030         PropertyRNA *prop;
1031
1032         FunctionRNA *func;
1033         PropertyRNA *parm;
1034
1035         srna = RNA_def_struct(brna, "SceneCollection", NULL);
1036         RNA_def_struct_ui_text(srna, "Scene Collection", "Collection");
1037
1038         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1039         RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_name_set");
1040         RNA_def_property_ui_text(prop, "Name", "Collection name");
1041         RNA_def_struct_name_property(srna, prop);
1042         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1043
1044         prop = RNA_def_property(srna, "filter", PROP_STRING, PROP_NONE);
1045         RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_filter_set");
1046         RNA_def_property_ui_text(prop, "Filter", "Filter to dynamically include objects based on their names (e.g., CHAR_*)");
1047         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1048
1049         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
1050         RNA_def_property_collection_sdna(prop, NULL, "scene_collections", NULL);
1051         RNA_def_property_struct_type(prop, "SceneCollection");
1052         RNA_def_property_ui_text(prop, "SceneCollections", "");
1053         rna_def_scene_collections(brna, prop);
1054
1055         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
1056         RNA_def_property_collection_sdna(prop, NULL, "objects", NULL);
1057         RNA_def_property_struct_type(prop, "Object");
1058         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL);
1059         RNA_def_property_ui_text(prop, "Objects", "All the objects directly added to this collection (not including sub-collection objects)");
1060         rna_def_collection_objects(brna, prop);
1061
1062         prop = RNA_def_property(srna, "filters_objects", PROP_COLLECTION, PROP_NONE);
1063         RNA_def_property_collection_sdna(prop, NULL, "filter_objects", NULL);
1064         RNA_def_property_struct_type(prop, "Object");
1065         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL);
1066         RNA_def_property_ui_text(prop, "Filter Objects", "All the objects dynamically added to this collection via the filter");
1067
1068         /* Functions */
1069         func = RNA_def_function(srna, "move_above", "rna_SceneCollection_move_above");
1070         RNA_def_function_ui_description(func, "Move collection after another");
1071         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1072         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection above which the collection will move");
1073         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1074         RNA_def_function_return(func, parm);
1075
1076         func = RNA_def_function(srna, "move_below", "rna_SceneCollection_move_below");
1077         RNA_def_function_ui_description(func, "Move collection before another");
1078         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1079         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection below which the collection will move");
1080         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1081         RNA_def_function_return(func, parm);
1082
1083         func = RNA_def_function(srna, "move_into", "rna_SceneCollection_move_into");
1084         RNA_def_function_ui_description(func, "Move collection into another");
1085         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1086         parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Collection to insert into");
1087         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1088         RNA_def_function_return(func, parm);
1089 }
1090
1091 static void rna_def_layer_collection_override(BlenderRNA *brna)
1092 {
1093         StructRNA *srna;
1094         PropertyRNA *prop;
1095
1096         srna = RNA_def_struct(brna, "LayerCollectionOverride", NULL);
1097         RNA_def_struct_sdna(srna, "CollectionOverride");
1098         RNA_def_struct_ui_text(srna, "Collection Override", "Collection Override");
1099
1100         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1101         RNA_def_property_ui_text(prop, "Name", "Collection name");
1102         RNA_def_struct_name_property(srna, prop);
1103         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1104 }
1105
1106
1107 #ifdef WITH_CLAY_ENGINE
1108 static void rna_def_scene_layer_engine_settings_clay(BlenderRNA *brna)
1109 {
1110         StructRNA *srna;
1111         PropertyRNA *prop;
1112
1113         srna = RNA_def_struct(brna, "SceneLayerEngineSettingsClay", "SceneLayerSettings");
1114         RNA_def_struct_ui_text(srna, "Clay Scene Layer Settings", "Clay Engine settings");
1115
1116         RNA_define_verify_sdna(0); /* not in sdna */
1117
1118         /* see RNA_LAYER_ENGINE_GET_SET macro */
1119         prop = RNA_def_property(srna, "ssao_samples", PROP_INT, PROP_NONE);
1120         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_samples_get",
1121                                    "rna_LayerEngineSettings_Clay_ssao_samples_set", NULL);
1122         RNA_def_property_ui_text(prop, "Samples", "Number of samples");
1123         RNA_def_property_range(prop, 1, 500);
1124         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1125         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1126
1127         RNA_define_verify_sdna(1); /* not in sdna */
1128 }
1129 #endif /* WITH_CLAY_ENGINE */
1130
1131 static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
1132 {
1133         StructRNA *srna;
1134         PropertyRNA *prop;
1135
1136         /* Keep in sync with eevee_private.h */
1137         static const  EnumPropertyItem eevee_shadow_method_items[] = {
1138                 {1, "ESM", 0, "ESM", "Exponential Shadow Mapping"},
1139                 {2, "VSM", 0, "VSM", "Variance Shadow Mapping"},
1140                 {0, NULL, 0, NULL, NULL}
1141         };
1142
1143         static const EnumPropertyItem eevee_shadow_size_items[] = {
1144                 {64, "64", 0, "64px", ""},
1145                 {128, "128", 0, "128px", ""},
1146                 {256, "256", 0, "256px", ""},
1147                 {512, "512", 0, "512px", ""},
1148                 {1024, "1024", 0, "1024px", ""},
1149                 {2048, "2048", 0, "2048px", ""},
1150                 {4096, "4096", 0, "4096px", ""},
1151                 {8192, "8192", 0, "8192px", ""},
1152                 {0, NULL, 0, NULL, NULL}
1153         };
1154
1155         static const EnumPropertyItem eevee_volumetric_tile_size_items[] = {
1156                 {2, "2", 0, "2px", ""},
1157                 {4, "4", 0, "4px", ""},
1158                 {8, "8", 0, "8px", ""},
1159                 {16, "16", 0, "16px", ""},
1160                 {0, NULL, 0, NULL, NULL}
1161         };
1162
1163         srna = RNA_def_struct(brna, "SceneLayerEngineSettingsEevee", "SceneLayerSettings");
1164         RNA_def_struct_ui_text(srna, "Eevee Scene Layer Settings", "Eevee Engine settings");
1165
1166         RNA_define_verify_sdna(0); /* not in sdna */
1167
1168         /* see RNA_LAYER_ENGINE_GET_SET macro */
1169
1170         /* Indirect Lighting */
1171         prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE);
1172         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_get",
1173                                        "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_set", NULL);
1174         RNA_def_property_ui_text(prop, "Diffuse Bounces", "Number of time the light is reinjected inside light grids, "
1175                                                           "0 disable indirect diffuse light");
1176         RNA_def_property_range(prop, 0, INT_MAX);
1177         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1178         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1179
1180         prop = RNA_def_property(srna, "gi_cubemap_resolution", PROP_ENUM, PROP_NONE);
1181         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_cubemap_resolution_get", "rna_LayerEngineSettings_Eevee_gi_cubemap_resolution_set", NULL);
1182         RNA_def_property_enum_items(prop, eevee_shadow_size_items);
1183         RNA_def_property_ui_text(prop, "Cubemap Size", "Size of every cubemaps");
1184         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1185         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1186
1187         /* Temporal Anti-Aliasing (super sampling) */
1188         prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
1189         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_samples_get",
1190                                        "rna_LayerEngineSettings_Eevee_taa_samples_set", NULL);
1191         RNA_def_property_ui_text(prop, "Viewport Samples", "Number of temporal samples, unlimited if 0, "
1192                                                            "disabled if 1");
1193         RNA_def_property_range(prop, 0, INT_MAX);
1194         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1195         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1196
1197         /* Screen Space Reflection */
1198         prop = RNA_def_property(srna, "ssr_enable", PROP_BOOLEAN, PROP_NONE);
1199         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_enable_get",
1200                                        "rna_LayerEngineSettings_Eevee_ssr_enable_set");
1201         RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection");
1202         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1203         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1204
1205         prop = RNA_def_property(srna, "ssr_refraction", PROP_BOOLEAN, PROP_NONE);
1206         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_refraction_get",
1207                                        "rna_LayerEngineSettings_Eevee_ssr_refraction_set");
1208         RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions");
1209         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1210         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1211
1212         prop = RNA_def_property(srna, "ssr_halfres", PROP_BOOLEAN, PROP_NONE);
1213         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_halfres_get",
1214                                        "rna_LayerEngineSettings_Eevee_ssr_halfres_set");
1215         RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution");
1216         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1217         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1218
1219         prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR);
1220         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_quality_get",
1221                                        "rna_LayerEngineSettings_Eevee_ssr_quality_set", NULL);
1222         RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the screen space raytracing");
1223         RNA_def_property_range(prop, 0.0f, 1.0f);
1224         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1225         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1226
1227         prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR);
1228         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_max_roughness_get",
1229                                        "rna_LayerEngineSettings_Eevee_ssr_max_roughness_set", NULL);
1230         RNA_def_property_ui_text(prop, "Max Roughness", "Do not raytrace reflections for roughness above this value");
1231         RNA_def_property_range(prop, 0.0f, 1.0f);
1232         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1233         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1234
1235         prop = RNA_def_property(srna, "ssr_ray_count", PROP_INT, PROP_NONE);
1236         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_ray_count_get",
1237                                        "rna_LayerEngineSettings_Eevee_ssr_ray_count_set", NULL);
1238         RNA_def_property_ui_text(prop, "Samples", "Number of rays to trace per pixels");
1239         RNA_def_property_range(prop, 1, 4);
1240         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1241         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1242
1243         prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE);
1244         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_thickness_get",
1245                                        "rna_LayerEngineSettings_Eevee_ssr_thickness_set", NULL);
1246         RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection");
1247         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1248         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3);
1249         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1250         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1251
1252         prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR);
1253         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_border_fade_get",
1254                                        "rna_LayerEngineSettings_Eevee_ssr_border_fade_set", NULL);
1255         RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR");
1256         RNA_def_property_range(prop, 0.0f, 0.5f);
1257         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1258         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1259
1260         prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE);
1261         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_get",
1262                                        "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_set", NULL);
1263         RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)");
1264         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1265         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1266         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1267
1268         /* Volumetrics */
1269         prop = RNA_def_property(srna, "volumetric_enable", PROP_BOOLEAN, PROP_NONE);
1270         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_enable_get",
1271                                        "rna_LayerEngineSettings_Eevee_volumetric_enable_set");
1272         RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material");
1273         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1274         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1275
1276         prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE);
1277         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_start_get",
1278                                        "rna_LayerEngineSettings_Eevee_volumetric_start_set", NULL);
1279         RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect");
1280         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1281         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
1282         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1283         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1284
1285         prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE);
1286         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_end_get",
1287                                        "rna_LayerEngineSettings_Eevee_volumetric_end_set", NULL);
1288         RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect");
1289         RNA_def_property_range(prop, 1e-6f, FLT_MAX);
1290         RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
1291         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1292         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1293
1294         prop = RNA_def_property(srna, "volumetric_tile_size", PROP_ENUM, PROP_NONE);
1295         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_tile_size_get",
1296                                           "rna_LayerEngineSettings_Eevee_volumetric_tile_size_set", NULL);
1297         RNA_def_property_enum_items(prop, eevee_volumetric_tile_size_items);
1298         RNA_def_property_ui_text(prop, "Tile Size", "Control the quality of the volumetric effects "
1299                                                     "(lower size increase vram usage and quality)");
1300         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1301         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1302
1303         prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE);
1304         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_samples_get",
1305                                        "rna_LayerEngineSettings_Eevee_volumetric_samples_set", NULL);
1306         RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects");
1307         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1308         RNA_def_property_range(prop, 1, 256);
1309         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1310
1311         prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR);
1312         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_get",
1313                                        "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_set", NULL);
1314         RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera");
1315         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1316         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1317
1318         prop = RNA_def_property(srna, "volumetric_lights", PROP_BOOLEAN, PROP_NONE);
1319         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_lights_get",
1320                                        "rna_LayerEngineSettings_Eevee_volumetric_lights_set");
1321         RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics");
1322         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1323         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1324
1325         prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE);
1326         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_get",
1327                                        "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_set", NULL);
1328         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1329         RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise");
1330         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1331         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1332
1333         prop = RNA_def_property(srna, "volumetric_shadows", PROP_BOOLEAN, PROP_NONE);
1334         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadows_get",
1335                                        "rna_LayerEngineSettings_Eevee_volumetric_shadows_set");
1336         RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)");
1337         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1338         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1339
1340         prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE);
1341         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_get",
1342                                        "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_set", NULL);
1343         RNA_def_property_range(prop, 1, 128);
1344         RNA_def_property_ui_text(prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing");
1345         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1346         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1347
1348         prop = RNA_def_property(srna, "volumetric_colored_transmittance", PROP_BOOLEAN, PROP_NONE);
1349         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_get",
1350                                        "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_set");
1351         RNA_def_property_ui_text(prop, "Colored Transmittance", "Enable wavelength dependent volumetric transmittance");
1352         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1353         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1354
1355         /* Ambient Occlusion */
1356         prop = RNA_def_property(srna, "gtao_enable", PROP_BOOLEAN, PROP_NONE);
1357         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_enable_get",
1358                                        "rna_LayerEngineSettings_Eevee_gtao_enable_set");
1359         RNA_def_property_ui_text(prop, "Ambient Occlusion", "Enable ambient occlusion to simulate medium scale indirect shadowing");
1360         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1361         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1362
1363         prop = RNA_def_property(srna, "gtao_use_bent_normals", PROP_BOOLEAN, PROP_NONE);
1364         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_get",
1365                                        "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_set");
1366         RNA_def_property_ui_text(prop, "Bent Normals", "Compute main non occluded direction to sample the environment");
1367         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1368         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1369
1370         prop = RNA_def_property(srna, "gtao_denoise", PROP_BOOLEAN, PROP_NONE);
1371         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_denoise_get",
1372                                        "rna_LayerEngineSettings_Eevee_gtao_denoise_set");
1373         RNA_def_property_ui_text(prop, "Denoise", "Use denoising to filter the resulting occlusion and bent normal but exhibit 2x2 pixel blocks");
1374         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1375         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1376
1377         prop = RNA_def_property(srna, "gtao_bounce", PROP_BOOLEAN, PROP_NONE);
1378         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_bounce_get",
1379                                        "rna_LayerEngineSettings_Eevee_gtao_bounce_set");
1380         RNA_def_property_ui_text(prop, "Bounces Approximation", "An approximation to simulate light bounces "
1381                                                                 "giving less occlusion on brighter objects");
1382         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1383         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1384
1385         prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR);
1386         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_factor_get", "rna_LayerEngineSettings_Eevee_gtao_factor_set", NULL);
1387         RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
1388         RNA_def_property_range(prop, 0.0f, FLT_MAX);
1389         RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2);
1390         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1391         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1392
1393         prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR);
1394         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_quality_get", "rna_LayerEngineSettings_Eevee_gtao_quality_set", NULL);
1395         RNA_def_property_ui_text(prop, "Trace Quality", "Quality of the horizon search");
1396         RNA_def_property_range(prop, 0.0f, 1.0f);
1397         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1398         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1399
1400         prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE);
1401         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_distance_get", "rna_LayerEngineSettings_Eevee_gtao_distance_set", NULL);
1402         RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the ambient occlusion effect");
1403         RNA_def_property_range(prop, 0.0f, 100000.0f);
1404         RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1405         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1406         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1407
1408         prop = RNA_def_property(srna, "gtao_samples", PROP_INT, PROP_UNSIGNED);
1409         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_samples_get",
1410                                    "rna_LayerEngineSettings_Eevee_gtao_samples_set", NULL);
1411         RNA_def_property_ui_text(prop, "Samples", "Number of samples to take to compute occlusion");
1412         RNA_def_property_range(prop, 2, 32);
1413         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1414         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1415
1416         /* Depth of Field */
1417         prop = RNA_def_property(srna, "dof_enable", PROP_BOOLEAN, PROP_NONE);
1418         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_dof_enable_get",
1419                                        "rna_LayerEngineSettings_Eevee_dof_enable_set");
1420         RNA_def_property_ui_text(prop, "Depth of Field", "Enable depth of field using the values from the active camera");
1421         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1422         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1423
1424         prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_FACTOR);
1425         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_max_size_get",
1426                                      "rna_LayerEngineSettings_Eevee_bokeh_max_size_set", NULL);
1427         RNA_def_property_ui_text(prop, "Max Size", "Max size of the bokeh shape for the depth of field (lower is faster)");
1428         RNA_def_property_range(prop, 0.0f, 2000.0f);
1429         RNA_def_property_ui_range(prop, 2.0f, 200.0f, 1, 3);
1430         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1431         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1432
1433         prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR);
1434         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_threshold_get",
1435                                      "rna_LayerEngineSettings_Eevee_bokeh_threshold_set", NULL);
1436         RNA_def_property_ui_text(prop, "Sprite Threshold", "Brightness threshold for using sprite base depth of field");
1437         RNA_def_property_range(prop, 0.0f, 100000.0f);
1438         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1439         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1440         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1441
1442         /* Bloom */
1443         prop = RNA_def_property(srna, "bloom_enable", PROP_BOOLEAN, PROP_NONE);
1444         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_enable_get",
1445                                        "rna_LayerEngineSettings_Eevee_bloom_enable_set");
1446         RNA_def_property_ui_text(prop, "Bloom", "High brighness pixels generate a glowing effect");
1447         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1448         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1449
1450         prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR);
1451         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_threshold_get",
1452                                      "rna_LayerEngineSettings_Eevee_bloom_threshold_set", NULL);
1453         RNA_def_property_ui_text(prop, "Threshold", "Filters out pixels under this level of brightness");
1454         RNA_def_property_range(prop, 0.0f, 100000.0f);
1455         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1456         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1457         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1458
1459         prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR);
1460         RNA_def_property_array(prop, 3);
1461         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_color_get",
1462                                      "rna_LayerEngineSettings_Eevee_bloom_color_set", NULL);
1463         RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
1464         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1465         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1466
1467         prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR);
1468         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_knee_get",
1469                                      "rna_LayerEngineSettings_Eevee_bloom_knee_set", NULL);
1470         RNA_def_property_ui_text(prop, "Knee", "Makes transition between under/over-threshold gradual");
1471         RNA_def_property_range(prop, 0.0f, 1.0f);
1472         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1473         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1474
1475         prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR);
1476         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_radius_get",
1477                                      "rna_LayerEngineSettings_Eevee_bloom_radius_set", NULL);
1478         RNA_def_property_ui_text(prop, "Radius", "Bloom spread distance");
1479         RNA_def_property_range(prop, 0.0f, 100.0f);
1480         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1481         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1482         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1483
1484         prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
1485         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_clamp_get",
1486                                      "rna_LayerEngineSettings_Eevee_bloom_clamp_set", NULL);
1487         RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have");
1488         RNA_def_property_range(prop, 0.0f, 1000.0f);
1489         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1490         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1491         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1492
1493         prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED);
1494         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_intensity_get",
1495                                      "rna_LayerEngineSettings_Eevee_bloom_intensity_set", NULL);
1496         RNA_def_property_ui_text(prop, "Intensity", "Blend factor");
1497         RNA_def_property_range(prop, 0.0f, 10000.0f);
1498         RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1499         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1500         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1501
1502         /* Motion blur */
1503         prop = RNA_def_property(srna, "motion_blur_enable", PROP_BOOLEAN, PROP_NONE);
1504         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_enable_get",
1505                                        "rna_LayerEngineSettings_Eevee_motion_blur_enable_set");
1506         RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)");
1507         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1508         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1509
1510         prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED);
1511         RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_samples_get",
1512                                    "rna_LayerEngineSettings_Eevee_motion_blur_samples_set", NULL);
1513         RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur");
1514         RNA_def_property_range(prop, 1, 64);
1515         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1516         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1517
1518         prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
1519         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_shutter_get",
1520                                      "rna_LayerEngineSettings_Eevee_motion_blur_shutter_set", NULL);
1521         RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
1522         RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
1523         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1524         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1525
1526         /* Shadows */
1527         prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
1528         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_method_get", "rna_LayerEngineSettings_Eevee_shadow_method_set", NULL);
1529         RNA_def_property_enum_items(prop, eevee_shadow_method_items);
1530         RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows");
1531         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1532         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1533
1534         prop = RNA_def_property(srna, "shadow_size", PROP_ENUM, PROP_NONE);
1535         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_size_get", "rna_LayerEngineSettings_Eevee_shadow_size_set", NULL);
1536         RNA_def_property_enum_items(prop, eevee_shadow_size_items);
1537         RNA_def_property_ui_text(prop, "Size", "Size of every shadow maps");
1538         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1539         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1540
1541         prop = RNA_def_property(srna, "shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
1542         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_get", "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_set");
1543         RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
1544         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1545         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
1546
1547         RNA_define_verify_sdna(1); /* not in sdna */
1548 }
1549
1550 #ifdef WITH_CLAY_ENGINE
1551 static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
1552 {
1553         StructRNA *srna;
1554         PropertyRNA *prop;
1555
1556         static const EnumPropertyItem clay_matcap_items[] = {
1557             {ICON_MATCAP_01, "01", ICON_MATCAP_01, "", ""},
1558             {ICON_MATCAP_02, "02", ICON_MATCAP_02, "", ""},
1559             {ICON_MATCAP_03, "03", ICON_MATCAP_03, "", ""},
1560             {ICON_MATCAP_04, "04", ICON_MATCAP_04, "", ""},
1561             {ICON_MATCAP_05, "05", ICON_MATCAP_05, "", ""},
1562             {ICON_MATCAP_06, "06", ICON_MATCAP_06, "", ""},
1563             {ICON_MATCAP_07, "07", ICON_MATCAP_07, "", ""},
1564             {ICON_MATCAP_08, "08", ICON_MATCAP_08, "", ""},
1565             {ICON_MATCAP_09, "09", ICON_MATCAP_09, "", ""},
1566             {ICON_MATCAP_10, "10", ICON_MATCAP_10, "", ""},
1567             {ICON_MATCAP_11, "11", ICON_MATCAP_11, "", ""},
1568             {ICON_MATCAP_12, "12", ICON_MATCAP_12, "", ""},
1569             {ICON_MATCAP_13, "13", ICON_MATCAP_13, "", ""},
1570             {ICON_MATCAP_14, "14", ICON_MATCAP_14, "", ""},
1571             {ICON_MATCAP_15, "15", ICON_MATCAP_15, "", ""},
1572             {ICON_MATCAP_16, "16", ICON_MATCAP_16, "", ""},
1573             {ICON_MATCAP_17, "17", ICON_MATCAP_17, "", ""},
1574             {ICON_MATCAP_18, "18", ICON_MATCAP_18, "", ""},
1575             {ICON_MATCAP_19, "19", ICON_MATCAP_19, "", ""},
1576             {ICON_MATCAP_20, "20", ICON_MATCAP_20, "", ""},
1577             {ICON_MATCAP_21, "21", ICON_MATCAP_21, "", ""},
1578             {ICON_MATCAP_22, "22", ICON_MATCAP_22, "", ""},
1579             {ICON_MATCAP_23, "23", ICON_MATCAP_23, "", ""},
1580             {ICON_MATCAP_24, "24", ICON_MATCAP_24, "", ""},
1581             {0, NULL, 0, NULL, NULL}
1582         };
1583
1584         srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsClay", "LayerCollectionSettings");
1585         RNA_def_struct_ui_text(srna, "Collections Clay Engine Settings", "Engine specific settings for this collection");
1586
1587         RNA_define_verify_sdna(0); /* not in sdna */
1588
1589         /* see RNA_LAYER_ENGINE_GET_SET macro */
1590         prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE);
1591         RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_icon_get", "rna_LayerEngineSettings_Clay_matcap_icon_set", NULL);
1592         RNA_def_property_enum_items(prop, clay_matcap_items);
1593         RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture by this material");
1594         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1595         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1596
1597         prop = RNA_def_property(srna, "matcap_rotation", PROP_FLOAT, PROP_FACTOR);
1598         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_rotation_get", "rna_LayerEngineSettings_Clay_matcap_rotation_set", NULL);
1599         RNA_def_property_range(prop, 0.0f, 1.0f);
1600         RNA_def_property_ui_text(prop, "Matcap Rotation", "Orientation of the matcap on the model");
1601         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1602         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1603
1604         prop = RNA_def_property(srna, "matcap_hue", PROP_FLOAT, PROP_FACTOR);
1605         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_hue_get", "rna_LayerEngineSettings_Clay_matcap_hue_set", NULL);
1606         RNA_def_property_range(prop, 0.0f, 1.0f);
1607         RNA_def_property_ui_text(prop, "Matcap Hue Shift", "Hue correction of the matcap");
1608         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1609         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1610
1611         prop = RNA_def_property(srna, "matcap_saturation", PROP_FLOAT, PROP_FACTOR);
1612         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_saturation_get", "rna_LayerEngineSettings_Clay_matcap_saturation_set", NULL);
1613         RNA_def_property_range(prop, 0.0f, 1.0f);
1614         RNA_def_property_ui_text(prop, "Matcap Saturation", "Saturation correction of the matcap");
1615         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1616         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1617
1618         prop = RNA_def_property(srna, "matcap_value", PROP_FLOAT, PROP_FACTOR);
1619         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_value_get", "rna_LayerEngineSettings_Clay_matcap_value_set", NULL);
1620         RNA_def_property_range(prop, 0.0f, 1.0f);
1621         RNA_def_property_ui_text(prop, "Matcap Value", "Value correction of the matcap");
1622         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1623         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1624
1625         prop = RNA_def_property(srna, "ssao_factor_cavity", PROP_FLOAT, PROP_NONE);
1626         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_cavity_get", "rna_LayerEngineSettings_Clay_ssao_factor_cavity_set", NULL);
1627         RNA_def_property_ui_text(prop, "Cavity Strength", "Strength of the Cavity effect");
1628         RNA_def_property_range(prop, 0.0f, 250.0f);
1629         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1630         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1631
1632         prop = RNA_def_property(srna, "ssao_factor_edge", PROP_FLOAT, PROP_NONE);
1633         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_edge_get", "rna_LayerEngineSettings_Clay_ssao_factor_edge_set", NULL);
1634         RNA_def_property_ui_text(prop, "Edge Strength", "Strength of the Edge effect");
1635         RNA_def_property_range(prop, 0.0f, 250.0f);
1636         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1637         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1638
1639         prop = RNA_def_property(srna, "ssao_distance", PROP_FLOAT, PROP_NONE);
1640         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_distance_get", "rna_LayerEngineSettings_Clay_ssao_distance_set", NULL);
1641         RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect");
1642         RNA_def_property_range(prop, 0.0f, 100000.0f);
1643         RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1644         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1645         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1646
1647         prop = RNA_def_property(srna, "ssao_attenuation", PROP_FLOAT, PROP_NONE);
1648         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_attenuation_get", "rna_LayerEngineSettings_Clay_ssao_attenuation_set", NULL);
1649         RNA_def_property_ui_text(prop, "Attenuation", "Attenuation constant");
1650         RNA_def_property_range(prop, 1.0f, 100000.0f);
1651         RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3);
1652         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1653         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1654
1655         prop = RNA_def_property(srna, "hair_brightness_randomness", PROP_FLOAT, PROP_NONE);
1656         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_hair_brightness_randomness_get", "rna_LayerEngineSettings_Clay_hair_brightness_randomness_set", NULL);
1657         RNA_def_property_ui_text(prop, "Hair Brightness Randomness", "Brightness randomness for hair");
1658         RNA_def_property_range(prop, 0.0f, 1.0f);
1659         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1660         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1661
1662         RNA_define_verify_sdna(1); /* not in sdna */
1663 }
1664 #endif /* WITH_CLAY_ENGINE */
1665
1666 static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna)
1667 {
1668         StructRNA *srna;
1669         PropertyRNA *prop;
1670
1671         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsObject", "LayerCollectionSettings");
1672         RNA_def_struct_ui_text(srna, "Collections Object Mode Settings", "Object Mode specific settings for this collection");
1673         RNA_define_verify_sdna(0); /* not in sdna */
1674
1675         /* see RNA_LAYER_ENGINE_GET_SET macro */
1676
1677         prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
1678         RNA_def_property_ui_text(prop, "Wire", "Add the object's wireframe over solid drawing");
1679         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_wire_get", "rna_LayerEngineSettings_ObjectMode_show_wire_set");
1680         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1681         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1682
1683         prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE);
1684         RNA_def_property_ui_text(prop, "Backface Culling", "");
1685         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_backface_culling_get", "rna_LayerEngineSettings_ObjectMode_show_backface_culling_set");
1686         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1687         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1688
1689         RNA_define_verify_sdna(1); /* not in sdna */
1690 }
1691
1692 static void rna_def_layer_collection_mode_settings_edit(BlenderRNA *brna)
1693 {
1694         StructRNA *srna;
1695         PropertyRNA *prop;
1696
1697         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsEdit", "LayerCollectionSettings");
1698         RNA_def_struct_ui_text(srna, "Collections Edit Mode Settings", "Edit Mode specific settings to be overridden per collection");
1699         RNA_define_verify_sdna(0); /* not in sdna */
1700
1701         /* see RNA_LAYER_ENGINE_GET_SET macro */
1702
1703         prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);
1704         RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display");
1705         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_occlude_wire_get", "rna_LayerEngineSettings_EditMode_show_occlude_wire_set");
1706         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1707         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1708
1709         prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE);
1710         RNA_def_property_ui_text(prop, "Show Weights", "Draw weights in editmode");
1711         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_weight_get", "rna_LayerEngineSettings_EditMode_show_weight_set");
1712         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1713         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1714
1715         prop = RNA_def_property(srna, "face_normals_show", PROP_BOOLEAN, PROP_NONE);
1716         RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines");
1717         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_face_normals_show_get", "rna_LayerEngineSettings_EditMode_face_normals_show_set");
1718         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1719         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1720
1721         prop = RNA_def_property(srna, "vert_normals_show", PROP_BOOLEAN, PROP_NONE);
1722         RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");
1723         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_vert_normals_show_get", "rna_LayerEngineSettings_EditMode_vert_normals_show_set");
1724         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1725         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1726
1727         prop = RNA_def_property(srna, "loop_normals_show", PROP_BOOLEAN, PROP_NONE);
1728         RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines");
1729         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_loop_normals_show_get", "rna_LayerEngineSettings_EditMode_loop_normals_show_set");
1730         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1731         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1732
1733         prop = RNA_def_property(srna, "normals_length", PROP_FLOAT, PROP_FACTOR);
1734         RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view");
1735         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_normals_length_get", "rna_LayerEngineSettings_EditMode_normals_length_set", NULL);
1736         RNA_def_property_range(prop, 0.00001, 1000.0);
1737         RNA_def_property_ui_range(prop, 0.01, 10.0, 10.0, 2);
1738         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1739         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1740
1741         prop = RNA_def_property(srna, "backwire_opacity", PROP_FLOAT, PROP_FACTOR);
1742         RNA_def_property_ui_text(prop, "Backwire Opacity", "Opacity when rendering transparent wires");
1743         RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_backwire_opacity_get", "rna_LayerEngineSettings_EditMode_backwire_opacity_set", NULL);
1744         RNA_def_property_range(prop, 0.0f, 1.0f);
1745         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1746         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1747
1748         RNA_define_verify_sdna(1); /* not in sdna */
1749 }
1750
1751 static void rna_def_layer_collection_mode_settings_paint_weight(BlenderRNA *brna)
1752 {
1753         StructRNA *srna;
1754         PropertyRNA *prop;
1755
1756         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintWeight", "LayerCollectionSettings");
1757         RNA_def_struct_ui_text(srna, "Collections Weight Paint Mode Settings", "Weight Paint Mode specific settings to be overridden per collection");
1758         RNA_define_verify_sdna(0); /* not in sdna */
1759
1760         /* see RNA_LAYER_ENGINE_GET_SET macro */
1761
1762         prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE);
1763         RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing");
1764         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_shading_get", "rna_LayerEngineSettings_PaintWeightMode_use_shading_set");
1765         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1766         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1767
1768         prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE);
1769         RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
1770         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_wire_get", "rna_LayerEngineSettings_PaintWeightMode_use_wire_set");
1771         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1772         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
1773
1774         RNA_define_verify_sdna(1); /* not in sdna */
1775 }
1776
1777 static void rna_def_layer_collection_mode_settings_paint_vertex(BlenderRNA *brna)
1778 {
1779         StructRNA *srna;
1780         PropertyRNA *prop;
1781
1782         srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintVertex", "LayerCollectionSettings");
1783         RNA_def_struct_ui_text(srna, "Collections Vertex Paint Mode Settings", "Vertex Paint Mode specific settings to be overridden per collection");
1784         RNA_define_verify_sdna(0); /* not in sdna */
1785
1786         /* see RNA_LAYER_ENGINE_GET_SET macro */
1787
1788         prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE);
1789         RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing");
1790         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_shading_get", "rna_LayerEngineSettings_PaintVertexMode_use_shading_set");
1791         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1792         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
1793
1794         prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE);
1795         RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
1796         RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_wire_get", "rna_LayerEngineSettings_PaintVertexMode_use_wire_set");
1797         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1798         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
1799
1800         RNA_define_verify_sdna(1); /* not in sdna */
1801 }
1802
1803 static void rna_def_scene_layer_settings(BlenderRNA *brna)
1804 {
1805         StructRNA *srna;
1806         PropertyRNA *prop;
1807         FunctionRNA *func;
1808         PropertyRNA *parm;
1809
1810         srna = RNA_def_struct(brna, "SceneLayerSettings", NULL);
1811         RNA_def_struct_sdna(srna, "IDProperty");
1812         RNA_def_struct_ui_text(srna, "Scene Layer Settings",
1813                                "Engine specific settings that can be overriden by SceneLayer");
1814         RNA_def_struct_refine_func(srna, "rna_SceneLayerSettings_refine");
1815
1816         RNA_define_verify_sdna(0);
1817
1818         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1819         RNA_def_property_string_funcs(prop, "rna_SceneLayerSettings_name_get", "rna_SceneLayerSettings_name_length", NULL);
1820         RNA_def_property_ui_text(prop, "Name", "Engine Name");
1821         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1822         RNA_def_struct_name_property(srna, prop);
1823
1824         func = RNA_def_function(srna, "use", "rna_SceneLayerSettings_use");
1825         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1826         RNA_def_function_ui_description(func, "Initialize this property to use");
1827         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set");
1828         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1829
1830         func = RNA_def_function(srna, "unuse", "rna_SceneLayerSettings_unuse");
1831         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1832         RNA_def_function_ui_description(func, "Remove the property");
1833         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset");
1834         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1835
1836 #ifdef WITH_CLAY_ENGINE
1837         rna_def_scene_layer_engine_settings_clay(brna);
1838 #endif
1839         rna_def_scene_layer_engine_settings_eevee(brna);
1840
1841 #if 0
1842         rna_def_scene_layer_mode_settings_object(brna);
1843         rna_def_scene_layer_mode_settings_edit(brna);
1844         rna_def_scene_layer_mode_settings_paint_weight(brna);
1845         rna_def_scene_layer_mode_settings_paint_vertex(brna);
1846 #endif
1847
1848         RNA_define_verify_sdna(1);
1849 }
1850
1851 static void rna_def_layer_collection_settings(BlenderRNA *brna)
1852 {
1853         StructRNA *srna;
1854         PropertyRNA *prop;
1855         FunctionRNA *func;
1856         PropertyRNA *parm;
1857
1858         srna = RNA_def_struct(brna, "LayerCollectionSettings", NULL);
1859         RNA_def_struct_sdna(srna, "IDProperty");
1860         RNA_def_struct_ui_text(srna, "Layer Collection Settings",
1861                                "Engine specific settings that can be overriden by LayerCollection");
1862         RNA_def_struct_refine_func(srna, "rna_LayerCollectionSettings_refine");
1863
1864         RNA_define_verify_sdna(0);
1865
1866         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1867         RNA_def_property_string_funcs(prop, "rna_LayerCollectionSettings_name_get", "rna_LayerCollectionSettings_name_length", NULL);
1868         RNA_def_property_ui_text(prop, "Name", "Engine Name");
1869         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1870         RNA_def_struct_name_property(srna, prop);
1871
1872         func = RNA_def_function(srna, "use", "rna_LayerCollectionSettings_use");
1873         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1874         RNA_def_function_ui_description(func, "Initialize this property to use");
1875         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set");
1876         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1877
1878         func = RNA_def_function(srna, "unuse", "rna_LayerCollectionSettings_unuse");
1879         RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1880         RNA_def_function_ui_description(func, "Remove the property");
1881         parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset");
1882         RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1883
1884 #ifdef WITH_CLAY_ENGINE
1885         rna_def_layer_collection_engine_settings_clay(brna);
1886 #endif
1887
1888         rna_def_layer_collection_mode_settings_object(brna);
1889         rna_def_layer_collection_mode_settings_edit(brna);
1890         rna_def_layer_collection_mode_settings_paint_weight(brna);
1891         rna_def_layer_collection_mode_settings_paint_vertex(brna);
1892
1893         RNA_define_verify_sdna(1);
1894 }
1895
1896 static void rna_def_layer_collection(BlenderRNA *brna)
1897 {
1898         StructRNA *srna;
1899         PropertyRNA *prop;
1900
1901         FunctionRNA *func;
1902         PropertyRNA *parm;
1903
1904         srna = RNA_def_struct(brna, "LayerCollection", NULL);
1905         RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection");
1906
1907         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1908         RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", "rna_LayerCollection_name_set");
1909         RNA_def_property_ui_text(prop, "Name", "Collection name");
1910         RNA_def_struct_name_property(srna, prop);
1911         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
1912
1913         prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
1914         RNA_def_property_flag(prop, PROP_NEVER_NULL);
1915         RNA_def_property_pointer_sdna(prop, NULL, "scene_collection");
1916         RNA_def_property_struct_type(prop, "SceneCollection");
1917         RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
1918
1919         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
1920         RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
1921         RNA_def_property_struct_type(prop, "LayerCollection");
1922         RNA_def_property_ui_text(prop, "Layer Collections", "");
1923
1924         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
1925         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
1926         RNA_def_property_struct_type(prop, "Object");
1927         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_LayerCollection_objects_get", NULL, NULL, NULL, NULL);
1928         RNA_def_property_ui_text(prop, "Objects", "All the objects directly or indirectly added to this collection (not including sub-collection objects)");
1929
1930         prop = RNA_def_property(srna, "overrides", PROP_COLLECTION, PROP_NONE);
1931         RNA_def_property_collection_sdna(prop, NULL, "overrides", NULL);
1932         RNA_def_property_struct_type(prop, "LayerCollectionOverride");
1933         RNA_def_property_ui_text(prop, "Collection Overrides", "");
1934
1935         /* Override settings */
1936         prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE);
1937         RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL);
1938         RNA_def_property_struct_type(prop, "LayerCollectionSettings");
1939         RNA_def_property_ui_text(prop, "Collection Settings", "Override of engine specific render settings");
1940
1941         /* Functions */
1942         func = RNA_def_function(srna, "move_above", "rna_LayerCollection_move_above");
1943         RNA_def_function_ui_description(func, "Move collection after another");
1944         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1945         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection above which the collection will move");
1946         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1947         RNA_def_function_return(func, parm);
1948
1949         func = RNA_def_function(srna, "move_below", "rna_LayerCollection_move_below");
1950         RNA_def_function_ui_description(func, "Move collection before another");
1951         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1952         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection below which the collection will move");
1953         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1954         RNA_def_function_return(func, parm);
1955
1956         func = RNA_def_function(srna, "move_into", "rna_LayerCollection_move_into");
1957         RNA_def_function_ui_description(func, "Move collection into another");
1958         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
1959         parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Collection to insert into");
1960         parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
1961         RNA_def_function_return(func, parm);
1962
1963         func = RNA_def_function(srna, "enable_set", "rna_LayerCollection_enable_set");
1964         RNA_def_function_ui_description(func, "Enable or disable a collection");
1965         parm = RNA_def_boolean(func, "value", 1, "Enable", "");
1966         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1967
1968         /* Flags */
1969         prop = RNA_def_property(srna, "is_enabled", PROP_BOOLEAN, PROP_NONE);
1970         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED);
1971         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1972         RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection from depsgraph");
1973
1974         prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1975         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE);
1976         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1977         RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
1978         RNA_def_property_ui_text(prop, "Hide", "Restrict visiblity");
1979         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
1980
1981         prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
1982         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE);
1983         RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1984         RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
1985         RNA_def_property_ui_text(prop, "Hide Selectable", "Restrict selection");
1986         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
1987
1988         /* TODO_LAYER_OVERRIDE */
1989 }
1990
1991 static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop)
1992 {
1993         StructRNA *srna;
1994         FunctionRNA *func;
1995         PropertyRNA *prop;
1996         PropertyRNA *parm;
1997
1998         RNA_def_property_srna(cprop, "LayerCollections");
1999         srna = RNA_def_struct(brna, "LayerCollections", NULL);
2000         RNA_def_struct_sdna(srna, "SceneLayer");
2001         RNA_def_struct_ui_text(srna, "Layer Collections", "Collections of render layer");
2002
2003         prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2004         RNA_def_property_int_sdna(prop, NULL, "active_collection");
2005         RNA_def_property_int_funcs(prop, "rna_LayerCollections_active_collection_index_get",
2006                                    "rna_LayerCollections_active_collection_index_set",
2007                                    "rna_LayerCollections_active_collection_index_range");
2008         RNA_def_property_ui_text(prop, "Active Collection Index", "Active index in layer collection array");
2009         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2010
2011         prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2012         RNA_def_property_struct_type(prop, "LayerCollection");
2013         RNA_def_property_pointer_funcs(prop, "rna_LayerCollections_active_collection_get",
2014                                        "rna_LayerCollections_active_collection_set", NULL, NULL);
2015         RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
2016         RNA_def_property_ui_text(prop, "Active Layer Collection", "Active Layer Collection");
2017         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2018
2019         func = RNA_def_function(srna, "link", "rna_SceneLayer_collection_link");
2020         RNA_def_function_ui_description(func, "Link a collection to render layer");
2021         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
2022         parm = RNA_def_pointer(func, "scene_collection", "SceneCollection", "", "Collection to add to render layer");
2023         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
2024         parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created layer collection");
2025         RNA_def_function_return(func, parm);
2026
2027         func = RNA_def_function(srna, "unlink", "rna_SceneLayer_collection_unlink");
2028         RNA_def_function_ui_description(func, "Unlink a collection from render layer");
2029         RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
2030         parm = RNA_def_pointer(func, "layer_collection", "LayerCollection", "", "Layer collection to remove from render layer");
2031         RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
2032 }
2033
2034 static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
2035 {
2036         StructRNA *srna;
2037         PropertyRNA *prop;
2038
2039         RNA_def_property_srna(cprop, "LayerObjects");
2040         srna = RNA_def_struct(brna, "LayerObjects", NULL);
2041         RNA_def_struct_sdna(srna, "SceneLayer");
2042         RNA_def_struct_ui_text(srna, "Layer Objects", "Collections of objects");
2043
2044         prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2045         RNA_def_property_struct_type(prop, "Object");
2046         RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", "rna_LayerObjects_active_object_set", NULL, NULL);
2047         RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
2048         RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
2049         /* Could call: ED_base_object_activate(C, rl->basact);
2050          * but would be a bad level call and it seems the notifier is enough */
2051         RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
2052
2053         prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
2054         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
2055         RNA_def_property_struct_type(prop, "Object");
2056         RNA_def_property_collection_funcs(prop, "rna_LayerObjects_selected_begin", "rna_iterator_listbase_next",
2057                                           "rna_iterator_listbase_end", "rna_SceneLayer_objects_get",
2058                                           NULL, NULL, NULL, NULL);
2059         RNA_def_property_ui_text(prop, "Selected Objects", "All the selected objects of this layer");
2060 }
2061
2062 static void rna_def_object_base(BlenderRNA *brna)
2063 {
2064         StructRNA *srna;
2065         PropertyRNA *prop;
2066
2067         srna = RNA_def_struct(brna, "ObjectBase", NULL);
2068         RNA_def_struct_sdna(srna, "Base");
2069         RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a render layer");
2070         RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2071
2072         prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2073         RNA_def_property_pointer_sdna(prop, NULL, "object");
2074         RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2075
2076         prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2077         RNA_def_property_boolean_sdna(prop, NULL, "flag", BASE_SELECTED);
2078         RNA_def_property_ui_text(prop, "Select", "Object base selection state");
2079         RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update");
2080 }
2081
2082 static void rna_def_scene_view_render(BlenderRNA *brna)
2083 {
2084         StructRNA *srna;
2085         PropertyRNA *prop;
2086
2087         static const EnumPropertyItem engine_items[] = {
2088                 {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
2089                 {0, NULL, 0, NULL, NULL}
2090         };
2091
2092         srna = RNA_def_struct(brna, "ViewRenderSettings", NULL);
2093         RNA_def_struct_sdna(srna, "ViewRender");
2094         RNA_def_struct_path_func(srna, "rna_ViewRenderSettings_path");
2095         RNA_def_struct_ui_text(srna, "View Render", "Rendering settings related to viewport drawing/rendering");
2096
2097         /* engine */
2098         prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
2099         RNA_def_property_enum_items(prop, engine_items);
2100         RNA_def_property_enum_funcs(prop, "rna_ViewRenderSettings_engine_get", "rna_ViewRenderSettings_engine_set",
2101                                     "rna_ViewRenderSettings_engine_itemf");
2102         RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2103         RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
2104         RNA_def_property_update(prop, NC_WINDOW, "rna_ViewRenderSettings_engine_update");
2105
2106         prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
2107         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_multiple_engines_get", NULL);
2108         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2109         RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
2110
2111         prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
2112         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_shading_nodes_get", NULL);
2113         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2114         RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system");
2115
2116         prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
2117         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_spherical_stereo_get", NULL);
2118         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2119         RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
2120
2121         prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE);
2122         RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_game_engine_get", NULL);
2123         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2124         RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine");
2125 }
2126
2127 void RNA_def_scene_layer(BlenderRNA *brna)
2128 {
2129         FunctionRNA *func;
2130         StructRNA *srna;
2131         PropertyRNA *prop;
2132
2133         srna = RNA_def_struct(brna, "SceneLayer", NULL);
2134         RNA_def_struct_ui_text(srna, "Render Layer", "Render layer");
2135         RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
2136
2137         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2138         RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneLayer_name_set");
2139         RNA_def_property_ui_text(prop, "Name", "Render layer name");
2140         RNA_def_struct_name_property(srna, prop);
2141         RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
2142
2143         prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
2144         RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
2145         RNA_def_property_struct_type(prop, "LayerCollection");
2146         RNA_def_property_ui_text(prop, "Layer Collections", "");
2147         rna_def_layer_collections(brna, prop);
2148
2149         prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
2150         RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
2151         RNA_def_property_struct_type(prop, "Object");
2152         RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneLayer_objects_get", NULL, NULL, NULL, NULL);
2153         RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer");
2154         rna_def_layer_objects(brna, prop);
2155
2156         /* layer options */
2157         prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
2158         RNA_def_property_boolean_sdna(prop, NULL, "flag", SCENE_LAYER_RENDER);
2159         RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render layer");
2160         RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
2161
2162         /* Override settings */
2163         prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE);
2164         RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL);
2165         RNA_def_property_struct_type(prop, "SceneLayerSettings");
2166         RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings");
2167
2168         /* debug update routine */
2169         func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged");
2170         RNA_def_function_flag(func, FUNC_USE_CONTEXT);
2171         RNA_def_function_ui_description(func,
2172                                         "Update data tagged to be updated from previous access to data or operators");
2173
2174         /* Dependency Graph */
2175         prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
2176         RNA_def_property_struct_type(prop, "Depsgraph");
2177         RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data");
2178         RNA_def_property_pointer_funcs(prop, "rna_SceneLayer_depsgraph_get", NULL, NULL, NULL);
2179
2180         /* Nested Data  */
2181         /* *** Non-Animated *** */
2182         RNA_define_animate_sdna(false);
2183         rna_def_scene_collection(brna);
2184         rna_def_layer_collection(brna);
2185         rna_def_layer_collection_override(brna);
2186         rna_def_object_base(brna);
2187         RNA_define_animate_sdna(true);
2188         /* *** Animated *** */
2189         rna_def_scene_layer_settings(brna);
2190         rna_def_layer_collection_settings(brna);
2191         rna_def_scene_view_render(brna);
2192 }
2193
2194 #endif