Group collection viewport/render options and remove collection visibility
authorDalai Felinto <dfelinto@gmail.com>
Thu, 14 Dec 2017 13:46:49 +0000 (11:46 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 15 Dec 2017 10:56:48 +0000 (08:56 -0200)
Users can change the group collection visibility in the outliner
when looking at groups.

Regular collections on the other hand don't have any special visibility control,
if you need a collection to be invisible during render, either don't link it
into the view layer used for F12, or disable it.

This includes:
* Updated unittests - update your lib/tests/layers folder.
* Subversion bump - branches be aware of that.

Note:
Although we are using eval_ctx to determine the visibility of a group collection
when rendering, the depsgraph is still using the same depsgraph for the viewport
and the render engine, so at the moment the render visibility is ignored.

Following next is a workaround for this separately to tag the groups before and
after rendering to tackle that.

38 files changed:
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenkernel/BKE_layer.h
source/blender/blenkernel/intern/layer.c
source/blender/blenloader/intern/versioning_280.c
source/blender/depsgraph/DEG_depsgraph_query.h
source/blender/draw/engines/eevee/eevee_engine.c
source/blender/draw/engines/eevee/eevee_lightprobes.c
source/blender/draw/intern/draw_manager.c
source/blender/draw/modes/object_mode.c
source/blender/editors/render/render_preview.c
source/blender/editors/space_outliner/outliner_collections.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/makesdna/DNA_layer_types.h
source/blender/makesrna/intern/rna_layer.c
source/blender/makesrna/intern/rna_object.c
tests/python/view_layer/test_evaluation_selectability_a.py
tests/python/view_layer/test_evaluation_selectability_b.py
tests/python/view_layer/test_evaluation_selectability_c.py
tests/python/view_layer/test_evaluation_selectability_d.py
tests/python/view_layer/test_evaluation_selectability_e.py
tests/python/view_layer/test_evaluation_selectability_f.py
tests/python/view_layer/test_evaluation_visibility_a.py
tests/python/view_layer/test_evaluation_visibility_b.py
tests/python/view_layer/test_evaluation_visibility_c.py
tests/python/view_layer/test_evaluation_visibility_d.py
tests/python/view_layer/test_evaluation_visibility_e.py
tests/python/view_layer/test_evaluation_visibility_f.py
tests/python/view_layer/test_group_b.py
tests/python/view_layer/test_move_above_below_layer_collection_f.py
tests/python/view_layer/test_move_above_below_layer_collection_g.py
tests/python/view_layer/test_move_above_below_layer_collection_h.py
tests/python/view_layer/test_move_above_below_layer_collection_i.py
tests/python/view_layer/test_move_above_below_layer_collection_j.py
tests/python/view_layer/test_move_into_layer_collection_f.py
tests/python/view_layer/test_move_into_layer_collection_g.py
tests/python/view_layer/test_move_into_layer_collection_h.py
tests/python/view_layer/test_scene_copy_f.py

index 8d326c6441c68175aace16bb105c2a9b0f494fa0..27223afe4ff11dcd75c1c61da80d5058f7e68aeb 100644 (file)
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      2
+#define BLENDER_SUBVERSION      3
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   6
index e4f8b8790f6fa2157581a0b3f44035e2f307a8ba..6a762c9b71125caa1b5fee589071b1e53c929ddf 100644 (file)
@@ -102,7 +102,6 @@ struct LayerCollection *BKE_collection_link(struct ViewLayer *view_layer, struct
 void BKE_collection_unlink(struct ViewLayer *view_layer, struct LayerCollection *lc);
 
 void BKE_collection_enable(struct ViewLayer *view_layer, struct LayerCollection *lc);
-void BKE_collection_disable(struct ViewLayer *view_layer, struct LayerCollection *lc);
 
 bool BKE_view_layer_has_collection(struct ViewLayer *view_layer, const struct SceneCollection *sc);
 bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
index 84eb4ee2e333774917e84521b4b1074575d3a3ec..2e6cd769db88b3ebaccd5b5f55fcdd302121224f 100644 (file)
@@ -42,6 +42,8 @@
 #include "BKE_node.h"
 #include "BKE_workspace.h"
 
+#include "DEG_depsgraph.h"
+
 #include "DNA_group_types.h"
 #include "DNA_ID.h"
 #include "DNA_layer_types.h"
@@ -1018,7 +1020,8 @@ static void layer_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
 /**
  * Enable collection
  * Add its objects bases to ViewLayer
- * Depsgraph needs to be rebuilt afterwards
+ *
+ * Only around for doversion.
  */
 void BKE_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
 {
@@ -1030,33 +1033,6 @@ void BKE_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
        layer_collection_enable(view_layer, lc);
 }
 
-/**
- * Recursively disable nested collections
- */
-static void layer_collection_disable(ViewLayer *view_layer, LayerCollection *lc)
-{
-       layer_collection_objects_unpopulate(view_layer, lc);
-
-       for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
-               layer_collection_disable(view_layer, nlc);
-       }
-}
-
-/**
- * Disable collection
- * Remove all its object bases from ViewLayer
- * Depsgraph needs to be rebuilt afterwards
- */
-void BKE_collection_disable(ViewLayer *view_layer, LayerCollection *lc)
-{
-       if ((lc->flag & COLLECTION_DISABLED) != 0) {
-               return;
-       }
-
-       lc->flag |= COLLECTION_DISABLED;
-       layer_collection_disable(view_layer, lc);
-}
-
 static void layer_collection_object_add(ViewLayer *view_layer, LayerCollection *lc, Object *ob)
 {
        Base *base = object_base_add(view_layer, ob);
@@ -1068,7 +1044,7 @@ static void layer_collection_object_add(ViewLayer *view_layer, LayerCollection *
                return;
        }
 
-       bool is_visible = (lc->flag & COLLECTION_VISIBLE) != 0;
+       bool is_visible = ((lc->flag & COLLECTION_VIEWPORT) != 0) && ((lc->flag & COLLECTION_DISABLED) == 0);
        bool is_selectable = is_visible && ((lc->flag & COLLECTION_SELECTABLE) != 0);
 
        if (is_visible) {
@@ -1117,7 +1093,7 @@ static LayerCollection *layer_collection_add(ViewLayer *view_layer, LayerCollect
        LayerCollection *lc = MEM_callocN(sizeof(LayerCollection), "Collection Base");
 
        lc->scene_collection = sc;
-       lc->flag = COLLECTION_VISIBLE | COLLECTION_SELECTABLE;
+       lc->flag = COLLECTION_SELECTABLE | COLLECTION_VIEWPORT | COLLECTION_RENDER;
 
        lc->properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
        collection_engine_settings_init(lc->properties, false);
@@ -2118,7 +2094,21 @@ static const char *collection_type_lookup[] =
     "Group Internal", /* COLLECTION_TYPE_GROUP_INTERNAL */
 };
 
-void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval_ctx),
+static bool layer_collection_visible_get(const EvaluationContext *eval_ctx, LayerCollection *layer_collection)
+{
+       bool is_visible = (layer_collection->flag & COLLECTION_DISABLED) == 0;
+
+       if (eval_ctx->mode == DAG_EVAL_VIEWPORT) {
+               is_visible &= (layer_collection->flag & COLLECTION_VIEWPORT) != 0;
+       }
+       else {
+               is_visible &= (layer_collection->flag & COLLECTION_RENDER) != 0;
+       }
+
+       return is_visible;
+}
+
+void BKE_layer_eval_layer_collection(const EvaluationContext *eval_ctx,
                                      LayerCollection *layer_collection,
                                      LayerCollection *parent_layer_collection)
 {
@@ -2134,11 +2124,11 @@ void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval
 
        /* visibility */
        layer_collection->flag_evaluated = layer_collection->flag;
-       bool is_visible = (layer_collection->flag & COLLECTION_VISIBLE) != 0;
+       bool is_visible = layer_collection_visible_get(eval_ctx, layer_collection);
        bool is_selectable = is_visible && ((layer_collection->flag & COLLECTION_SELECTABLE) != 0);
 
        if (parent_layer_collection != NULL) {
-               is_visible &= (parent_layer_collection->flag_evaluated & COLLECTION_VISIBLE) != 0;
+               is_visible &= layer_collection_visible_get(eval_ctx, parent_layer_collection);
                is_selectable &= (parent_layer_collection->flag_evaluated & COLLECTION_SELECTABLE) != 0;
                layer_collection->flag_evaluated &= parent_layer_collection->flag_evaluated;
        }
index 163df9987bb5633ec482aa0d19b2f4d4d7c9f183..cfe7ffe87a2d05c56e12951ab229d6dde85522a5 100644 (file)
@@ -189,21 +189,21 @@ void do_versions_after_linking_280(Main *main)
                                                .collections = {NULL},
                                                .created = 0,
                                                .suffix = "",
-                                               .flag_viewport = COLLECTION_VISIBLE | COLLECTION_SELECTABLE,
-                                               .flag_render = COLLECTION_VISIBLE | COLLECTION_SELECTABLE
+                                               .flag_viewport = COLLECTION_SELECTABLE,
+                                               .flag_render = COLLECTION_SELECTABLE
                                        },
                                        {
                                                .collections = {NULL},
                                                .created = 0,
                                                .suffix = " - Hide Viewport",
                                                .flag_viewport = COLLECTION_SELECTABLE,
-                                               .flag_render = COLLECTION_VISIBLE | COLLECTION_SELECTABLE
+                                               .flag_render = COLLECTION_SELECTABLE
                                        },
                                        {
                                                .collections = {NULL},
                                                .created = 0,
                                                .suffix = " - Hide Render",
-                                               .flag_viewport = COLLECTION_VISIBLE | COLLECTION_SELECTABLE,
+                                               .flag_viewport = COLLECTION_SELECTABLE,
                                                .flag_render = COLLECTION_SELECTABLE | COLLECTION_DISABLED
                                        },
                                        {
@@ -391,13 +391,9 @@ void do_versions_after_linking_280(Main *main)
 
                                                                        for (int j = 1; j < 4; j++) {
                                                                                if (collections[j].created & (1 << layer)) {
-                                                                                       layer_collection_child->flag =
-                                                                                               collections[j].flag_render & (~COLLECTION_DISABLED);
-
-                                                                                       if (collections[j].flag_render & COLLECTION_DISABLED) {
-                                                                                               BKE_collection_disable(view_layer, layer_collection_child);
-                                                                                       }
-
+                                                                                       layer_collection_child->flag = COLLECTION_VIEWPORT |
+                                                                                                                      COLLECTION_RENDER |
+                                                                                                                      collections[j].flag_render;
                                                                                        layer_collection_child = layer_collection_child->next;
                                                                                }
                                                                        }
@@ -450,7 +446,7 @@ void do_versions_after_linking_280(Main *main)
 
                                                /* We only need to disable the parent collection. */
                                                if (is_disabled) {
-                                                       BKE_collection_disable(view_layer, layer_collection_parent);
+                                                       layer_collection_parent->flag |= COLLECTION_DISABLED;
                                                }
 
                                                LayerCollection *layer_collection_child;
@@ -458,11 +454,9 @@ void do_versions_after_linking_280(Main *main)
 
                                                for (int j = 1; j < 4; j++) {
                                                        if (collections[j].created & (1 << layer)) {
-                                                               layer_collection_child->flag = collections[j].flag_viewport & (~COLLECTION_DISABLED);
-
-                                                               if (collections[j].flag_viewport & COLLECTION_DISABLED) {
-                                                                       BKE_collection_disable(view_layer, layer_collection_child);
-                                                               }
+                                                               layer_collection_child->flag = COLLECTION_VIEWPORT |
+                                                                                              COLLECTION_RENDER |
+                                                                                              collections[j].flag_viewport;
                                                                layer_collection_child = layer_collection_child->next;
                                                        }
                                                }
@@ -594,11 +588,9 @@ void do_versions_after_linking_280(Main *main)
 
                                if (sc_hidden != NULL) {
                                        LayerCollection *layer_collection_master, *layer_collection_hidden;
-
                                        layer_collection_master = group->view_layer->layer_collections.first;
                                        layer_collection_hidden = layer_collection_master->layer_collections.first;
-
-                                       layer_collection_hidden->flag &= ~COLLECTION_VISIBLE;
+                                       layer_collection_hidden->flag |= COLLECTION_DISABLED;
                                }
                        }
 
@@ -629,6 +621,25 @@ static void do_version_layer_collections_idproperties(ListBase *lb)
        }
 }
 
+static void do_version_view_layer_visibility(ViewLayer *view_layer)
+{
+       LayerCollection *layer_collection;
+       for (layer_collection = view_layer->layer_collections.first;
+            layer_collection;
+            layer_collection = layer_collection->next)
+       {
+               if (layer_collection->flag & COLLECTION_DISABLED) {
+                       BKE_collection_enable(view_layer, layer_collection);
+                       layer_collection->flag &= ~COLLECTION_DISABLED;
+               }
+
+               if ((layer_collection->flag & (1 << 0)) == 0) { /* !COLLECTION_VISIBLE */
+                       layer_collection->flag |= COLLECTION_DISABLED;
+               }
+               layer_collection->flag |= COLLECTION_VIEWPORT | COLLECTION_RENDER;
+       }
+}
+
 void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 {
 
@@ -827,4 +838,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                }
        }
+
+       if (!MAIN_VERSION_ATLEAST(main, 280, 3)) {
+               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       ViewLayer *view_layer;
+                       for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+                               do_version_view_layer_visibility(view_layer);
+                       }
+               }
+
+               for (Group *group = main->group.first; group; group = group->id.next) {
+                       if (group->view_layer != NULL){
+                               do_version_view_layer_visibility(group->view_layer);
+                       }
+               }
+       }
 }
index 7771d35d58110315c469096ea81a7bed29ceeca4..bd60428953456e1568709c11a46a2a6cf97860a1 100644 (file)
@@ -111,7 +111,7 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
 
 #define DEG_OBJECT_ITER(graph_, instance_, flag_)                                 \
        {                                                                             \
-               DEGOIterObjectData data_ = {                                          \
+               DEGOIterObjectData data_ = {                                              \
                        .graph = (graph_),                                                    \
                        .flag = (flag_),                                                      \
                };                                                                        \
@@ -119,7 +119,11 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
                ITER_BEGIN(DEG_iterator_objects_begin,                                    \
                           DEG_iterator_objects_next,                                     \
                           DEG_iterator_objects_end,                                      \
-                          &data_, Object *, instance_)
+                          &data_, Object *, instance_)                                   \
+                                                                                  \
+                       if (BKE_object_is_visible(instance_) == false) {                      \
+                               continue;                                                         \
+                       }
 
 #define DEG_OBJECT_ITER_END                                                       \
                ITER_END                                                                  \
index 6f6992a2256b26d421133a806ec7a891c8af042b..f24381e1fb4c7248cc108b762b2e7b92d4a0be22 100644 (file)
@@ -114,10 +114,6 @@ static void eevee_cache_populate(void *vedata, Object *ob)
        }
 
        if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
-               if (!BKE_object_is_visible(ob)) {
-                       return;
-               }
-
                EEVEE_materials_cache_populate(vedata, sldata, ob);
 
                const bool cast_shadow = true;
index d7ccc1a5336b36cb8cceaa8b4babe6c5973ce3b4..fed8460e00868d2304633e430b8d10a019b1d01e 100644 (file)
@@ -685,8 +685,7 @@ static void EEVEE_planar_reflections_updates(EEVEE_ViewLayerData *sldata, EEVEE_
                eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
 
                /* Debug Display */
-               if (BKE_object_is_visible(ob) &&
-                   DRW_state_draw_support() &&
+               if (DRW_state_draw_support() &&
                    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
                {
                        DRW_shgroup_call_dynamic_add(stl->g_data->planar_display_shgrp, &ped->probe_id, ob->obmat);
@@ -734,8 +733,7 @@ static void EEVEE_lightprobes_updates(EEVEE_ViewLayerData *sldata, EEVEE_PassLis
                invert_m4(eprobe->parallaxmat);
 
                /* Debug Display */
-               if (BKE_object_is_visible(ob) &&
-                   DRW_state_draw_support() &&
+               if (DRW_state_draw_support() &&
                    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
                {
                        ped->probe_size = probe->data_draw_size * 0.1f;
@@ -816,8 +814,7 @@ static void EEVEE_lightprobes_updates(EEVEE_ViewLayerData *sldata, EEVEE_PassLis
                                                        len_v3(egrid->increment_z)) + 1.0f;
 
                /* Debug Display */
-               if (BKE_object_is_visible(ob) &&
-                   DRW_state_draw_support() &&
+               if (DRW_state_draw_support() &&
                    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
                {
                        struct Gwn_Batch *geom = DRW_cache_sphere_get();
index 525289f51b94eb5054de4addff5b241e8d8e7cf1..2ab5b9dd75808e11b69a583029fd2c25a6af8277 100644 (file)
@@ -2214,9 +2214,7 @@ bool DRW_object_is_renderable(Object *ob)
        Scene *scene = DST.draw_ctx.scene;
        Object *obedit = scene->obedit;
 
-       if (!BKE_object_is_visible(ob)) {
-               return false;
-       }
+       BLI_assert(BKE_object_is_visible(ob));
 
        if (ob->type == OB_MESH) {
                if (ob == obedit) {
index 91b64818effaf2d871797d71996b257e24d390a2..3d84611f94d632f1805c1424a84b4dffa9e1ab4c 100644 (file)
@@ -1763,10 +1763,6 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
        View3D *v3d = draw_ctx->v3d;
        int theme_id = TH_UNDEFINED;
 
-       if (!BKE_object_is_visible(ob)) {
-               return;
-       }
-
        //CollectionEngineSettings *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
 
        //bool do_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_wire");
index 47794e0e357b3f41e7a3265513a6765034d7dabc..83beb7da1ce4a8c9fb174248468323f05ab95f3f 100644 (file)
@@ -313,11 +313,10 @@ static void set_preview_layer(ViewLayer *view_layer, char pr_type)
 
        for (lc = view_layer->layer_collections.first; lc; lc = lc->next) {
                if (STREQ(lc->scene_collection->name, collection_name)) {
-                       lc->flag = COLLECTION_VISIBLE | COLLECTION_DISABLED;
-                       BKE_collection_enable(view_layer, lc);
+                       lc->flag = COLLECTION_VIEWPORT | COLLECTION_RENDER;
                }
                else {
-                       BKE_collection_disable(view_layer, lc);
+                       lc->flag = COLLECTION_DISABLED;
                }
        }
 }
index b00f33ae37d18a6149e397c035fa8810fcbb1678..0a51b1a0d69952f108c3f7c765151bad073692fb 100644 (file)
@@ -489,13 +489,12 @@ static int collection_toggle_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
-       ViewLayer *view_layer = CTX_data_view_layer(C);
        int action = RNA_enum_get(op->ptr, "action");
        LayerCollection *layer_collection = CTX_data_layer_collection(C);
 
        if (layer_collection->flag & COLLECTION_DISABLED) {
                if (ELEM(action, ACTION_TOGGLE, ACTION_ENABLE)) {
-                       BKE_collection_enable(view_layer, layer_collection);
+                       layer_collection->flag &= ~COLLECTION_DISABLED;
                }
                else { /* ACTION_DISABLE */
                        BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already disabled",
@@ -505,7 +504,7 @@ static int collection_toggle_exec(bContext *C, wmOperator *op)
        }
        else {
                if (ELEM(action, ACTION_TOGGLE, ACTION_DISABLE)) {
-                       BKE_collection_disable(view_layer, layer_collection);
+                       layer_collection->flag |= COLLECTION_DISABLED;
                }
                else { /* ACTION_ENABLE */
                        BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already enabled",
index cecfc0cb71d1e50049b3249cfaf00fc80bc924dc..bc40067c2a8456dbd1a531e6142d66e5f2245ca2 100644 (file)
@@ -247,49 +247,16 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
        WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
-static void enablebutton_collection_flag_cb(bContext *C, void *poin, void *poin2)
-{
-       Main *bmain = CTX_data_main(C);
-       Scene *scene = CTX_data_scene(C);
-       ID *id = poin;
-       LayerCollection *layer_collection = poin2;
-       ViewLayer *view_layer = BKE_view_layer_find_from_collection(id, layer_collection);
-
-       /* TODO: This breaks when you see the collections of a group. (dfelinto) */
-       if (view_layer == NULL) {
-               WM_reportf(RPT_INFO, "Enable/disable of group collections disabled for now");
-               return;
-       }
-
-       /* We need to toggle the flag since this is called after the flag is already set. */
-       layer_collection->flag ^= COLLECTION_DISABLED;
-
-       if (layer_collection->flag & COLLECTION_DISABLED) {
-               BKE_collection_enable(view_layer, layer_collection);
-       }
-       else {
-               BKE_collection_disable(view_layer, layer_collection);
-       }
-
-       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_OB_SELECT, scene);
-       WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
-}
-
 static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2))
 {
        ID *id = (ID *)poin;
 
-       /* hide and deselect bases that are directly influenced by this LayerCollection */
        /* TODO(sergey): Use proper flag for tagging here. */
        DEG_id_tag_update(id, 0);
 
        if (GS(id->name) == ID_SCE) {
                WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, id);
        }
-
        WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
 }
 
@@ -602,21 +569,6 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
 
                                UI_block_emboss_set(block, UI_EMBOSS_NONE);
 
-                               bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0,
-                                                     is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
-                                                     UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
-                                                     TIP_("Enable/Disable collection from depsgraph"));
-                               UI_but_func_set(bt, enablebutton_collection_flag_cb, tselem->id, collection);
-                               UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
-                               bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VISIBLE, 0, ICON_RESTRICT_VIEW_OFF,
-                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
-                                                     UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
-                                                     TIP_("Restrict/Allow 3D View visibility of objects in the collection"));
-                               UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
-                               UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
                                if (collection->scene_collection->type == COLLECTION_TYPE_NONE) {
                                        bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
                                                              (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
@@ -625,6 +577,31 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                        UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
                                        UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
                                }
+                               else if ((soops->outlinevis == SO_GROUPS) &&
+                                        (collection->scene_collection->type == COLLECTION_TYPE_GROUP_INTERNAL))
+                               {
+                                       bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VIEWPORT, 0, ICON_RESTRICT_VIEW_OFF,
+                                                             (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), te->ys, UI_UNIT_X,
+                                                             UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+                                                             TIP_("Restrict/Allow 3D View selection of objects in the collection"));
+                                       UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+                                       UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+
+                                       bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_RENDER, 0, ICON_RESTRICT_RENDER_OFF,
+                                                             (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X,
+                                                             UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+                                                             TIP_("Restrict/Allow 3D View selection of objects in the collection"));
+                                       UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+                                       UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+                               }
+
+                               bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0,
+                                                     is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
+                                                     UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+                                                     TIP_("Enable/Disable collection"));
+                               UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+                               UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
 
                                UI_block_emboss_set(block, UI_EMBOSS);
                        }
@@ -1805,8 +1782,9 @@ static void outliner_draw_tree(
 
        /* set scissor so tree elements or lines can't overlap restriction icons */
        GLfloat scissor[4] = {0};
+       const bool is_group = (soops->outlinevis == SO_GROUPS);
        if (has_restrict_icons) {
-               int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)OL_TOGW + 1;
+               int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)(is_group ? OL_TOG_GROUPW : OL_TOGW) + 1;
                CLAMP_MIN(mask_x, 0);
 
                glGetFloatv(GL_SCISSOR_BOX, scissor);
@@ -1872,27 +1850,31 @@ static void outliner_back(ARegion *ar)
        immUnbindProgram();
 }
 
-static void outliner_draw_restrictcols(ARegion *ar)
+static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops)
 {
        glLineWidth(1.0f);
 
+       const bool is_group = (soops->outlinevis == SO_GROUPS);
+
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
        immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
-       immBegin(GWN_PRIM_LINES, 6);
+       immBegin(GWN_PRIM_LINES, is_group ? 6 : 4);
 
        /* view */
-       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax);
-       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin);
-
-       /* render */
-       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymax);
-       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymin);
+       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), (int)ar->v2d.cur.ymax);
+       immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), (int)ar->v2d.cur.ymin);
 
        /* render */
        immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax);
        immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin);
 
+       if (is_group) {
+               /* render */
+               immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), (int)ar->v2d.cur.ymax);
+               immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), (int)ar->v2d.cur.ymin);
+       }
+
        immEnd();
        immUnbindProgram();
 }
@@ -1943,8 +1925,9 @@ void draw_outliner(const bContext *C)
                
                /* constant offset for restriction columns */
                // XXX this isn't that great yet...
-               if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
-                       sizex += OL_TOGW * 3;
+               if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) {
+                       sizex += OL_TOGW * ((soops->flag & SO_GROUPS) != 0 ? 3 : 2);
+               }
 
                has_restrict_icons = !(soops->flag & SO_HIDE_RESTRICTCOLS);
        }
@@ -1972,12 +1955,12 @@ void draw_outliner(const bContext *C)
        }
        else if ((soops->outlinevis == SO_ID_ORPHANS) && has_restrict_icons) {
                /* draw user toggle columns */
-               outliner_draw_restrictcols(ar);
+               outliner_draw_restrictcols(ar, soops);
                outliner_draw_userbuts(block, ar, soops, &soops->tree);
        }
        else if (has_restrict_icons) {
                /* draw restriction columns */
-               outliner_draw_restrictcols(ar);
+               outliner_draw_restrictcols(ar, soops);
                outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree);
        }
 
index 9047512caad7707a9bcb6f5225d08ae36e2ae815..abf733d0684adde84c2289c86fc6d3c60482e1b5 100644 (file)
@@ -143,12 +143,14 @@ typedef enum {
 /* size constants */
 #define OL_Y_OFFSET 2
 
-#define OL_TOG_RESTRICT_ENABLEX (UI_UNIT_X * 3.0f)
+#define OL_TOG_RESTRICT_ENABLEX UI_UNIT_X
 #define OL_TOG_RESTRICT_VIEWX   (UI_UNIT_X * 2.0f)
-#define OL_TOG_RESTRICT_SELECTX UI_UNIT_X
-#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X
+#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 2.0f)
+#define OL_TOG_RESTRICT_RENDERX (UI_UNIT_X * 2.0f)
+#define OL_TOG_RESTRICT_VIEWPORTX (UI_UNIT_X * 3.0f)
 
-#define OL_TOGW OL_TOG_RESTRICT_ENABLEX
+#define OL_TOGW OL_TOG_RESTRICT_VIEWX
+#define OL_TOG_GROUPW OL_TOG_RESTRICT_VIEWPORTX
 
 #define OL_RNA_COLX         (UI_UNIT_X * 15)
 #define OL_RNA_COL_SIZEX    (UI_UNIT_X * 7.5f)
index c677383cb6e57abd8077f8252aac9523ecc22a8c..ff81e04c5a107df2cbf25ebb13bbcaa6dc1abff0 100644 (file)
@@ -123,9 +123,10 @@ enum {
 
 /* LayerCollection->flag */
 enum {
-       COLLECTION_VISIBLE    = (1 << 0),
+       COLLECTION_VIEWPORT   = (1 << 0), /* Only used for group collections. */
        COLLECTION_SELECTABLE = (1 << 1),
        COLLECTION_DISABLED   = (1 << 2),
+       COLLECTION_RENDER     = (1 << 3), /* Only used for group collections. */
 };
 
 /* ViewLayer->flag */
index 877d6b250c0774e0d9c7a900b7d4f2d702f87cd0..11e35bed9ee4252d369d166c034c474c18a0516c 100644 (file)
@@ -70,6 +70,7 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
 #include "BKE_idprop.h"
 #include "BKE_layer.h"
 #include "BKE_node.h"
+#include "BKE_object.h"
 #include "BKE_scene.h"
 #include "BKE_mesh.h"
 
@@ -703,48 +704,6 @@ static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *ptr)
        WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
 }
 
-static void rna_LayerCollection_enable_set(
-        ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports, int value)
-{
-       ViewLayer *view_layer;
-       if (GS(id->name) == ID_SCE) {
-               Scene *scene = (Scene *)id;
-               view_layer = BKE_view_layer_find_from_collection(&scene->id, layer_collection);
-       }
-       else {
-               BLI_assert(GS(id->name) == ID_GR);
-               Group *group = (Group *)id;
-               view_layer = group->view_layer;
-       }
-
-       if (layer_collection->flag & COLLECTION_DISABLED) {
-               if (value == 1) {
-                       BKE_collection_enable(view_layer, layer_collection);
-               }
-               else {
-                       BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already disabled",
-                                   layer_collection->scene_collection->name);
-                       return;
-               }
-       }
-       else {
-               if (value == 0) {
-                       BKE_collection_disable(view_layer, layer_collection);
-               }
-               else {
-                       BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already enabled",
-                                   layer_collection->scene_collection->name);
-               }
-       }
-
-       Scene *scene = CTX_data_scene(C);
-       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_OB_SELECT, scene);
-       WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
-}
-
 static Group *rna_LayerCollection_create_group(
         ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports)
 {
@@ -2065,11 +2024,6 @@ static void rna_def_layer_collection(BlenderRNA *brna)
        parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded");
        RNA_def_function_return(func, parm);
 
-       func = RNA_def_function(srna, "enable_set", "rna_LayerCollection_enable_set");
-       RNA_def_function_ui_description(func, "Enable or disable a collection");
-       parm = RNA_def_boolean(func, "value", 1, "Enable", "");
-       RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
-
        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);
@@ -2077,23 +2031,31 @@ static void rna_def_layer_collection(BlenderRNA *brna)
        RNA_def_function_return(func, parm);
 
        /* Flags */
-       prop = RNA_def_property(srna, "is_enabled", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection from depsgraph");
+       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, "hide", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE);
+       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, "Hide", "Restrict visiblity");
+       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, "hide_select", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE);
+       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_SELECT_OFF, 1);
-       RNA_def_property_ui_text(prop, "Hide Selectable", "Restrict selection");
+       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");
 
        /* TODO_LAYER_OVERRIDE */
index 9301ed63adb53b9d68bf938ac3338a6200263dd2..786598b073197d41b3be59596dbe84a4f98f7b58 100644 (file)
@@ -229,6 +229,12 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
        DEG_id_type_tag(bmain, ID_OB);
 }
 
+static int rna_Object_is_visible_get(PointerRNA *ptr)
+{
+       Object *ob = ptr->id.data;
+       return BKE_object_is_visible(ob);
+}
+
 static void rna_Object_collection_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Object *ob = ptr->data;
@@ -2786,27 +2792,14 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
        
        /* restrict */
-       prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
-       RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
-       RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
-
-       prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
-       RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
-       RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
        prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
        RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
-       /* Keep it in sync with BKE_object_is_visible. */
        prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_VISIBLED);
+       RNA_def_property_boolean_funcs(prop, "rna_Object_is_visible_get", NULL);
        RNA_def_property_ui_text(prop, "Visible", "Visible to camera rays, set only on objects evaluated by depsgraph");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
index 82404d54fe3091c32fa88dc696597f86b346eef3..bd80f638ef4d594b63caa55a79ab8b463b83760b 100644 (file)
@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = True
+        layer_collection_mom.enabled = False
         bpy.context.scene.update()  # update depsgraph
         cube.select_set('SELECT')
 
index f05ab5de2e1af76fbbfd5531e98e96e6d20bfb9d..a220d89445ebc69c526d67944c83e7126630f09a 100644 (file)
@@ -39,8 +39,8 @@ class UnitTesting(ViewLayerTesting):
         bpy.context.scene.update()  # update depsgraph
         cube.select_set('SELECT')
 
-        layer_collection_mom.collections[layer_collection_kid.name].hide = True
-        layer_collection_kid.hide = True
+        layer_collection_mom.collections[layer_collection_kid.name].enabled = False
+        layer_collection_kid.enabled = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertFalse(cube.visible_get(), "Cube should be invisible")
index 71452bc13548b30c4f9c6636262ab89033974422..e551310cbbe0a9eba16b68d9e6aba8ff93f78a06 100644 (file)
@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
+        layer_collection_mom.enabled = True
         bpy.context.scene.update()  # update depsgraph
         cube.select_set('SELECT')
 
index 529a36c101e8257127188eb3f08e2c6eb673acd7..76adf12c6669b1356f3cea7254e6afeed1b3b4af 100644 (file)
@@ -37,11 +37,11 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
+        layer_collection_mom.enabled = True
         bpy.context.scene.update()  # update depsgraph
 
         cube.select_set('SELECT')
-        layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
+        layer_collection_mom.collections[layer_collection_kid.name].selectable = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Cube should be visible")
index a26fa0df304e7d3900e8afef20a063a709843537..970c1cdd9d253ba701b64dfc0d3b4c341b35a789 100644 (file)
@@ -37,10 +37,10 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
+        layer_collection_mom.enabled = True
         cube.select_set('SELECT')
-        layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
-        layer_collection_kid.hide = True
+        layer_collection_mom.collections[layer_collection_kid.name].selectable = False
+        layer_collection_kid.enabled = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Cube should be visible")
index 1cffed9b0f4c259cbe15cfbda8d16d65d8e63a23..54a070e4ae92a8ea8c17f3d573a4fc4f961092fa 100644 (file)
@@ -26,8 +26,8 @@ class UnitTesting(ViewLayerTesting):
 
         scene_collection.objects.link(cube)
 
-        self.assertFalse(layer_collection.hide)
-        self.assertFalse(layer_collection.hide_select)
+        self.assertTrue(layer_collection.enabled)
+        self.assertTrue(layer_collection.selectable)
 
         bpy.context.scene.update()  # update depsgraph
         cube.select_set(action='SELECT')
index 3ae567df82c7a1d62ceca564bf0afb693642da39..c1e6a427210ee1345418bfae8643a63ae01f1ef1 100644 (file)
@@ -38,8 +38,8 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = True
-        layer_collection_kid.hide = False
+        layer_collection_mom.enabled = False
+        layer_collection_kid.enabled = True
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
index 93ace3928f234b14d0ccc45014d7707963ce18bc..a6859ba31ec30dbbed9820ce77de5a9bcbcea82a 100644 (file)
@@ -37,9 +37,9 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
-        layer_collection_mom.collections[layer_collection_kid.name].hide = True
-        layer_collection_kid.hide = True
+        layer_collection_mom.enabled = True
+        layer_collection_mom.collections[layer_collection_kid.name].enabled = False
+        layer_collection_kid.enabled = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertFalse(cube.visible_get(), "Object should be invisible")
index 05db85771671f8d8595b48f896de4a0c60949e53..8c88a045c99f1f1013f124a5cab3186bf2e93fe3 100644 (file)
@@ -37,9 +37,9 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
-        layer_collection_mom.collections[layer_collection_kid.name].hide = True
-        layer_collection_kid.hide = False
+        layer_collection_mom.enabled = True
+        layer_collection_mom.collections[layer_collection_kid.name].enabled = False
+        layer_collection_kid.enabled = True
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
index e08ab4d571eee5999e9698211b97a9c0de5ebcb4..1836fae98027c19322020c2b4b705dedeb2fbc1a 100644 (file)
@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
+        layer_collection_mom.enabled = True
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
 
index b54238337c60b2c5371b657cb6cecb3a3060607e..f05d797ecdc89f04398b609247cba6bfcbbc598e 100644 (file)
@@ -38,8 +38,8 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
-        layer_collection_kid.hide = True
+        layer_collection_mom.enabled = True
+        layer_collection_kid.enabled = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
index e532a19e3ef160fdccc964678f5a7cdf3683d46c..9034d0ce6f821aa9f9837f606bde3aecaf54efef 100644 (file)
@@ -38,9 +38,9 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
-        layer_collection_mom.hide = False
-        layer_collection_mom.collections[layer_collection_kid.name].hide = True
-        layer_collection_kid.hide = True
+        layer_collection_mom.enabled = True
+        layer_collection_mom.collections[layer_collection_kid.name].enabled = False
+        layer_collection_kid.enabled = False
 
         bpy.context.scene.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
index 6a4478aeba8073957abf00421762f901734c166f..5d3a03b129b958aa17e8136fd8050c41724b6251 100644 (file)
@@ -35,10 +35,10 @@ class UnitTesting(ViewLayerTesting):
         grandma_layer_collection = scene.view_layers[0].collections.link(grandma)
         mom_layer_collection = grandma_layer_collection.collections[0]
 
-        grandma_layer_collection.hide = False
-        grandma_layer_collection.hide = False
-        mom_layer_collection.hide = True
-        mom_layer_collection.hide_select = False
+        grandma_layer_collection.enabled = True
+        grandma_layer_collection.enabled = True
+        mom_layer_collection.enabled = False
+        mom_layer_collection.selectable = True
 
         # update depsgraph
         scene.update()
@@ -53,14 +53,14 @@ class UnitTesting(ViewLayerTesting):
         self.assertEqual(len(group.view_layer.collections), 1)
         grandma_group_layer = group.view_layer.collections[0]
 
-        self.assertEqual(grandma_group_layer.hide, False)
-        self.assertEqual(grandma_group_layer.hide_select, False)
+        self.assertTrue(grandma_group_layer.enabled, True)
+        self.assertTrue(grandma_group_layer.selectable)
 
         self.assertEqual(len(grandma_group_layer.collections), 1)
         mom_group_layer = grandma_group_layer.collections[0]
 
-        self.assertEqual(mom_group_layer.hide, True)
-        self.assertEqual(mom_group_layer.hide_select, False)
+        self.assertFalse(mom_group_layer.enabled)
+        self.assertTrue(mom_group_layer.selectable)
 
 
 # ############################################################
index 8182655ebbd094c6c926521eb2ee92c56449d117..77d65ef8671e3d11b9f2c6a8b409bbb2a25829e1 100644 (file)
@@ -72,13 +72,13 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 2.3')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # collection that will disappear
         collection_old = self.parse_move('Layer 2.C.3')
-        collection_old.hide = True
-        collection_old.hide_select = False
+        collection_old.enabled = False
+        collection_old.selectable = True
 
         # move
         self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1'))
@@ -87,8 +87,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 2.C.3')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index 7ee7aff9dc7f7f3565ade2a53343fb92d08bff3c..16cd628edfcde402f3380f0add12938d47a15854 100644 (file)
@@ -53,13 +53,13 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 2.C.3.cat')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # collection that will disappear
         collection_old = self.parse_move('Layer 2.3.cat')
-        collection_old.hide = True
-        collection_old.hide_select = False
+        collection_old.enabled = False
+        collection_old.selectable = True
 
         # move
         self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog'))
