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