Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 10,255 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (Collection *, collection, &bmain->collections) { | ||||
| if (BKE_collection_has_object(collection, ob)) { | if (BKE_collection_has_object(collection, ob)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | |||||
| * Shared operations to perform on the object's base after adding it to the scene. | |||||
| */ | |||||
| static void object_base_instance_init( | |||||
| Object *ob, bool set_selected, bool set_active, ViewLayer *view_layer, const View3D *v3d) | |||||
| { | |||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | |||||
| if (v3d != NULL) { | |||||
| base->local_view_bits |= v3d->local_view_uuid; | |||||
| } | |||||
| if (set_selected) { | |||||
| if (base->flag & BASE_SELECTABLE) { | |||||
| base->flag |= BASE_SELECTED; | |||||
| } | |||||
| } | |||||
| if (set_active) { | |||||
| view_layer->basact = base; | |||||
| } | |||||
| BKE_scene_object_base_flag_sync_from_base(base); | |||||
| } | |||||
| static void add_loose_objects_to_scene(Main *mainvar, | static void add_loose_objects_to_scene(Main *mainvar, | ||||
| Main *bmain, | Main *bmain, | ||||
| Scene *scene, | Scene *scene, | ||||
| ViewLayer *view_layer, | ViewLayer *view_layer, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| Library *lib, | Library *lib, | ||||
| const short flag) | const short flag) | ||||
| { | { | ||||
| Show All 29 Lines | if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) { | ||||
| active_collection = BKE_collection_add(bmain, scene->master_collection, NULL); | active_collection = BKE_collection_add(bmain, scene->master_collection, NULL); | ||||
| } | } | ||||
| } | } | ||||
| CLAMP_MIN(ob->id.us, 0); | CLAMP_MIN(ob->id.us, 0); | ||||
| ob->mode = OB_MODE_OBJECT; | ob->mode = OB_MODE_OBJECT; | ||||
| BKE_collection_object_add(bmain, active_collection, ob); | BKE_collection_object_add(bmain, active_collection, ob); | ||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | |||||
| if (v3d != NULL) { | |||||
| base->local_view_bits |= v3d->local_view_uuid; | |||||
| } | |||||
| if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) { | |||||
| /* Do NOT make base active here! screws up GUI stuff, | /* Do NOT make base active here! screws up GUI stuff, | ||||
| * if you want it do it at the editor level. */ | * if you want it do it at the editor level. */ | ||||
| base->flag |= BASE_SELECTED; | const bool set_selected = (flag & FILE_AUTOSELECT) != 0; | ||||
| } | const bool set_active = false; | ||||
| object_base_instance_init(ob, set_selected, set_active, view_layer, v3d); | |||||
| BKE_scene_object_base_flag_sync_from_base(base); | DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); | ||||
mont29: This does not seem to be related to the purpose of this patch? Is it actually needed, and why? | |||||
| ob->id.tag &= ~LIB_TAG_INDIRECT; | ob->id.tag &= ~LIB_TAG_INDIRECT; | ||||
| ob->id.flag &= ~LIB_INDIRECT_WEAK_LINK; | ob->id.flag &= ~LIB_INDIRECT_WEAK_LINK; | ||||
| ob->id.tag |= LIB_TAG_EXTERN; | ob->id.tag |= LIB_TAG_EXTERN; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 29 Lines | LISTBASE_FOREACH (ID *, id, lbarray[i]) { | ||||
| const int type = BKE_object_obdata_to_type(id); | const int type = BKE_object_obdata_to_type(id); | ||||
| BLI_assert(type != -1); | BLI_assert(type != -1); | ||||
| Object *ob = BKE_object_add_only_object(bmain, type, id->name + 2); | Object *ob = BKE_object_add_only_object(bmain, type, id->name + 2); | ||||
| ob->data = id; | ob->data = id; | ||||
| id_us_plus(id); | id_us_plus(id); | ||||
| BKE_object_materials_test(bmain, ob, ob->data); | BKE_object_materials_test(bmain, ob, ob->data); | ||||
| BKE_collection_object_add(bmain, active_collection, ob); | BKE_collection_object_add(bmain, active_collection, ob); | ||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | |||||
| if (v3d != NULL) { | |||||
| base->local_view_bits |= v3d->local_view_uuid; | |||||
| } | |||||
| if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) { | const bool set_selected = (flag & FILE_AUTOSELECT) != 0; | ||||
| /* Do NOT make base active here! screws up GUI stuff, | /* Do NOT make base active here! screws up GUI stuff, | ||||
| * if you want it do it at the editor level. */ | * if you want it do it at the editor level. */ | ||||
| base->flag |= BASE_SELECTED; | bool set_active = false; | ||||
| } | object_base_instance_init(ob, set_selected, set_active, view_layer, v3d); | ||||
| BKE_scene_object_base_flag_sync_from_base(base); | |||||
| copy_v3_v3(ob->loc, scene->cursor.location); | copy_v3_v3(ob->loc, scene->cursor.location); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void add_collections_to_scene(Main *mainvar, | static void add_collections_to_scene(Main *mainvar, | ||||
| Show All 17 Lines | if ((flag & FILE_COLLECTION_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) { | ||||
| BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0); | BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0); | ||||
| /* BKE_object_add(...) messes with the selection. */ | /* BKE_object_add(...) messes with the selection. */ | ||||
| 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; | ||||
| BKE_collection_object_add(bmain, active_collection, ob); | BKE_collection_object_add(bmain, active_collection, ob); | ||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | |||||
| if (v3d != NULL) { | |||||
| base->local_view_bits |= v3d->local_view_uuid; | |||||
| } | |||||
| if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) { | const bool set_selected = (flag & FILE_AUTOSELECT) != 0; | ||||
| base->flag |= BASE_SELECTED; | const bool set_active = set_selected; | ||||
| } | object_base_instance_init(ob, set_selected, set_active, view_layer, v3d); | ||||
| BKE_scene_object_base_flag_sync_from_base(base); | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); | DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); | ||||
| if (flag & FILE_AUTOSELECT) { | |||||
| view_layer->basact = base; | |||||
| } | |||||
| /* Assign the collection. */ | /* Assign the collection. */ | ||||
| ob->instance_collection = collection; | ob->instance_collection = collection; | ||||
| id_us_plus(&collection->id); | id_us_plus(&collection->id); | ||||
| ob->transflag |= OB_DUPLICOLLECTION; | ob->transflag |= OB_DUPLICOLLECTION; | ||||
| copy_v3_v3(ob->loc, scene->cursor.location); | copy_v3_v3(ob->loc, scene->cursor.location); | ||||
| } | } | ||||
| /* We do not want to force instantiation of indirectly linked collections, | /* We do not want to force instantiation of indirectly linked collections, | ||||
| * not even when appending. Users can now easily instantiate collections (and their objects) | * not even when appending. Users can now easily instantiate collections (and their objects) | ||||
| ▲ Show 20 Lines • Show All 921 Lines • Show Last 20 Lines | |||||
This does not seem to be related to the purpose of this patch? Is it actually needed, and why?