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