Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/blendfile_link_append.c
| Show First 20 Lines • Show All 675 Lines • ▼ Show 20 Lines | for (itemlink = lapp_context->items.list; itemlink; itemlink = itemlink->next) { | ||||
| ID *id = loose_data_instantiate_process_check(instantiate_context, item); | ID *id = loose_data_instantiate_process_check(instantiate_context, item); | ||||
| if (id == NULL || GS(id->name) != ID_GR) { | if (id == NULL || GS(id->name) != ID_GR) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Collection *collection = (Collection *)id; | Collection *collection = (Collection *)id; | ||||
| bool do_add_collection = (id->tag & LIB_TAG_DOIT) != 0; | bool do_add_collection = (id->tag & LIB_TAG_DOIT) != 0; | ||||
| if (!do_add_collection) { | |||||
| continue; | |||||
| } | |||||
| /* When instantiated into view-layer, do not add collections if one of their parents is also | /* When instantiated into view-layer, do not add collections if one of their parents is also | ||||
| * instantiated. In case of empty-instantiation though, instantiation of all user-selected | * instantiated. */ | ||||
| * collections is the desired behavior. */ | if (!do_instantiate_as_empty && | ||||
| if (!do_add_collection || | loose_data_instantiate_collection_parents_check_recursive(collection)) { | ||||
| (!do_instantiate_as_empty && | continue; | ||||
| loose_data_instantiate_collection_parents_check_recursive(collection))) { | } | ||||
| /* When instantiated as empty, do not add indirectly linked (i.e. non-user-selected) | |||||
| * collections. */ | |||||
| if (do_instantiate_as_empty && (item->tag & LINK_APPEND_TAG_INDIRECT) != 0) { | |||||
| continue; | continue; | ||||
| } | } | ||||
mont29: Think this can be split in two, and then add a third condition, with appropriate comment about… | |||||
Done Inline ActionsAgree, this makes things more readable. Severin: Agree, this makes things more readable. | |||||
| loose_data_instantiate_ensure_active_collection(instantiate_context); | loose_data_instantiate_ensure_active_collection(instantiate_context); | ||||
| Collection *active_collection = instantiate_context->active_collection; | Collection *active_collection = instantiate_context->active_collection; | ||||
| /* In case user requested instantiation of collections as empties, do so for the one they | if (do_instantiate_as_empty) { | ||||
| * explicitly selected (originally directly linked IDs) only. */ | |||||
| if (do_instantiate_as_empty && (item->tag & LINK_APPEND_TAG_INDIRECT) == 0) { | |||||
| /* BKE_object_add(...) messes with the selection. */ | /* BKE_object_add(...) messes with the selection. */ | ||||
Done Inline ActionsThis change is not making logic of the code easier to follow, rather the opposite. Suggest to move that 'skip' case above with the other ones. Then you can just do if (do_instantiate_as_empty) here. mont29: This change is not making logic of the code easier to follow, rather the opposite. Suggest to… | |||||
| Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2); | Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2); | ||||
| ob->type = OB_EMPTY; | ob->type = OB_EMPTY; | ||||
| ob->empty_drawsize = U.collection_instance_empty_size; | ob->empty_drawsize = U.collection_instance_empty_size; | ||||
| const bool set_selected = (lapp_context->params->flag & FILE_AUTOSELECT) != 0; | const bool set_selected = (lapp_context->params->flag & FILE_AUTOSELECT) != 0; | ||||
| /* TODO: why is it OK to make this active here but not in other situations? | /* TODO: why is it OK to make this active here but not in other situations? | ||||
| * See other callers of #object_base_instance_init */ | * See other callers of #object_base_instance_init */ | ||||
| const bool set_active = set_selected; | const bool set_active = set_selected; | ||||
| ▲ Show 20 Lines • Show All 938 Lines • Show Last 20 Lines | |||||
Think this can be split in two, and then add a third condition, with appropriate comment about why. Something like that: