Page MenuHome

Local Collections: Allow users to show hidden collections
ClosedPublic

Authored by Dalai Felinto (dfelinto) on Oct 4 2019, 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
Branch
dev-v3d-collections (branched from master)
Build Status
Buildable 5283
Build 5283: arc lint + arc unit

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.Oct 8 2019, 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.Oct 8 2019, 11:40 AM
Dalai Felinto (dfelinto) marked an inline comment as done.Oct 8 2019, 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.Oct 8 2019, 6:09 PM

As someone who wasn't aware this even happened until my code in my own branch broke, I'm missing a few things.

  • An explanation what "visible for the depsgraph" even means. The depsgraph doesn't have eyes, and it's an invisible thing in itself.
  • A guide that explains what the proper replacement is for the old BASE_VISIBLE.

Maybe one of the two is enough; it may be obvious which one to replace the old BASE_VISIBLE with once you know what "visible for the depsgraph" means.

Hi @Sybren A. Stüvel (sybren),

BASE_VISIBLE_VIEWLAYER means the object (base) is visible as a whole in the view layer.
This is what is used when checking from outside a viewport (e.g., in action editor you decide to see only the visible objects), or in a viewport when you are not using local collections.

BASE_VISIBLE_DEPSGRAPH is a test to see whether the object is enabled in the depsgraph.

A simple way of remembering it: The base not visible in the depsgraph will never be visible in the view layer (or just look at the code in BKE_base_is_visible).

Enabled in the depsgraph

What's that?
There are no changes in the depsgraph builder, so all the dependencies are enabled.

An explanation what "visible for the depsgraph" even means. The depsgraph doesn't have eyes, and it's an invisible thing in itself.

Not entirely true. Depsgraph knows what is to be shown in the corresponding "context": as in, what is to be displayed in the viewport or rendered in the final F12, and it knows about "support" objects which are only needed to bring actually visible ones to their final state.

One most clear example of this is a boolean modifier, whos operand is not visible (otherwise it will be in a way of viewer, making the entire boolean operation pointless).

Main confusion here comes from the undefined nature of an observer. BASE_VISIBLE_DEPSGRAPH is not to be treated as "visible by dependency graph" but rather "by a render engine looking at the dependency graph". Something like this.

That being said, naming is rather confusing. The comment around the flags are so called "over documenting comments": comments which are there but which do not add any extra information.

A guide that explains what the proper replacement is for the old BASE_VISIBLE.

That's a great point. Something to get in a culture to mention how to update code in other branches/projects/studio forks/etc.
To make it clear: the point is applicable in many cases outside of this specific change.

That being said, naming is rather confusing. The comment around the flags are so called "over documenting comments": comments which are there but which do not add any extra information.

To add to that, something that's also bugging me but was already there before this patch, is that "Object is enabled" doesn't make sense. What is an "enabled object"?