@@ -68,8 +68,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 2.3.cat')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index 4581f9d4767d54d4fbee2d873d2e96028ea5c2eb..4fe2c857e50b3438008fc8b7c74accedb3b0793b 100644 (file)
@@ -38,13 +38,13 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 2.C.3.cat')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # collection that will disappear
         collection_old = self.parse_move('Layer 2.3.cat')
-        collection_old.hide = True
-        collection_old.hide_select = False
+        collection_old.enabled = False
+        collection_old.selectable = True
 
         # move
         self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog'))
@@ -53,8 +53,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 2.3.cat')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index fd204cc0a4611e4538f86f4a9a4376c1f16a8981..0134d11adcdfb1102d1c46481c88a97ec323f373 100644 (file)
@@ -50,8 +50,8 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 2.C')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # move
         self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3'))
@@ -60,8 +60,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 2.C')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index 7c9dcbfdb3a19bfefc9991c31f4fac708e8af25e..cb56ca0b963d7ced05ad569d7449ad83691b1e0c 100644 (file)
@@ -39,8 +39,8 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 1.3.dog')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # move
         self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat'))
@@ -50,8 +50,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 1.3.dog')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index d857fd4cd1b014e78c2ea1a19041bec220b10f11..7bf007d272462655a0bd31d0f192ade8b00324fe 100644 (file)
@@ -64,8 +64,8 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 1.3')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         self.assertTrue(self.move_into('Layer 1.3', 'Layer 1.Master Collection.A'))
         self.compare_tree_maps()
@@ -73,8 +73,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 1.Master Collection.A.3')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index c3a0e80c3a037ca01c5d8c964394544d7c493fb8..efcdd44da9782fbe6e8abc993edf5c25834698de 100644 (file)
@@ -49,13 +49,13 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 2.3')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         # collection that will disappear
         collection_old = self.parse_move('Layer 2.C.3')
-        collection_old.hide = True
-        collection_old.hide_select = False
+        collection_old.enabled = False
+        collection_old.selectable = True
 
         # move collection
         self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C'))
@@ -64,8 +64,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 2.C.3')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index fc0bef61214be300a46477fcbe78d92122cbfa6c..82f5d70dceb86256421355ea3cc6f987e29cd15e 100644 (file)
@@ -54,8 +54,8 @@ class UnitTesting(MoveLayerCollectionTesting):
 
         # collection that will be moved
         collection_original = self.parse_move('Layer 1.3.dog')
-        collection_original.hide = False
-        collection_original.hide_select = True
+        collection_original.enabled = True
+        collection_original.selectable = False
 
         self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1'))
         self.compare_tree_maps()
@@ -63,8 +63,8 @@ class UnitTesting(MoveLayerCollectionTesting):
         # we expect the settings to be carried along from the
         # original layer collection
         collection_new = self.parse_move('Layer 1.C.1.dog')
-        self.assertEqual(collection_new.hide, False)
-        self.assertEqual(collection_new.hide_select, True)
+        self.assertEqual(collection_new.enabled, True)
+        self.assertEqual(collection_new.selectable, False)
 
 
 # ############################################################
index 726861df9ba9cb9e8a289f33cbf57e2a0e5c6c4b..f97eec3b98ae490a15a4d86adcd2bc00593b82df 100644 (file)
@@ -24,11 +24,11 @@ class UnitTesting(ViewLayerTesting):
 
         scene = bpy.context.scene
 
-        hide_lookup = [0, 1, 1, 0]
-        hide_lookup_sub = [1, 0, 1]
+        enabled_lookup = [True, False, False, True]
+        enabled_lookup_sub = [False, True, False]
 
-        hide_select_lookup = [0, 0, 1, 1]
-        hide_select_lookup_sub = [1, 0, 1, 0]
+        selectable_lookup = [True, True, False, False]
+        selectable_lookup_sub = [False, True, False, True]
         new_collections = []
 
         # clean everything
@@ -50,12 +50,12 @@ class UnitTesting(ViewLayerTesting):
                 layer.collections.link(collection)
                 self.assertEqual(layer.collections[-1], layer.collections[i])
 
-                layer.collections[i].hide = hide_lookup[i]
-                layer.collections[i].hide_select = hide_select_lookup[i]
+                layer.collections[i].enabled = enabled_lookup[i]
+                layer.collections[i].selectable = selectable_lookup[i]
 
                 for j, sub_collection in enumerate(layer.collections[i].collections):
-                    sub_collection.hide = hide_lookup_sub[j]
-                    sub_collection.hide_select = hide_select_lookup_sub[j]
+                    sub_collection.enabled = enabled_lookup_sub[j]
+                    sub_collection.selectable = selectable_lookup_sub[j]
 
         # copy scene
         bpy.ops.scene.new(type='FULL_COPY')
@@ -71,13 +71,13 @@ class UnitTesting(ViewLayerTesting):
 
             for i, collection in enumerate(layer.collections):
                 new_collection = new_layer.collections[i]
-                self.assertEqual(collection.hide, new_collection.hide)
-                self.assertEqual(collection.hide_select, new_collection.hide_select)
+                self.assertEqual(collection.enabled, new_collection.enabled)
+                self.assertEqual(collection.selectable, new_collection.selectable)
 
                 for j, sub_collection in enumerate(layer.collections[i].collections):
                     new_sub_collection = new_collection.collections[j]
-                    self.assertEqual(sub_collection.hide, new_sub_collection.hide)
-                    self.assertEqual(sub_collection.hide_select, new_sub_collection.hide_select)
+                    self.assertEqual(sub_collection.enabled, new_sub_collection.enabled)
+                    self.assertEqual(sub_collection.selectable, new_sub_collection.selectable)
 
 
 # ############################################################