Commit: 5e968a996a5397a14d00c49e67c74b993859a1d6
Author: Brecht Van Lommel
Date:   Mon Jun 18 19:18:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB5e968a996a5397a14d00c49e67c74b993859a1d6

Objects: restore per object restrict view/render/select.

Note this is now separate from H key hiding, and meant for more persistent
ways to define which objects are relevant to the viewport or render.

This avoids some cases where you'd have to create collection specifically
to hide objects for viewport/render.

===================================================================

M       source/blender/blenkernel/intern/collection.c
M       source/blender/blenkernel/intern/layer.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M       source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M       source/blender/editors/space_outliner/outliner_draw.c
M       source/blender/makesrna/intern/rna_group.c
M       source/blender/makesrna/intern/rna_object.c

===================================================================

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index dfb43812b49..eef4a6210c8 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -309,15 +309,21 @@ static void collection_object_cache_fill(ListBase *lb, 
Collection *collection, i
                if (base == NULL) {
                        base = MEM_callocN(sizeof(Base), "Object Base");
                        base->object = cob->ob;
+                       BLI_addtail(lb, base);
+               }
 
-                       if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) {
-                               base->flag |= BASE_VISIBLE_VIEWPORT;
-                       }
-                       if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) 
{
-                               base->flag |= BASE_VISIBLE_RENDER;
-                       }
+               int object_restrict = base->object->restrictflag;
 
-                       BLI_addtail(lb, base);
+               if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) &&
+                   ((object_restrict & OB_RESTRICT_VIEW) == 0))
+               {
+                       base->flag |= BASE_VISIBLE_VIEWPORT;
+               }
+
+               if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) &&
+                   ((object_restrict & OB_RESTRICT_RENDER) == 0))
+               {
+                       base->flag |= BASE_VISIBLE_RENDER;
                }
        }
 
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index 090be7e0fe5..84915e628df 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -647,14 +647,24 @@ static void layer_collection_sync(
                                BLI_ghash_insert(view_layer->object_bases_hash, 
base->object, base);
                        }
 
-                       if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) {
+                       int object_restrict = base->object->restrictflag;
+
+                       if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) 
&&
+                               ((object_restrict & OB_RESTRICT_VIEW) == 0))
+                       {
                                base->flag |= BASE_VISIBLED | 
BASE_VISIBLE_VIEWPORT;
 
-                               if ((child_restrict & 
COLLECTION_RESTRICT_SELECT) == 0) {
+                               if (((child_restrict & 
COLLECTION_RESTRICT_SELECT) == 0) &&
+                                   ((object_restrict & OB_RESTRICT_SELECT) == 
0))
+                               {
                                        base->flag |= BASE_SELECTABLED;
                                }
                        }
-                       if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) 
{
+
+                       if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 
0) &&
+                           ((object_restrict & OB_RESTRICT_RENDER) == 0))
+
+                       {
                                base->flag |= BASE_VISIBLE_RENDER;
                        }
 
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 74ff53a45d9..190b9d86d59 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -355,13 +355,6 @@ static void do_version_scene_collection_to_collection(Main 
*bmain, Scene *scene)
 #endif
 
 
-enum {
-       DO_VERSION_COLLECTION_VISIBLE     = 0,
-       DO_VERSION_COLLECTION_HIDE        = 1,
-       DO_VERSION_COLLECTION_HIDE_RENDER = 2,
-       DO_VERSION_COLLECTION_HIDE_ALL    = 3,
-};
-
 static void do_version_layers_to_collections(Main *bmain, Scene *scene)
 {
        /* Since we don't have access to FileData we check the (always valid) 
first
@@ -376,99 +369,26 @@ static void do_version_layers_to_collections(Main *bmain, 
Scene *scene)
 
        /* Create collections from layers. */
        Collection *collection_master = BKE_collection_master(scene);
-
-       struct DoVersionSceneCollections {
-               Collection *collections[20];
-               int created;
-               const char *suffix;
-               int flag;
-       } collections[] =
-       {
-               {
-                       .collections = {NULL},
-                       .created = 0,
-                       .suffix = "",
-                       .flag = 0,
-               },
-               {
-                       .collections = {NULL},
-                       .created = 0,
-                       .suffix = " - Hide Viewport",
-                       .flag = COLLECTION_RESTRICT_VIEW,
-               },
-               {
-                       .collections = {NULL},
-                       .created = 0,
-                       .suffix = " - Hide Render",
-                       .flag = COLLECTION_RESTRICT_RENDER,
-               },
-               {
-                       .collections = {NULL},
-                       .created = 0,
-                       .suffix = " - Hide Render All",
-                       .flag = COLLECTION_RESTRICT_VIEW | 
COLLECTION_RESTRICT_RENDER,
-               }
-       };
+       Collection *collections[20] = {NULL};
 
        for (int layer = 0; layer < 20; layer++) {
                for (Base *base = scene->base.first; base; base = base->next) {
                        if (base->lay & (1 << layer)) {
-                               int collection_index = -1;
-                               if ((base->object->restrictflag & 
OB_RESTRICT_VIEW) &&
-                                   (base->object->restrictflag & 
OB_RESTRICT_RENDER))
-                               {
-                                       collection_index = 
DO_VERSION_COLLECTION_HIDE_ALL;
-                               }
-                               else if (base->object->restrictflag & 
OB_RESTRICT_VIEW) {
-                                       collection_index = 
DO_VERSION_COLLECTION_HIDE;
-                               }
-                               else if (base->object->restrictflag & 
OB_RESTRICT_RENDER) {
-                                       collection_index = 
DO_VERSION_COLLECTION_HIDE_RENDER;
-                               }
-                               else {
-                                       collection_index = 
DO_VERSION_COLLECTION_VISIBLE;
-                               }
-
                                /* Create collections when needed only. */
-                               if ((collections[collection_index].created & (1 
<< layer)) == 0) {
+                               if (collections[layer] == NULL) {
                                        char name[MAX_NAME];
 
-                                       if 
((collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) == 0) {
-                                               BLI_snprintf(name,
-                                                            
sizeof(collection_master->id.name),
-                                                            "Collection %d%s",
-                                                            layer + 1,
-                                                            
collections[DO_VERSION_COLLECTION_VISIBLE].suffix);
-
-                                               Collection *collection = 
BKE_collection_add(bmain, collection_master, name);
-                                               collection->id.lib = 
scene->id.lib;
-                                               collection->flag |= 
collections[DO_VERSION_COLLECTION_VISIBLE].flag;
-                                               
collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = collection;
-                                               
collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer);
-
-                                               if (!(scene->lay & (1 << 
layer))) {
-                                                       collection->flag |= 
COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
-                                               }
-                                       }
+                                       BLI_snprintf(name,
+                                                    
sizeof(collection_master->id.name),
+                                                    "Collection %d",
+                                                    layer + 1);
 
-                                       if (collection_index != 
DO_VERSION_COLLECTION_VISIBLE) {
-                                               Collection *collection_parent;
-                                               collection_parent = 
collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer];
-                                               BLI_snprintf(name,
-                                                            
sizeof(collection_master->id.name),
-                                                            "Collection %d%s",
-                                                            layer + 1,
-                                                            
collections[collection_index].suffix);
-
-                                               Collection *collection = 
BKE_collection_add(bmain, collection_parent, name);
-                                               collection->id.lib = 
scene->id.lib;
-                                               collection->flag |= 
collections[collection_index].flag;
-                                               
collections[collection_index].collections[layer] = collection;
-                                               
collections[collection_index].created |= (1 << layer);
-
-                                               if (!(scene->lay & (1 << 
layer))) {
-                                                       collection->flag |= 
COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
-                                               }
+                                       Collection *collection = 
BKE_collection_add(bmain, collection_master, name);
+                                       collection->id.lib = scene->id.lib;
+                                       collections[layer] = collection;
+
+                                       if (!(scene->lay & (1 << layer))) {
+                                               collection->flag |= 
COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
                                        }
                                }
 
@@ -476,7 +396,7 @@ static void do_version_layers_to_collections(Main *bmain, 
Scene *scene)
                                 * but since no view layers exists yet at this 
point it's fast. */
                                BKE_collection_object_add(
                                        bmain,
-                                       
collections[collection_index].collections[layer], base->object);
+                                       collections[layer], base->object);
                        }
 
                        if (base->flag & SELECT) {
@@ -488,46 +408,6 @@ static void do_version_layers_to_collections(Main *bmain, 
Scene *scene)
                }
        }
 
-       /* Re-order the nested hidden collections. */
-       CollectionChild *child_parent = collection_master->children.first;
-       Collection *collection_parent = (child_parent) ? 
child_parent->collection : NULL;
-
-       for (int layer = 0; layer < 20; layer++) {
-               if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << 
layer)) {
-                       CollectionChild *hide_child = BLI_findptr(
-                               &collection_parent->children,
-                               
collections[DO_VERSION_COLLECTION_HIDE].collections[layer],
-                               offsetof(CollectionChild, collection));
-
-                       if ((collections[DO_VERSION_COLLECTION_HIDE].created & 
(1 << layer)) &&
-                           (hide_child != collection_parent->children.first))
-                       {
-                               BLI_listbase_swaplinks(
-                                       &collection_parent->children,
-                                       hide_child,
-                                       collection_parent->children.first);
-                       }
-
-                       CollectionChild *hide_all_child = BLI_findptr(
-                               &collection_parent->children,
-                               
collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer],
-                               offsetof(CollectionChild, collection));
-
-                       if 
((collections[DO_VERSION_COLLECTION_HIDE_ALL].created & (1 << layer)) &&
-                           (hide_all_child != 
collection_parent->children.last))
-                       {
-                               BLI_listbase_swaplinks(
-                                       &collection_parent->children,
-                                       hide_all_child,
-                                       collection_parent->children.last);
-                       }
-
-                       child_parent = child_parent->next;
-                       collection_parent = (child_parent) ? 
child_parent->collection : NULL;
-               }
-       }
-       BLI_assert(collection_parent == NULL);
-
        /* Handle legacy render layers. */
        bool have_override = false;
 
@@ -577,8 +457,8 @@ static void do_version_layers_to_collections(Main *bmain, 
Scene *scene)
 
                /* Set exclusion and overrides. */
                for (int layer = 0; layer < 20; layer++) {
-                       if (collections[DO_VERSION_COLLECTION_VISIBLE].created 
& (1 << layer)) {
-                               Collection *collection = 
collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer];
+                       Collection *collection = collections[layer];
+                       if (collection) {
                                LayerCollection *lc = 
BKE_layer_collection_first_from_scene_collection(view_layer, collection);
 
                                if (srl->lay_exclude & (1 << layer)) {
@@ -612,14 +492,6 @@ static void do_version_layers_to_collections(Main *bmain, 
Scene *scene)
                                                        false);
                                        }
                                }
-
-                               LayerCollection *nlc = 
lc->layer_collections.first;
-                               for (int j = 1; j < 4; j++) {
-                                       if (collections[j].created & (1 << 
layer)) {
-                                               nlc = nlc->next;
-                                       }
-                               }
-                               BLI_assert(nlc == NULL);
                        }
                }
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index d4a115cfb8b..9b0c3354c47 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -458,6 +458,14 @@ 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to