Fix T70080: Newly created objects not visible with local collections

The tricky part here is to support a hidden parent and a "visible" child
collection. In this case the object should obviously be invisible. It is
all working now.
This commit is contained in:
Dalai Felinto 2019-09-24 11:48:49 -03:00
parent 9dced206dd
commit 3142ae19d2
Notes: blender-bot 2023-02-14 00:44:03 +01:00
Referenced by issue #70247, Crash on enter edit mode with UV editor opened
Referenced by issue #70080, Newly created objects not visible when using local collections
1 changed files with 10 additions and 3 deletions

View File

@ -654,7 +654,8 @@ static short layer_collection_sync(ViewLayer *view_layer,
ListBase *new_object_bases,
short parent_exclude,
short parent_restrict,
short parent_layer_restrict)
short parent_layer_restrict,
unsigned short parent_local_collections_bits)
{
/* TODO: support recovery after removal of intermediate collections, reordering, ..
* For local edits we can make editing operating do the appropriate thing, but for
@ -700,6 +701,9 @@ static short layer_collection_sync(ViewLayer *view_layer,
lc->flag = parent_exclude;
}
unsigned short local_collections_bits = parent_local_collections_bits &
lc->local_collections_bits;
/* Tag linked collection as a weak reference so we keep the layer
* collection pointer on file load and remember exclude state. */
id_lib_indirect_weak_link(&collection->id);
@ -719,7 +723,8 @@ static short layer_collection_sync(ViewLayer *view_layer,
new_object_bases,
lc->flag,
child_restrict,
child_layer_restrict);
child_layer_restrict,
local_collections_bits);
/* Layer collection exclude is not inherited. */
if (lc->flag & LAYER_COLLECTION_EXCLUDE) {
@ -760,6 +765,7 @@ static short layer_collection_sync(ViewLayer *view_layer,
else {
/* Create new base. */
base = object_base_new(cob->ob);
base->local_collections_bits = local_collections_bits;
*base_p = base;
BLI_addtail(new_object_bases, base);
}
@ -837,7 +843,8 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
&new_object_bases,
parent_exclude,
parent_restrict,
parent_layer_restrict);
parent_layer_restrict,
~(0));
/* Any remaining object bases are to be removed. */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {