Page MenuHome

Local Collections: Allow users to show hidden collections
ClosedPublic

Authored by Dalai Felinto (dfelinto) on Fri, Oct 4, 7:13 PM.

Details

Summary

Users now can turn on in a viewport collections that are temporarily
hidden (eye) in the view layer.

Design task: T61327

There is one "bug" that in a way was there before which is some
operators (e.g., writing a text inside of a text object) run regardless
of the visibility of the active object.

The issue is a bit worse now since if the active object is hidden you
can still go to edit mode and type a text without seeing what is going
on.

As for the implementation, I had to decouple the visibility in the
depsgraph from the visibility in the view layer. The patch probably
needs more testing, but I got the basis well coverered here.

Diff Detail

Repository
rB Blender

Event Timeline

As usual my test file:

Build warnings and errors:

1[377/2992] Building C object source/blender/editors/sculpt_paint/CMakeFiles/bf_editor_sculpt_paint.dir/paint_vertex.c.o
2In file included from /home/brecht/dev/worktree/source/blender/editors/sculpt_paint/paint_vertex.c:39:0:
3/home/brecht/dev/worktree/source/blender/editors/sculpt_paint/paint_vertex.c: In function ‘wpaint_mode_toggle_exec’:
4/home/brecht/dev/worktree/source/blender/editors/sculpt_paint/paint_vertex.c:1323:47: warning: passing argument 2 of ‘BKE_base_is_visible’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
5 if (base_arm && BASE_VISIBLE(v3d, base_arm)) {
6 ^
7/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:58: note: in definition of macro ‘BASE_VISIBLE’
8 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
9 ^~~~
10In file included from /home/brecht/dev/worktree/source/blender/editors/sculpt_paint/paint_vertex.c:57:0:
11/home/brecht/dev/worktree/source/blender/blenkernel/BKE_layer.h:117:6: note: expected ‘struct Base *’ but argument is of type ‘const Base * {aka const struct Base *}’
12 bool BKE_base_is_visible(struct View3D *v3d, struct Base *base);
13 ^~~~~~~~~~~~~~~~~~~
14[597/2992] Building C object source/blender/editors/transform/CMakeFiles/bf_editor_transform.dir/transform_snap_object.c.o
15In file included from /home/brecht/dev/worktree/source/blender/editors/transform/transform_snap_object.c:37:0:
16/home/brecht/dev/worktree/source/blender/editors/transform/transform_snap_object.c: In function ‘iter_snap_objects’:
17/home/brecht/dev/worktree/source/blender/editors/transform/transform_snap_object.c:226:23: warning: passing argument 1 of ‘BKE_base_is_visible’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
18 if (!BASE_VISIBLE(v3d, base)) {
19 ^
20/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:53: note: in definition of macro ‘BASE_VISIBLE’
21 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
22 ^~~
23In file included from /home/brecht/dev/worktree/source/blender/editors/transform/transform_snap_object.c:50:0:
24/home/brecht/dev/worktree/source/blender/blenkernel/BKE_layer.h:117:6: note: expected ‘struct View3D *’ but argument is of type ‘const View3D * {aka const struct View3D *}’
25 bool BKE_base_is_visible(struct View3D *v3d, struct Base *base);
26
27
28/home/brecht/dev/worktree/source/blender/alembic/intern/abc_exporter.cc: In function ‘bool export_object(const ExportSettings*, const Base*, bool)’:
29/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: error: ‘BKE_base_is_visible’ was not declared in this scope
30 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
31 ^
32/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: in definition of macro ‘BASE_VISIBLE’
33 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
34 ^~~~~~~~~~~~~~~~~~~
35/home/brecht/dev/worktree/source/blender/alembic/intern/abc_exporter.cc:158:37: note: in expansion of macro ‘BASE_SELECTED’
36 if (settings->selected_only && !BASE_SELECTED(v3d, base)) {
37 ^
38/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: suggested alternative: ‘BKE_mball_is_basis’
39 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
40 ^
41/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: in definition of macro ‘BASE_VISIBLE’
42 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
43 ^~~~~~~~~~~~~~~~~~~
44/home/brecht/dev/worktree/source/blender/alembic/intern/abc_exporter.cc:158:37: note: in expansion of macro ‘BASE_SELECTED’
45 if (settings->selected_only && !BASE_SELECTED(v3d, base)) {
46 ^
47/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: error: ‘BKE_base_is_visible’ was not declared in this scope
48 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
49 ^
50/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: in definition of macro ‘BASE_VISIBLE’
51 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
52 ^~~~~~~~~~~~~~~~~~~
53/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: suggested alternative: ‘BKE_mball_is_basis’
54 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
55 ^
56/home/brecht/dev/worktree/source/blender/makesdna/DNA_scene_types.h:1979:33: note: in definition of macro ‘BASE_VISIBLE’
57 #define BASE_VISIBLE(v3d, base) BKE_base_is_visible(v3d, base)
58 ^~~~~~~~~~~~~~~~~~~

Brecht Van Lommel (brecht) requested changes to this revision.Tue, Oct 8, 11:40 AM

It seems that it is impossible to select objects that are locally visible in a viewport, but hidden globally for the view layer.

Clicking in the viewport does not select them. They can be selected in the outliner, but transforming them then still does not work.

I guess it needs to be carefully checked that selecting objects is possible even if they are marked as hidden in the view layer, but that operators only considered them as actually selected if they are also visible with the context. I guess the code is already doing that for the most part but missing some cases?

source/blender/draw/intern/draw_manager.c
1589–1591

Should use != 0

It's not obvious to me why this test is needed though.

This revision now requires changes to proceed.Tue, Oct 8, 11:40 AM
Dalai Felinto (dfelinto) marked an inline comment as done.Tue, Oct 8, 1:59 PM

It seems that it is impossible to select objects that are locally visible in a viewport, but hidden globally for the view layer.

Can confirm, I will look at it. It may be the operators poll :/ hopefully not I'm staying away from any change that would touch many operators.

source/blender/draw/intern/draw_manager.c
1589–1591

This function is called from a DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN which now tests only for "depsgraph" visibility (BKE_object_visibility()) disconsidering the view layer visibility.

Easy to test, (without local view or local collection) if this goes away the objects will always be visible, even if you hide their collections.

Dalai Felinto (dfelinto) marked an inline comment as done.
  • Fix small int/bool from review and add comment
  • Fix selection issues (and likely many others)

For the records the following fixes the original issue I mentioned regarding operator pools and "viewport hidden" active objects: P1132

You can reproduce the issue even in 2.80 with the object type visibility restriction and e.g., tab to edit mode invisible text objects. But if we consider this worth fixing I would rather we do it afterwards anyways.

This revision is now accepted and ready to land.Tue, Oct 8, 6:09 PM