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:
authorDalai Felinto <dfelinto@gmail.com>2019-10-04 01:22:36 +0300
committerDalai Felinto <dfelinto@gmail.com>2019-10-09 01:16:05 +0300
commit0812949bbc3d7acfd1f20a47087ff973110aa177 (patch)
tree0ec8a52ea73790d85f4b14993de3c252e9fa6de5 /source/blender/blenkernel/intern/layer.c
parent6d3c34fe9d1eabc7765275ff68600734be0e3acb (diff)
Local Collections: Allow users to show hidden collections
Users now can turn on in a viewport collections that are temporarily hidden (eye) in the view layer. Design task: T61327 As for the implementation, I had to decouple the visibility in the depsgraph from the visibility in the view layer. Also there is a "bug" that in a way was there before which is some operators (e.g., writing a text inside of a text object, tab into edit mode) run regardless of the visibility of the active object. The bug was present already (with object type visibility restriction) in 2.80 so if we decide to tackle it, can be done separately (I have a patch for it though P1132). Reviewed by: brecht (thank you) Differential Revision: D5992
Diffstat (limited to 'source/blender/blenkernel/intern/layer.c')
-rw-r--r--source/blender/blenkernel/intern/layer.c86
1 files changed, 60 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 9b18052ef1e..726ca9d705b 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -44,6 +44,7 @@
#include "DNA_object_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
@@ -56,9 +57,10 @@
#include "MEM_guardedalloc.h"
/* Set of flags which are dependent on a collection settings. */
-static const short g_base_collection_flags = (BASE_VISIBLE | BASE_SELECTABLE |
- BASE_ENABLED_VIEWPORT | BASE_ENABLED_RENDER |
- BASE_HOLDOUT | BASE_INDIRECT_ONLY);
+static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER |
+ BASE_SELECTABLE | BASE_ENABLED_VIEWPORT |
+ BASE_ENABLED_RENDER | BASE_HOLDOUT |
+ BASE_INDIRECT_ONLY);
/* prototype */
static void object_bases_iterator_next(BLI_Iterator *iter, const int flag);
@@ -735,9 +737,15 @@ static short layer_collection_sync(ViewLayer *view_layer,
lc->runtime_flag = child_runtime_flag;
}
- if (((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) &&
+ /* We separate restrict viewport and visible view layer because a layer collection can be
+ * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted).*/
+ if (child_restrict & COLLECTION_RESTRICT_VIEWPORT) {
+ lc->runtime_flag |= LAYER_COLLECTION_RESTRICT_VIEWPORT;
+ }
+
+ if (((lc->runtime_flag & LAYER_COLLECTION_RESTRICT_VIEWPORT) == 0) &&
((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) {
- lc->runtime_flag |= LAYER_COLLECTION_VISIBLE;
+ lc->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER;
}
/* Sync objects, except if collection was excluded. */
@@ -771,12 +779,12 @@ static short layer_collection_sync(ViewLayer *view_layer,
}
if ((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) {
- base->flag_from_collection |= BASE_ENABLED_VIEWPORT;
+ base->flag_from_collection |= (BASE_ENABLED_VIEWPORT | BASE_VISIBLE_DEPSGRAPH);
if ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0) {
- base->flag_from_collection |= BASE_VISIBLE;
- if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) {
- base->flag_from_collection |= BASE_SELECTABLE;
- }
+ base->flag_from_collection |= BASE_VISIBLE_VIEWLAYER;
+ }
+ if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) {
+ base->flag_from_collection |= BASE_SELECTABLE;
}
}
@@ -974,7 +982,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle
for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
- if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE)) {
+ if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
return true;
}
}
@@ -1026,6 +1034,31 @@ void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool
BKE_layer_collection_sync(scene, view_layer);
}
+bool BKE_base_is_visible(const View3D *v3d, const Base *base)
+{
+ if ((base->flag & BASE_VISIBLE_DEPSGRAPH) == 0) {
+ return false;
+ }
+
+ if (v3d == NULL) {
+ return base->flag & BASE_VISIBLE_VIEWLAYER;
+ }
+
+ if ((v3d->localvd) && ((v3d->local_view_uuid & base->local_view_bits) == 0)) {
+ return false;
+ }
+
+ if (((1 << (base->object->type)) & v3d->object_type_exclude_viewport) != 0) {
+ return false;
+ }
+
+ if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
+ return (v3d->local_collections_uuid & base->local_collections_bits) != 0;
+ }
+
+ return base->flag & BASE_VISIBLE_VIEWLAYER;
+}
+
static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag)
{
lc->flag |= flag;
@@ -1050,13 +1083,13 @@ 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.
*/
-void BKE_layer_collection_isolate(Scene *scene,
- ViewLayer *view_layer,
- LayerCollection *lc,
- bool extend)
+void BKE_layer_collection_isolate_global(Scene *scene,
+ ViewLayer *view_layer,
+ LayerCollection *lc,
+ bool extend)
{
LayerCollection *lc_master = view_layer->layer_collections.first;
- bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE);
+ bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER);
if (!extend) {
/* Hide all collections . */
@@ -1163,9 +1196,9 @@ void BKE_layer_collection_local_sync(ViewLayer *view_layer, View3D *v3d)
/**
* Isolate the collection locally
*
- * Same as BKE_layer_collection_local_isolate but for a viewport
+ * Same as BKE_layer_collection_isolate_local but for a viewport
*/
-void BKE_layer_collection_local_isolate(ViewLayer *view_layer,
+void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
View3D *v3d,
LayerCollection *lc,
bool extend)
@@ -1436,12 +1469,12 @@ static void objects_iterator_end(BLI_Iterator *iter)
void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
{
- objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED);
+ objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
}
void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter)
{
- objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED);
+ objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
}
void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter)
@@ -1478,7 +1511,7 @@ void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *iter)
void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
{
- objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED);
+ objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
if (iter->valid) {
if (BKE_object_is_libdata((Object *)iter->current) == false) {
// First object is valid (selectable and not libdata) -> all good.
@@ -1495,7 +1528,7 @@ void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter)
{
// Search while there are objects and the one we have is not editable (editable = not libdata).
do {
- objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED);
+ objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
} while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false);
}
@@ -1512,12 +1545,12 @@ void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter)
void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
{
- objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED);
+ objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
}
void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter)
{
- object_bases_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED);
+ object_bases_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
}
void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *iter)
@@ -1617,7 +1650,8 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
/* Evaluation */
/* Applies object's restrict flags on top of flags coming from the collection
- * and stores those in base->flag. BASE_VISIBLE is based on viewport visibility. */
+ * and stores those in base->flag. BASE_VISIBLE_DEPSGRAPH ignores viewport flags visibility
+ * (i.e., restriction and local collection). */
void BKE_base_eval_flags(Base *base)
{
/* Apply collection flags. */
@@ -1640,7 +1674,7 @@ void BKE_base_eval_flags(Base *base)
* can change these again, but for tools we always want the viewport
* visibility to be in sync regardless if depsgraph was evaluated. */
if (!(base->flag & BASE_ENABLED_VIEWPORT) || (base->flag & BASE_HIDDEN)) {
- base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE);
+ base->flag &= ~(BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER | BASE_SELECTABLE);
}
/* Deselect unselectable objects. */