Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-30 16:57:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-18 14:34:24 +0300
commit17bd5c9d4b1e9377b896c13043e24eaa7e979714 (patch)
tree60ca4e4118c01d88ccc04919d4f7ed46014875c1 /source/blender/makesrna/intern/rna_layer.c
parent70aec3732d0f03138d6477fd04c81dfd9fd21256 (diff)
Collections and groups unification
OVERVIEW * In 2.7 terminology, all layers and groups are now collection datablocks. * These collections are nestable, linkable, instanceable, overrideable, .. which opens up new ways to set up scenes and link + override data. * Viewport/render visibility and selectability are now a part of the collection and shared across all view layers and linkable. * View layers define which subset of the scene collection hierarchy is excluded for each. For many workflows one view layer can be used, these are more of an advanced feature now. OUTLINER * The outliner now has a "View Layer" display mode instead of "Collections", which can display the collections and/or objects in the view layer. * In this display mode, collections can be excluded with the right click menu. These will then be greyed out and their objects will be excluded. * To view collections not linked to any scene, the "Blender File" display mode can be used, with the new filtering option to just see Colleciton datablocks. * The outliner right click menus for collections and objects were reorganized. * Drag and drop still needs to be improved. Like before, dragging the icon or text gives different results, we'll unify this later. LINKING AND OVERRIDES * Collections can now be linked into the scene without creating an instance, with the link/append operator or from the collections view in the outliner. * Collections can get static overrides with the right click menu in the outliner, but this is rather unreliable and not clearly communicated at the moment. * We still need to improve the make override operator to turn collection instances into collections with overrides directly in the scene. PERFORMANCE * We tried to make performance not worse than before and improve it in some cases. The main thing that's still a bit slower is multiple scenes, we have to change the layer syncing to only updated affected scenes. * Collections keep a list of their parent collections for faster incremental updates in syncing and caching. * View layer bases are now in a object -> base hash to avoid quadratic time lookups internally and in API functions like visible_get(). VERSIONING * Compatibility with 2.7 files should be improved due to the new visibility controls. Of course users may not want to set up their scenes differently now to avoid having separate layers and groups. * Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero files. There's a few things which are know to be not quite compatible, like nested layer collections inside groups. * The versioning code for 2.8 files is quite complicated, and isolated behind #ifdef so it can be removed at the end of the release cycle. KNOWN ISSUES * The G-key group operators in the 3D viewport were left mostly as is, they need to be modified still to fit better. * Same for the groups panel in the object properties. This needs to be updated still, or perhaps replaced by something better. * Collections must all have a unique name. Less restrictive namespacing is to be done later, we'll have to see how important this is as all objects within the collections must also have a unique name anyway. * Full scene copy and delete scene are exactly doing the right thing yet. Differential Revision: https://developer.blender.org/D3383 https://code.blender.org/2018/05/collections-and-groups/
Diffstat (limited to 'source/blender/makesrna/intern/rna_layer.c')
-rw-r--r--source/blender/makesrna/intern/rna_layer.c600
1 files changed, 22 insertions, 578 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index e6e90f4f05d..61bf5ceab8e 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -47,12 +47,6 @@
#include "rna_internal.h"
-const EnumPropertyItem rna_enum_collection_type_items[] = {
- {COLLECTION_TYPE_NONE, "NONE", 0, "Normal", ""},
- {COLLECTION_TYPE_GROUP_INTERNAL, "GROUP_INTERNAL", 0, "Group Internal", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
#ifdef RNA_RUNTIME
#include "DNA_group_types.h"
@@ -69,324 +63,13 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
-static StructRNA *rna_SceneCollection_refine(PointerRNA *ptr)
-{
- SceneCollection *scene_collection = (SceneCollection *)ptr->data;
- switch (scene_collection->type) {
- case COLLECTION_TYPE_GROUP_INTERNAL:
- case COLLECTION_TYPE_NONE:
- return &RNA_SceneCollection;
- default:
- BLI_assert(!"Collection type not fully implemented");
- break;
- }
- return &RNA_SceneCollection;
-}
-
-static void rna_SceneCollection_name_set(PointerRNA *ptr, const char *value)
-{
- Scene *scene = (Scene *)ptr->id.data;
- SceneCollection *sc = (SceneCollection *)ptr->data;
- BKE_collection_rename(&scene->id, sc, value);
-}
-
-static PointerRNA rna_SceneCollection_objects_get(CollectionPropertyIterator *iter)
-{
- ListBaseIterator *internal = &iter->internal.listbase;
-
- /* we are actually iterating a LinkData list */
- return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((LinkData *)internal->link)->data);
-}
-
-static int rna_SceneCollection_move_above(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
-{
- if (!BKE_collection_move_above(id, sc_dst, sc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static int rna_SceneCollection_move_below(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
-{
- if (!BKE_collection_move_below(id, sc_dst, sc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static int rna_SceneCollection_move_into(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst)
-{
- if (!BKE_collection_move_into(id, sc_dst, sc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static SceneCollection *rna_SceneCollection_duplicate(
- ID *id, SceneCollection *scene_collection, Main *bmain, bContext *C, ReportList *reports)
-{
- if (scene_collection == BKE_collection_master(id)) {
- BKE_report(reports, RPT_ERROR, "The master collection can't be duplicated");
- return NULL;
- }
-
- SceneCollection *scene_collection_new = BKE_collection_duplicate(id, scene_collection);
-
- DEG_relations_tag_update(bmain);
- /* Don't use id here, since the layer collection may come from a group. */
- WM_event_add_notifier(C, NC_SCENE | ND_LAYER, CTX_data_scene(C));
-
- return scene_collection_new;
-}
-
-static SceneCollection *rna_SceneCollection_new(
- ID *id, SceneCollection *sc_parent, Main *bmain, const char *name)
-{
- SceneCollection *sc = BKE_collection_add(id, sc_parent, COLLECTION_TYPE_NONE, name);
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return sc;
-}
-
-static void rna_SceneCollection_remove(
- ID *id, SceneCollection *sc_parent, Main *bmain, ReportList *reports, PointerRNA *sc_ptr)
-{
- SceneCollection *sc = sc_ptr->data;
-
- const int index = BLI_findindex(&sc_parent->scene_collections, sc);
- if (index == -1) {
- BKE_reportf(reports, RPT_ERROR, "Collection '%s' is not a sub-collection of '%s'",
- sc->name, sc_parent->name);
- return;
- }
-
- if (!BKE_collection_remove(id, sc)) {
- BKE_reportf(reports, RPT_ERROR, "Collection '%s' could not be removed from collection '%s'",
- sc->name, sc_parent->name);
- return;
- }
-
- RNA_POINTER_INVALIDATE(sc_ptr);
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-}
-
-static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr)
-{
- SceneCollection *sc = (SceneCollection *)ptr->data;
- return sc->active_object_index;
-}
-
-static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int value)
-{
- SceneCollection *sc = (SceneCollection *)ptr->data;
- sc->active_object_index = value;
-}
-
-static void rna_SceneCollection_objects_active_index_range(
- PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
-{
- SceneCollection *sc = (SceneCollection *)ptr->data;
- *min = 0;
- *max = max_ii(0, BLI_listbase_count(&sc->objects) - 1);
-}
-
-void rna_SceneCollection_object_link(
- ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob)
-{
- Scene *scene = (Scene *)id;
-
- if (BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) {
- BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in collection '%s'", ob->id.name + 2, sc->name);
- return;
- }
-
- BKE_collection_object_add(&scene->id, sc, ob);
-
- /* TODO(sergey): Only update relations for the current scene. */
- DEG_relations_tag_update(bmain);
-
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(&scene->id, 0);
-
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
-
- WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
-}
-
-static void rna_SceneCollection_object_unlink(
- ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob)
-{
- Scene *scene = (Scene *)id;
-
- if (!BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) {
- BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in collection '%s'", ob->id.name + 2, sc->name);
- return;
- }
-
- BKE_collection_object_remove(bmain, &scene->id, sc, ob, false);
-
- /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */
- DEG_relations_tag_update(bmain);
-
- WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
-}
-
/***********************************/
-static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value)
-{
- SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
- strcpy(value, sc->name);
-}
-
-static int rna_LayerCollection_name_length(PointerRNA *ptr)
-{
- SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
- return strnlen(sc->name, sizeof(sc->name));
-}
-
-static void rna_LayerCollection_name_set(PointerRNA *ptr, const char *value)
-{
- ID *owner_id = (ID *)ptr->id.data;
- SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
- BKE_collection_rename(owner_id, sc, value);
-}
-
-static PointerRNA rna_LayerCollection_objects_get(CollectionPropertyIterator *iter)
-{
- ListBaseIterator *internal = &iter->internal.listbase;
- Base *base = ((LinkData *)internal->link)->data;
- return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object);
-}
-
-static int rna_LayerCollection_move_above(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
-{
- if (!BKE_layer_collection_move_above(id, lc_dst, lc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static int rna_LayerCollection_move_below(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
-{
- if (!BKE_layer_collection_move_below(id, lc_dst, lc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static int rna_LayerCollection_move_into(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst)
-{
- if (!BKE_layer_collection_move_into(id, lc_dst, lc_src)) {
- return 0;
- }
-
- DEG_relations_tag_update(bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
-
- return 1;
-}
-
-static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *ptr)
-{
- ID *id = ptr->id.data;
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(id, 0);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
-}
-
-static Group *rna_LayerCollection_create_group(
- ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports)
-{
- Group *group;
- Scene *scene = (Scene *)id;
- SceneCollection *scene_collection = layer_collection->scene_collection;
-
- /* The master collection can't be converted. */
- if (scene_collection == BKE_collection_master(&scene->id)) {
- BKE_report(reports, RPT_ERROR, "The master collection can't be converted to group");
- return NULL;
- }
-
- group = BKE_collection_group_create(bmain, scene, layer_collection);
- if (group == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Failed to convert collection %s", scene_collection->name);
- return NULL;
- }
-
- DEG_relations_tag_update(bmain);
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(&scene->id, 0);
- WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
- return group;
-}
-
-static LayerCollection *rna_LayerCollection_duplicate(
- ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports)
-{
- if (layer_collection->scene_collection == BKE_collection_master(id)) {
- BKE_report(reports, RPT_ERROR, "The master collection can't be duplicated");
- return NULL;
- }
-
- LayerCollection *layer_collection_new = BKE_layer_collection_duplicate(id, layer_collection);
-
- DEG_relations_tag_update(bmain);
- /* Don't use id here, since the layer collection may come from a group. */
- WM_event_add_notifier(C, NC_SCENE | ND_LAYER, CTX_data_scene(C));
-
- return layer_collection_new;
-}
-
-static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr)
-{
- ViewLayer *view_layer = (ViewLayer *)ptr->data;
- return view_layer->active_collection;
-}
-
-static void rna_LayerCollections_active_collection_index_set(PointerRNA *ptr, int value)
-{
- ViewLayer *view_layer = (ViewLayer *)ptr->data;
- int num_collections = BKE_layer_collection_count(view_layer);
- view_layer->active_collection = min_ff(value, num_collections - 1);
-}
-
-static void rna_LayerCollections_active_collection_index_range(
- PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
-{
- ViewLayer *view_layer = (ViewLayer *)ptr->data;
- *min = 0;
- *max = max_ii(0, BKE_layer_collection_count(view_layer) - 1);
-}
static PointerRNA rna_LayerCollections_active_collection_get(PointerRNA *ptr)
{
ViewLayer *view_layer = (ViewLayer *)ptr->data;
- LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
+ LayerCollection *lc = view_layer->active_collection;
return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc);
}
@@ -395,40 +78,7 @@ static void rna_LayerCollections_active_collection_set(PointerRNA *ptr, PointerR
ViewLayer *view_layer = (ViewLayer *)ptr->data;
LayerCollection *lc = (LayerCollection *)value.data;
const int index = BKE_layer_collection_findindex(view_layer, lc);
- if (index != -1) view_layer->active_collection = index;
-}
-
-LayerCollection * rna_ViewLayer_collection_link(
- ID *id, ViewLayer *view_layer, Main *bmain, SceneCollection *sc)
-{
- Scene *scene = (Scene *)id;
- LayerCollection *lc = BKE_collection_link(view_layer, sc);
-
- DEG_relations_tag_update(bmain);
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(id, 0);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, scene);
-
- return lc;
-}
-
-static void rna_ViewLayer_collection_unlink(
- ID *id, ViewLayer *view_layer, Main *bmain, ReportList *reports, LayerCollection *lc)
-{
- Scene *scene = (Scene *)id;
-
- if (BLI_findindex(&view_layer->layer_collections, lc) == -1) {
- BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is not in '%s'",
- lc->scene_collection->name, view_layer->name);
- return;
- }
-
- BKE_collection_unlink(view_layer, lc);
-
- DEG_relations_tag_update(bmain);
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(id, 0);
- WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene);
+ if (index != -1) BKE_layer_collection_activate(view_layer, lc);
}
static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
@@ -538,250 +188,59 @@ static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scen
ED_object_base_select(base, mode);
}
-#else
-
-static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop)
+static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
- StructRNA *srna;
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "SceneCollections");
- srna = RNA_def_struct(brna, "SceneCollections", NULL);
- RNA_def_struct_sdna(srna, "SceneCollection");
- RNA_def_struct_ui_text(srna, "Scene Collection", "Collection of scene collections");
-
- func = RNA_def_function(srna, "new", "rna_SceneCollection_new");
- RNA_def_function_ui_description(func, "Add a collection to scene");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_string(func, "name", NULL, 0, "", "New name for the collection (not unique)");
- parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "remove", "rna_SceneCollection_remove");
- RNA_def_function_ui_description(func, "Remove a collection and move its objects to the master collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "collection", "SceneCollection", "", "Collection to remove");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
- RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
-}
+ Scene *scene = (Scene *)ptr->id.data;
+ LayerCollection *lc = (LayerCollection*)ptr->data;
+ ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
-static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- FunctionRNA *func;
- PropertyRNA *parm;
- PropertyRNA *prop;
+ BKE_layer_collection_sync(scene, view_layer);
- RNA_def_property_srna(cprop, "CollectionObjects");
- srna = RNA_def_struct(brna, "CollectionObjects", NULL);
- RNA_def_struct_sdna(srna, "SceneCollection");
- RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection");
-
- prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get",
- "rna_SceneCollection_objects_active_index_set",
- "rna_SceneCollection_objects_active_index_range");
- RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
-
- func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link");
- RNA_def_function_ui_description(func, "Link an object to collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to collection");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
- func = RNA_def_function(srna, "unlink", "rna_SceneCollection_object_unlink");
- RNA_def_function_ui_description(func, "Unlink object from collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from collection");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ /* TODO(sergey): Use proper flag for tagging here. */
+ DEG_id_tag_update(&scene->id, 0);
+ DEG_relations_tag_update(bmain);
+ WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
}
-static void rna_def_scene_collection(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- srna = RNA_def_struct(brna, "SceneCollection", NULL);
- RNA_def_struct_ui_text(srna, "Scene Collection", "Collection");
- RNA_def_struct_ui_icon(srna, ICON_COLLAPSEMENU);
- RNA_def_struct_refine_func(srna, "rna_SceneCollection_refine");
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_name_set");
- RNA_def_property_ui_text(prop, "Name", "Collection name");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, rna_enum_collection_type_items);
- RNA_def_property_ui_text(prop, "Type", "Type of collection");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "scene_collections", NULL);
- RNA_def_property_struct_type(prop, "SceneCollection");
- RNA_def_property_ui_text(prop, "SceneCollections", "");
- rna_def_scene_collections(brna, prop);
-
- prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "objects", NULL);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Objects", "All the objects directly added to this collection (not including sub-collection objects)");
- rna_def_collection_objects(brna, prop);
-
- /* Functions */
- func = RNA_def_function(srna, "move_above", "rna_SceneCollection_move_above");
- RNA_def_function_ui_description(func, "Move collection after another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection above which the collection will move");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "move_below", "rna_SceneCollection_move_below");
- RNA_def_function_ui_description(func, "Move collection before another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection below which the collection will move");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "move_into", "rna_SceneCollection_move_into");
- RNA_def_function_ui_description(func, "Move collection into another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Collection to insert into");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "duplicate", "rna_SceneCollection_duplicate");
- RNA_def_function_ui_description(func, "Create a copy of the collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
- RNA_def_function_return(func, parm);
-}
+#else
static void rna_def_layer_collection(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- FunctionRNA *func;
- PropertyRNA *parm;
-
srna = RNA_def_struct(brna, "LayerCollection", NULL);
RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection");
- RNA_def_struct_ui_icon(srna, ICON_COLLAPSEMENU);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", "rna_LayerCollection_name_set");
- RNA_def_property_ui_text(prop, "Name", "Collection name");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+ RNA_def_struct_ui_icon(srna, ICON_GROUP);
prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "scene_collection");
- RNA_def_property_struct_type(prop, "SceneCollection");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
+ RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping");
- prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE);
+ prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
RNA_def_property_struct_type(prop, "LayerCollection");
- RNA_def_property_ui_text(prop, "Layer Collections", "");
+ RNA_def_property_ui_text(prop, "Children", "Child layer collections");
- prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_LayerCollection_objects_get", NULL, NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Objects", "All the objects directly or indirectly added to this collection (not including sub-collection objects)");
-
- /* Functions */
- func = RNA_def_function(srna, "move_above", "rna_LayerCollection_move_above");
- RNA_def_function_ui_description(func, "Move collection after another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection above which the collection will move");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "move_below", "rna_LayerCollection_move_below");
- RNA_def_function_ui_description(func, "Move collection before another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection below which the collection will move");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "move_into", "rna_LayerCollection_move_into");
- RNA_def_function_ui_description(func, "Move collection into another");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Collection to insert into");
- parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "create_group", "rna_LayerCollection_create_group");
- RNA_def_function_ui_description(func, "Enable or disable a collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "result", "Group", "", "Newly created Group");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "duplicate", "rna_LayerCollection_duplicate");
- RNA_def_function_ui_description(func, "Create a copy of the collection");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created collection");
- RNA_def_function_return(func, parm);
-
- /* Flags */
- prop = RNA_def_property(srna, "selectable", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
- RNA_def_property_ui_text(prop, "Selectable", "Restrict selection");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
-
- prop = RNA_def_property(srna, "visible_viewport", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_VIEWPORT);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
- RNA_def_property_ui_text(prop, "Viewport Visibility", "");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
-
- prop = RNA_def_property(srna, "visible_render", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RENDER);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- RNA_def_property_ui_text(prop, "Render Visibility", "Control");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
-
- prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED);
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
+ prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_EXCLUDE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Exclude", "Exclude collection from view layer");
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_use_update");
}
static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- FunctionRNA *func;
PropertyRNA *prop;
- PropertyRNA *parm;
RNA_def_property_srna(cprop, "LayerCollections");
srna = RNA_def_struct(brna, "LayerCollections", NULL);
RNA_def_struct_sdna(srna, "ViewLayer");
RNA_def_struct_ui_text(srna, "Layer Collections", "Collections of render layer");
- prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "active_collection");
- RNA_def_property_int_funcs(prop, "rna_LayerCollections_active_collection_index_get",
- "rna_LayerCollections_active_collection_index_set",
- "rna_LayerCollections_active_collection_index_range");
- RNA_def_property_ui_text(prop, "Active Collection Index", "Active index in layer collection array");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
-
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "LayerCollection");
RNA_def_property_pointer_funcs(prop, "rna_LayerCollections_active_collection_get",
@@ -789,20 +248,6 @@ static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Active Layer Collection", "Active Layer Collection");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL);
-
- func = RNA_def_function(srna, "link", "rna_ViewLayer_collection_link");
- RNA_def_function_ui_description(func, "Link a collection to render layer");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
- parm = RNA_def_pointer(func, "scene_collection", "SceneCollection", "", "Collection to add to render layer");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created layer collection");
- RNA_def_function_return(func, parm);
-
- func = RNA_def_function(srna, "unlink", "rna_ViewLayer_collection_unlink");
- RNA_def_function_ui_description(func, "Unlink a collection from render layer");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "layer_collection", "LayerCollection", "", "Layer collection to remove from render layer");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
}
static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
@@ -919,7 +364,6 @@ void RNA_def_view_layer(BlenderRNA *brna)
/* Nested Data */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
- rna_def_scene_collection(brna);
rna_def_layer_collection(brna);
rna_def_object_base(brna);
RNA_define_animate_sdna(true);