Collections: Never change the collection views visibility when unhiding it

How to reproduce: use 1-10 to change the visible collection. If the
collection was globally invisible, it would be set to globally visible.

This was a left over from the previous collection visibility design.

Now that we have a more clear separation between temporary visibility
(i.e., layer collection visibiilty) and a global visibility setting
(i.e., collection visibility) we should keep them separated.
This commit is contained in:
Dalai Felinto
2019-06-07 18:41:37 -03:00
parent b236c2a0ce
commit e70428c80e
4 changed files with 7 additions and 45 deletions

View File

@@ -118,11 +118,11 @@ void BKE_base_set_visible(struct Scene *scene,
struct ViewLayer *view_layer,
struct Base *base,
bool extend);
bool BKE_layer_collection_isolate(struct Scene *scene,
void BKE_layer_collection_isolate(struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc,
bool extend);
bool BKE_layer_collection_set_visible(struct ViewLayer *view_layer,
void BKE_layer_collection_set_visible(struct ViewLayer *view_layer,
struct LayerCollection *lc,
const bool visible,
const bool hierarchy);

View File

@@ -1000,25 +1000,15 @@ static void layer_collection_flag_unset_recursive(LayerCollection *lc, const int
*
* If the collection or any of its parents is disabled, make it enabled.
* Don't change the children disable state though.
*
* Return whether depsgraph needs update.
*/
bool BKE_layer_collection_isolate(Scene *scene,
void BKE_layer_collection_isolate(Scene *scene,
ViewLayer *view_layer,
LayerCollection *lc,
bool extend)
{
bool depsgraph_need_update = false;
LayerCollection *lc_master = view_layer->layer_collections.first;
bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE);
if ((!ID_IS_LINKED(lc->collection) && !hide_it)) {
if (lc->collection->flag & COLLECTION_RESTRICT_VIEWPORT) {
lc->collection->flag &= ~COLLECTION_RESTRICT_VIEWPORT;
depsgraph_need_update = true;
}
}
if (!extend) {
/* Hide all collections . */
for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
@@ -1042,13 +1032,6 @@ bool BKE_layer_collection_isolate(Scene *scene,
}
while (lc_parent != lc) {
if (!ID_IS_LINKED(lc_parent->collection)) {
if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEWPORT) {
lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEWPORT;
depsgraph_need_update = true;
}
}
lc_parent->flag &= ~LAYER_COLLECTION_HIDE;
for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
@@ -1067,8 +1050,6 @@ bool BKE_layer_collection_isolate(Scene *scene,
}
BKE_layer_collection_sync(scene, view_layer);
return depsgraph_need_update;
}
static void layer_collection_bases_show_recursive(ViewLayer *view_layer, LayerCollection *lc)
@@ -1101,22 +1082,12 @@ static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCo
* Hide/show all the elements of a collection.
* Don't change the collection children enable/disable state,
* but it may change it for the collection itself.
*
* Return true if depsgraph needs update.
*/
bool BKE_layer_collection_set_visible(ViewLayer *view_layer,
void BKE_layer_collection_set_visible(ViewLayer *view_layer,
LayerCollection *lc,
const bool visible,
const bool hierarchy)
{
bool depsgraph_changed = false;
if (visible && (!ID_IS_LINKED(lc->collection)) &&
((lc->collection->flag & COLLECTION_RESTRICT_VIEWPORT) != 0)) {
lc->collection->flag &= ~COLLECTION_RESTRICT_VIEWPORT;
depsgraph_changed = true;
}
if (hierarchy) {
if (visible) {
layer_collection_flag_unset_recursive(lc, LAYER_COLLECTION_HIDE);
@@ -1135,7 +1106,6 @@ bool BKE_layer_collection_set_visible(ViewLayer *view_layer,
lc->flag |= LAYER_COLLECTION_HIDE;
}
}
return depsgraph_changed;
}
/* ---------------------------------------------------------------------- */
@@ -1422,7 +1392,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter)
static bool base_is_in_mode(struct ObjectsInModeIteratorData *data, Base *base)
{
return BASE_VISIBLE(data->v3d, base) && (base->object->type == data->object_type) &&
return (base->object->type == data->object_type) &&
(base->object->mode & data->object_mode) != 0;
}

View File

@@ -288,9 +288,7 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
if (BKE_layer_collection_isolate(scene, view_layer, lc, extend)) {
DEG_relations_tag_update(CTX_data_main(C));
}
BKE_layer_collection_isolate(scene, view_layer, lc, extend);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);

View File

@@ -1045,7 +1045,6 @@ static int collection_visibility_exec(bContext *C, wmOperator *op)
SpaceOutliner *soops = CTX_wm_space_outliner(C);
const bool is_inside = strstr(op->idname, "inside") != NULL;
const bool show = strstr(op->idname, "show") != NULL;
bool depsgraph_changed = false;
struct CollectionEditData data = {
.scene = scene,
.soops = soops,
@@ -1058,18 +1057,13 @@ static int collection_visibility_exec(bContext *C, wmOperator *op)
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
depsgraph_changed |= BKE_layer_collection_set_visible(
view_layer, layer_collection, show, is_inside);
BKE_layer_collection_set_visible(view_layer, layer_collection, show, is_inside);
}
BLI_gset_free(data.collections_to_edit, NULL);
BKE_layer_collection_sync(scene, view_layer);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
if (depsgraph_changed) {
DEG_relations_tag_update(CTX_data_main(C));
}
WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
return OPERATOR_FINISHED;
}