Page MenuHome

Outliner Selected Objects in Scene View

Authored by Harley Acheson (harley) on Apr 10 2019, 7:20 PM.



Fixes the problem reported here:

When using the Outliner in "View Layer" mode the active and selected objects are shown specially by having their icons have a background circle that is painted in orange and red (depends on theme).

But when viewing in "Scene" mode however, you only see a black circle for the active object, whether selected or not. So select an object then deselect all and you will still see that object with black circle. But you never see any with orange and red like you do as when in View Layer mode

Basically they way that "is_selected" is evaluated in there doesn't work when viewing as scene. This patch fixes that. The following capture shows the current behavior on left, the fixed behavior on right.

Note this patch does nothing but fix this one small thing, so just a one-line change.

Larger changes to outliner remain here and I will incorporate this fix into that patch as well.

Diff Detail

rB Blender

Event Timeline

@Harley Acheson (harley) Thank you for the improvement. I'll post another "problem" into this discussion.

This revision is now accepted and ready to land.Apr 11 2019, 12:58 PM
This revision was automatically updated to reflect the committed changes.

I raised a concern about this commit. Since I believe the author of the original patch is not poked in that case let's me repeat it here:

Isn't this too expensive? Even using ghash we run this for every object. Also this runs even when te->directdata would be valid (i.e., when in view layer mode).
I think we should at the very least use (potentially outdated) ob->base_flag when te->directdata is not Base.

Note, if we are to get rid of BKE_view_layer_base_find in this case, outliner_draw_restrictbuts() could probably be addressed as well.

I agree, but couldn’t find (from what I could understand from that area) another way of fixing that. I don’t really know how important that performance regression could be, nor how much weight to give to the original complaint.

We could revert this if you think best. Not seeing highlighted objects outside of layer view mode is not going to kill anyone. And then someone (or me if I gain some knowledge there) could fix it properly later.

@Dalai Felinto (dfelinto): This works fine. Does this approach work for you?

So use the element's directdata as base only if in view layer mode, otherwise use ob->base_flag

else if (te->idcode == ID_OB) {
  Object *ob = (Object *)tselem->id;
  short base_flag = 0;
  if (soops->outlinevis == SO_VIEW_LAYER) {
    Base *base = (Base *)te->directdata;
    if (base != NULL) {
      base_flag = base->flag;
  else {
    base_flag = ob->base_flag;

  const bool is_selected = ((base_flag & BASE_SELECTED) != 0);

A patch for this particular issue (with outliner_draw_tree_element) is now here:

Doing similar for outliner_draw_restrictbuts() looks a bit more complex (to me) because of the need to pass base to UI_but_func_set() and UI_but_func_pushed_state_set()