Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_280.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_genfile.h" | #include "DNA_genfile.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_freestyle.h" | #include "BKE_freestyle.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| #include "readfile.h" | #include "readfile.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| static bScreen *screen_parent_find(const bScreen *screen) | static bScreen *screen_parent_find(const bScreen *screen) | ||||
| { | { | ||||
| /* can avoid lookup if screen state isn't maximized/full (parent and child store the same state) */ | /* can avoid lookup if screen state isn't maximized/full (parent and child store the same state) */ | ||||
| if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) { | if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) { | ||||
| for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| if (sa->full && sa->full != screen) { | if (sa->full && sa->full != screen) { | ||||
| BLI_assert(sa->full->state == screen->state); | BLI_assert(sa->full->state == screen->state); | ||||
| return sa->full; | return sa->full; | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | static void do_version_workspaces_after_lib_link(Main *bmain) | ||||
| for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { | for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { | ||||
| /* Deprecated from now on! */ | /* Deprecated from now on! */ | ||||
| BLI_freelistN(&screen->scene->transform_spaces); | BLI_freelistN(&screen->scene->transform_spaces); | ||||
| screen->scene = NULL; | screen->scene = NULL; | ||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | |||||
| enum { | |||||
| COLLECTION_DEPRECATED_VISIBLE = (1 << 0), | |||||
| COLLECTION_DEPRECATED_VIEWPORT = (1 << 0), | |||||
| COLLECTION_DEPRECATED_SELECTABLE = (1 << 1), | |||||
| COLLECTION_DEPRECATED_DISABLED = (1 << 2), | |||||
| COLLECTION_DEPRECATED_RENDER = (1 << 3), | |||||
| }; | |||||
| static void do_version_view_layer_visibility(ViewLayer *view_layer) | |||||
| { | |||||
| /* Convert from deprecated VISIBLE flag to DISABLED */ | |||||
| LayerCollection *lc; | |||||
| for (lc = view_layer->layer_collections.first; | |||||
| lc; | |||||
| lc = lc->next) | |||||
| { | |||||
| if (lc->flag & COLLECTION_DEPRECATED_DISABLED) { | |||||
| lc->flag &= ~COLLECTION_DEPRECATED_DISABLED; | |||||
| } | |||||
| if ((lc->flag & COLLECTION_DEPRECATED_VISIBLE) == 0) { | |||||
| lc->flag |= COLLECTION_DEPRECATED_DISABLED; | |||||
| } | |||||
| lc->flag |= COLLECTION_DEPRECATED_VIEWPORT | COLLECTION_DEPRECATED_RENDER; | |||||
| } | |||||
| } | |||||
| static void do_version_layer_collection_pre(ViewLayer *view_layer, | |||||
| ListBase *lb, | |||||
| GSet *enabled_set, | |||||
| GSet *selectable_set) | |||||
| { | |||||
| /* Convert from deprecated DISABLED to new layer collection and collection flags */ | |||||
| for (LayerCollection *lc = lb->first; lc; lc = lc->next) { | |||||
| if (lc->scene_collection) { | |||||
| if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) { | |||||
| BLI_gset_insert(enabled_set, lc->scene_collection); | |||||
| } | |||||
| if (lc->flag & COLLECTION_DEPRECATED_SELECTABLE) { | |||||
| BLI_gset_insert(selectable_set, lc->scene_collection); | |||||
| } | |||||
| } | |||||
| do_version_layer_collection_pre(view_layer, &lc->layer_collections, enabled_set, selectable_set); | |||||
| } | |||||
| } | |||||
| static void do_version_layer_collection_post(ViewLayer *view_layer, | |||||
| ListBase *lb, | |||||
| GSet *enabled_set, | |||||
| GSet *selectable_set, | |||||
| GHash *collection_map) | |||||
| { | |||||
| /* Apply layer collection exclude flags. */ | |||||
| for (LayerCollection *lc = lb->first; lc; lc = lc->next) { | |||||
| if (!(lc->collection->flag & COLLECTION_IS_MASTER)) { | |||||
| SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection); | |||||
| const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc)); | |||||
| const bool selectable = (sc && BLI_gset_haskey(selectable_set, sc)); | |||||
| if (!enabled) { | |||||
| lc->flag |= LAYER_COLLECTION_EXCLUDE; | |||||
| } | |||||
| if (enabled && !selectable) { | |||||
| lc->collection->flag |= COLLECTION_RESTRICT_SELECT; | |||||
| } | |||||
| } | |||||
| do_version_layer_collection_post(view_layer, &lc->layer_collections, enabled_set, selectable_set, collection_map); | |||||
| } | |||||
| } | |||||
| static void do_version_scene_collection_convert(Main *bmain, | |||||
| SceneCollection *sc, | |||||
| Collection *collection, | |||||
| GHash *collection_map) | |||||
| { | |||||
| if (collection_map) { | |||||
| BLI_ghash_insert(collection_map, collection, sc); | |||||
| } | |||||
| for (SceneCollection *nsc = sc->scene_collections.first; nsc;) { | |||||
| SceneCollection *nsc_next = nsc->next; | |||||
| Collection *ncollection = BKE_collection_add(bmain, collection, nsc->name); | |||||
| do_version_scene_collection_convert(bmain, nsc, ncollection, collection_map); | |||||
| nsc = nsc_next; | |||||
| } | |||||
| for (LinkData *link = sc->objects.first; link; link = link->next) { | |||||
| Object *ob = link->data; | |||||
| if (ob) { | |||||
| BKE_collection_object_add(bmain, collection, ob); | |||||
| id_us_min(&ob->id); | |||||
| } | |||||
| } | |||||
| BLI_freelistN(&sc->objects); | |||||
| MEM_freeN(sc); | |||||
| } | |||||
| static void do_version_group_collection_to_collection(Main *bmain, Collection *group) | |||||
| { | |||||
| /* Convert old 2.8 group collections to new unified collections. */ | |||||
| if (group->collection) { | |||||
| do_version_scene_collection_convert(bmain, group->collection, group, NULL); | |||||
| } | |||||
| group->collection = NULL; | |||||
| id_fake_user_set(&group->id); | |||||
| } | |||||
| static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene) | |||||
| { | |||||
| /* Convert old 2.8 scene collections to new unified collections. */ | |||||
| /* Temporarily clear view layers so we don't do any layer collection syncing | |||||
| * and destroy old flags that we want to restore. */ | |||||
| ListBase view_layers = scene->view_layers; | |||||
| BLI_listbase_clear(&scene->view_layers); | |||||
| if (!scene->master_collection) { | |||||
| scene->master_collection = BKE_collection_master_add(); | |||||
| } | |||||
| /* Convert scene collections. */ | |||||
| GHash *collection_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); | |||||
| if (scene->collection) { | |||||
| do_version_scene_collection_convert(bmain, scene->collection, scene->master_collection, collection_map); | |||||
| scene->collection = NULL; | |||||
| } | |||||
| scene->view_layers = view_layers; | |||||
| /* Convert layer collections. */ | |||||
| ViewLayer *view_layer; | |||||
| for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | |||||
| GSet *enabled_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); | |||||
| GSet *selectable_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); | |||||
| do_version_layer_collection_pre(view_layer, &view_layer->layer_collections, enabled_set, selectable_set); | |||||
| BKE_layer_collection_sync(scene, view_layer); | |||||
| do_version_layer_collection_post(view_layer, &view_layer->layer_collections, enabled_set, selectable_set, collection_map); | |||||
| BLI_gset_free(enabled_set, NULL); | |||||
| BLI_gset_free(selectable_set, NULL); | |||||
| BKE_layer_collection_sync(scene, view_layer); | |||||
| } | |||||
| BLI_ghash_free(collection_map, NULL, NULL); | |||||
| } | |||||
| #endif | |||||
| enum { | enum { | ||||
| DO_VERSION_COLLECTION_VISIBLE = 0, | DO_VERSION_COLLECTION_VISIBLE = 0, | ||||
| DO_VERSION_COLLECTION_HIDE = 1, | DO_VERSION_COLLECTION_HIDE = 1, | ||||
| DO_VERSION_COLLECTION_HIDE_RENDER = 2, | DO_VERSION_COLLECTION_HIDE_RENDER = 2, | ||||
| DO_VERSION_COLLECTION_HIDE_ALL = 3, | DO_VERSION_COLLECTION_HIDE_ALL = 3, | ||||
| }; | }; | ||||
| void do_versions_after_linking_280(Main *main) | static void do_version_layers_to_collections(Main *bmain, Scene *scene) | ||||
| { | { | ||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | /* Since we don't have access to FileData we check the (always valid) first | ||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | * render layer instead. */ | ||||
| /* since we don't have access to FileData we check the (always valid) first render layer instead */ | if (!scene->master_collection) { | ||||
| if (scene->view_layers.first == NULL) { | scene->master_collection = BKE_collection_master_add(); | ||||
| SceneCollection *sc_master = BKE_collection_master(&scene->id); | } | ||||
| BLI_strncpy(sc_master->name, "Master Collection", sizeof(sc_master->name)); | |||||
| if (scene->view_layers.first) { | |||||
| return; | |||||
| } | |||||
| /* Create collections from layers. */ | |||||
| Collection *collection_master = BKE_collection_master(scene); | |||||
| struct DoVersionSceneCollections { | struct DoVersionSceneCollections { | ||||
| SceneCollection *collections[20]; | Collection *collections[20]; | ||||
| int created; | int created; | ||||
| const char *suffix; | const char *suffix; | ||||
| int flag_viewport; | int flag; | ||||
| int flag_render; | |||||
| } collections[] = | } collections[] = | ||||
| { | { | ||||
| { | { | ||||
| .collections = {NULL}, | .collections = {NULL}, | ||||
| .created = 0, | .created = 0, | ||||
| .suffix = "", | .suffix = "", | ||||
| .flag_viewport = COLLECTION_SELECTABLE, | .flag = 0, | ||||
| .flag_render = COLLECTION_SELECTABLE | |||||
| }, | }, | ||||
| { | { | ||||
| .collections = {NULL}, | .collections = {NULL}, | ||||
| .created = 0, | .created = 0, | ||||
| .suffix = " - Hide Viewport", | .suffix = " - Hide Viewport", | ||||
| .flag_viewport = COLLECTION_SELECTABLE, | .flag = COLLECTION_RESTRICT_VIEW, | ||||
| .flag_render = COLLECTION_SELECTABLE | |||||
| }, | }, | ||||
| { | { | ||||
| .collections = {NULL}, | .collections = {NULL}, | ||||
| .created = 0, | .created = 0, | ||||
| .suffix = " - Hide Render", | .suffix = " - Hide Render", | ||||
| .flag_viewport = COLLECTION_SELECTABLE, | .flag = COLLECTION_RESTRICT_RENDER, | ||||
| .flag_render = COLLECTION_SELECTABLE | COLLECTION_DISABLED | |||||
| }, | }, | ||||
| { | { | ||||
| .collections = {NULL}, | .collections = {NULL}, | ||||
| .created = 0, | .created = 0, | ||||
| .suffix = " - Hide Render All", | .suffix = " - Hide Render All", | ||||
| .flag_viewport = COLLECTION_SELECTABLE | COLLECTION_DISABLED, | .flag = COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER, | ||||
| .flag_render = COLLECTION_SELECTABLE | COLLECTION_DISABLED | |||||
| } | } | ||||
| }; | }; | ||||
| for (int layer = 0; layer < 20; layer++) { | for (int layer = 0; layer < 20; layer++) { | ||||
| for (Base *base = scene->base.first; base; base = base->next) { | for (Base *base = scene->base.first; base; base = base->next) { | ||||
| if (base->lay & (1 << layer)) { | if (base->lay & (1 << layer)) { | ||||
| int collection_index = -1; | int collection_index = -1; | ||||
| if ((base->object->restrictflag & OB_RESTRICT_VIEW) && | if ((base->object->restrictflag & OB_RESTRICT_VIEW) && | ||||
| (base->object->restrictflag & OB_RESTRICT_RENDER)) | (base->object->restrictflag & OB_RESTRICT_RENDER)) | ||||
| { | { | ||||
| collection_index = DO_VERSION_COLLECTION_HIDE_ALL; | collection_index = DO_VERSION_COLLECTION_HIDE_ALL; | ||||
| } | } | ||||
| else if (base->object->restrictflag & OB_RESTRICT_VIEW) { | else if (base->object->restrictflag & OB_RESTRICT_VIEW) { | ||||
| collection_index = DO_VERSION_COLLECTION_HIDE; | collection_index = DO_VERSION_COLLECTION_HIDE; | ||||
| } | } | ||||
| else if (base->object->restrictflag & OB_RESTRICT_RENDER) { | else if (base->object->restrictflag & OB_RESTRICT_RENDER) { | ||||
| collection_index = DO_VERSION_COLLECTION_HIDE_RENDER; | collection_index = DO_VERSION_COLLECTION_HIDE_RENDER; | ||||
| } | } | ||||
| else { | else { | ||||
| collection_index = DO_VERSION_COLLECTION_VISIBLE; | collection_index = DO_VERSION_COLLECTION_VISIBLE; | ||||
| } | } | ||||
| /* Create collections when needed only. */ | /* Create collections when needed only. */ | ||||
| if ((collections[collection_index].created & (1 << layer)) == 0) { | if ((collections[collection_index].created & (1 << layer)) == 0) { | ||||
| char name[MAX_NAME]; | char name[MAX_NAME]; | ||||
| if ((collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) == 0) { | if ((collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) == 0) { | ||||
| BLI_snprintf(name, | BLI_snprintf(name, | ||||
| sizeof(sc_master->name), | sizeof(collection_master->id.name), | ||||
| "Collection %d%s", | "Collection %d%s", | ||||
| layer + 1, | layer + 1, | ||||
| collections[DO_VERSION_COLLECTION_VISIBLE].suffix); | collections[DO_VERSION_COLLECTION_VISIBLE].suffix); | ||||
| collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = | |||||
| BKE_collection_add(&scene->id, sc_master, COLLECTION_TYPE_NONE, name); | Collection *collection = BKE_collection_add(bmain, collection_master, name); | ||||
| collection->flag |= collections[DO_VERSION_COLLECTION_VISIBLE].flag; | |||||
| collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = collection; | |||||
| collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer); | collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer); | ||||
| if (!(scene->lay & (1 << layer))) { | |||||
| collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; | |||||
| } | |||||
| } | } | ||||
| if (collection_index != DO_VERSION_COLLECTION_VISIBLE) { | if (collection_index != DO_VERSION_COLLECTION_VISIBLE) { | ||||
| SceneCollection *sc_parent; | Collection *collection_parent; | ||||
| sc_parent = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; | collection_parent = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; | ||||
| BLI_snprintf(name, | BLI_snprintf(name, | ||||
| sizeof(sc_master->name), | sizeof(collection_master->id.name), | ||||
| "Collection %d%s", | "Collection %d%s", | ||||
| layer + 1, | layer + 1, | ||||
| collections[collection_index].suffix); | collections[collection_index].suffix); | ||||
| collections[collection_index].collections[layer] = BKE_collection_add( | |||||
| &scene->id, | Collection *collection = BKE_collection_add(bmain, collection_parent, name); | ||||
| sc_parent, | collection->flag |= collections[collection_index].flag; | ||||
| COLLECTION_TYPE_NONE, | collections[collection_index].collections[layer] = collection; | ||||
| name); | |||||
| collections[collection_index].created |= (1 << layer); | collections[collection_index].created |= (1 << layer); | ||||
| if (!(scene->lay & (1 << layer))) { | |||||
| collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| BKE_collection_object_add( | /* Note usually this would do slow collection syncing for view layers, | ||||
| &scene->id, collections[collection_index].collections[layer], base->object); | * but since no view layers exists yet at this point it's fast. */ | ||||
| BKE_collection_object_add(bmain, | |||||
| collections[collection_index].collections[layer], base->object); | |||||
| } | } | ||||
| if (base->flag & SELECT) { | if (base->flag & SELECT) { | ||||
| base->object->flag |= SELECT; | base->object->flag |= SELECT; | ||||
| } | } | ||||
| else { | else { | ||||
| base->object->flag &= ~SELECT; | base->object->flag &= ~SELECT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Re-order the nested hidden collections. */ | /* Re-order the nested hidden collections. */ | ||||
| SceneCollection *scene_collection_parent = sc_master->scene_collections.first; | CollectionChild *child_parent = collection_master->children.first; | ||||
| Collection *collection_parent = (child_parent) ? child_parent->collection : NULL; | |||||
| for (int layer = 0; layer < 20; layer++) { | for (int layer = 0; layer < 20; layer++) { | ||||
| if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { | if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { | ||||
| CollectionChild *hide_child = BLI_findptr(&collection_parent->children, collections[DO_VERSION_COLLECTION_HIDE].collections[layer], offsetof(CollectionChild, collection)); | |||||
| if ((collections[DO_VERSION_COLLECTION_HIDE].created & (1 << layer)) && | if ((collections[DO_VERSION_COLLECTION_HIDE].created & (1 << layer)) && | ||||
| (collections[DO_VERSION_COLLECTION_HIDE].collections[layer] != | (hide_child != collection_parent->children.first)) | ||||
| scene_collection_parent->scene_collections.first)) | |||||
| { | { | ||||
| BLI_listbase_swaplinks( | BLI_listbase_swaplinks( | ||||
| &scene_collection_parent->scene_collections, | &collection_parent->children, | ||||
| collections[DO_VERSION_COLLECTION_HIDE].collections[layer], | hide_child, | ||||
| scene_collection_parent->scene_collections.first); | collection_parent->children.first); | ||||
| } | } | ||||
| CollectionChild *hide_all_child = BLI_findptr(&collection_parent->children, collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer], offsetof(CollectionChild, collection)); | |||||
| if ((collections[DO_VERSION_COLLECTION_HIDE_ALL].created & (1 << layer)) && | if ((collections[DO_VERSION_COLLECTION_HIDE_ALL].created & (1 << layer)) && | ||||
| (collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer] != | (hide_all_child != collection_parent->children.last)) | ||||
| scene_collection_parent->scene_collections.last)) | |||||
| { | { | ||||
| BLI_listbase_swaplinks( | BLI_listbase_swaplinks( | ||||
| &scene_collection_parent->scene_collections, | &collection_parent->children, | ||||
| collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer], | hide_all_child, | ||||
| scene_collection_parent->scene_collections.last); | collection_parent->children.last); | ||||
| } | } | ||||
| scene_collection_parent = scene_collection_parent->next; | child_parent = child_parent->next; | ||||
| collection_parent = (child_parent) ? child_parent->collection : NULL; | |||||
| } | } | ||||
| } | } | ||||
| BLI_assert(scene_collection_parent == NULL); | BLI_assert(collection_parent == NULL); | ||||
| /* Handle legacy render layers. */ | /* Handle legacy render layers. */ | ||||
| { | bool have_override = false; | ||||
| for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) { | |||||
| for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) { | |||||
| ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name); | ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name); | ||||
| if (srl->samples != 0) { | if (srl->samples != 0) { | ||||
| have_override = true; | |||||
| /* It is up to the external engine to handle | /* It is up to the external engine to handle | ||||
| * its own doversion in this case. */ | * its own doversion in this case. */ | ||||
| BKE_override_view_layer_int_add( | BKE_override_view_layer_int_add( | ||||
| view_layer, | view_layer, | ||||
| ID_SCE, | ID_SCE, | ||||
| "samples", | "samples", | ||||
| srl->samples); | srl->samples); | ||||
| } | } | ||||
| if (srl->mat_override) { | if (srl->mat_override) { | ||||
| have_override = true; | |||||
| BKE_override_view_layer_datablock_add( | BKE_override_view_layer_datablock_add( | ||||
| view_layer, | view_layer, | ||||
| ID_MA, | ID_MA, | ||||
| "self", | "self", | ||||
| (ID *)srl->mat_override); | (ID *)srl->mat_override); | ||||
| } | } | ||||
| if (srl->layflag & SCE_LAY_DISABLE) { | if (srl->layflag & SCE_LAY_DISABLE) { | ||||
| view_layer->flag &= ~VIEW_LAYER_RENDER; | view_layer->flag &= ~VIEW_LAYER_RENDER; | ||||
| } | } | ||||
| if ((srl->layflag & SCE_LAY_FRS) == 0) { | if ((srl->layflag & SCE_LAY_FRS) == 0) { | ||||
| view_layer->flag &= ~VIEW_LAYER_FREESTYLE; | view_layer->flag &= ~VIEW_LAYER_FREESTYLE; | ||||
| } | } | ||||
| /* XXX If we are to keep layflag it should be merged with flag (dfelinto). */ | /* XXX If we are to keep layflag it should be merged with flag (dfelinto). */ | ||||
| view_layer->layflag = srl->layflag; | view_layer->layflag = srl->layflag; | ||||
| /* XXX Not sure if we should keep the passes (dfelinto). */ | /* XXX Not sure if we should keep the passes (dfelinto). */ | ||||
| view_layer->passflag = srl->passflag; | view_layer->passflag = srl->passflag; | ||||
| view_layer->pass_xor = srl->pass_xor; | view_layer->pass_xor = srl->pass_xor; | ||||
| view_layer->pass_alpha_threshold = srl->pass_alpha_threshold; | view_layer->pass_alpha_threshold = srl->pass_alpha_threshold; | ||||
| BKE_freestyle_config_free(&view_layer->freestyle_config, true); | BKE_freestyle_config_free(&view_layer->freestyle_config, true); | ||||
| view_layer->freestyle_config = srl->freestyleConfig; | view_layer->freestyle_config = srl->freestyleConfig; | ||||
| view_layer->id_properties = srl->prop; | view_layer->id_properties = srl->prop; | ||||
| /* unlink master collection */ | /* Set exclusion and overrides. */ | ||||
| BKE_collection_unlink(view_layer, view_layer->layer_collections.first); | |||||
| /* Add new collection bases. */ | |||||
| for (int layer = 0; layer < 20; layer++) { | for (int layer = 0; layer < 20; layer++) { | ||||
| if ((scene->lay & srl->lay & ~(srl->lay_exclude) & (1 << layer)) || | |||||
| (srl->lay_zmask & (scene->lay | srl->lay_exclude) & (1 << layer))) | |||||
| { | |||||
| if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { | if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { | ||||
| Collection *collection = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; | |||||
| LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer, collection); | |||||
| LayerCollection *layer_collection_parent; | if (srl->lay_exclude & (1 << layer)) { | ||||
| layer_collection_parent = BKE_collection_link( | /* Disable excluded layer. */ | ||||
| view_layer, | have_override = true; | ||||
| collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]); | lc->flag |= LAYER_COLLECTION_EXCLUDE; | ||||
| for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) { | |||||
| nlc->flag |= LAYER_COLLECTION_EXCLUDE; | |||||
| } | |||||
| } | |||||
| else if ((scene->lay & srl->lay & ~(srl->lay_exclude) & (1 << layer)) || | |||||
| (srl->lay_zmask & (scene->lay | srl->lay_exclude) & (1 << layer))) | |||||
| { | |||||
| if (srl->lay_zmask & (1 << layer)) { | if (srl->lay_zmask & (1 << layer)) { | ||||
| have_override = true; | |||||
| BKE_override_layer_collection_boolean_add( | BKE_override_layer_collection_boolean_add( | ||||
| layer_collection_parent, | lc, | ||||
| ID_OB, | ID_OB, | ||||
| "cycles.is_holdout", | "cycles.is_holdout", | ||||
| true); | true); | ||||
| } | } | ||||
| if ((srl->lay & (1 << layer)) == 0) { | if ((srl->lay & (1 << layer)) == 0) { | ||||
| have_override = true; | |||||
| BKE_override_layer_collection_boolean_add( | BKE_override_layer_collection_boolean_add( | ||||
| layer_collection_parent, | lc, | ||||
| ID_OB, | ID_OB, | ||||
| "cycles_visibility.camera", | "cycles_visibility.camera", | ||||
| false); | false); | ||||
| } | } | ||||
| } | |||||
| LayerCollection *layer_collection_child; | LayerCollection *nlc = lc->layer_collections.first; | ||||
| layer_collection_child = layer_collection_parent->layer_collections.first; | |||||
| for (int j = 1; j < 4; j++) { | for (int j = 1; j < 4; j++) { | ||||
| if (collections[j].created & (1 << layer)) { | if (collections[j].created & (1 << layer)) { | ||||
| layer_collection_child->flag = COLLECTION_VIEWPORT | | nlc = nlc->next; | ||||
| COLLECTION_RENDER | | |||||
| collections[j].flag_render; | |||||
| layer_collection_child = layer_collection_child->next; | |||||
| } | |||||
| } | } | ||||
| BLI_assert(layer_collection_child == NULL); | |||||
| } | } | ||||
| BLI_assert(nlc == NULL); | |||||
| } | } | ||||
| } | } | ||||
| /* for convenience set the same active object in all the layers */ | /* for convenience set the same active object in all the layers */ | ||||
| if (scene->basact) { | if (scene->basact) { | ||||
| view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object); | view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object); | ||||
| } | } | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | for (Base *base = view_layer->object_bases.first; base; base = base->next) { | ||||
| if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { | if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| BLI_freelistN(&scene->r.layers); | BLI_freelistN(&scene->r.layers); | ||||
| /* If render layers included overrides, we also create a vanilla | |||||
| * viewport layer without them. */ | |||||
| if (have_override) { | |||||
| ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport"); | ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport"); | ||||
| /* Make it first in the list. */ | |||||
| BLI_remlink(&scene->view_layers, view_layer); | |||||
| BLI_addhead(&scene->view_layers, view_layer); | |||||
| /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */ | /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */ | ||||
| if (!BLI_listbase_is_single(&scene->view_layers)) { | if (!BLI_listbase_is_single(&scene->view_layers)) { | ||||
| view_layer->flag &= ~VIEW_LAYER_RENDER; | view_layer->flag &= ~VIEW_LAYER_RENDER; | ||||
| } | } | ||||
| /* If layer was not set, disable it. */ | |||||
| LayerCollection *layer_collection_parent; | |||||
| layer_collection_parent = | |||||
| ((LayerCollection *)view_layer->layer_collections.first)->layer_collections.first; | |||||
| for (int layer = 0; layer < 20; layer++) { | |||||
| if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { | |||||
| const bool is_disabled = (scene->lay & (1 << layer)) == 0; | |||||
| /* We only need to disable the parent collection. */ | |||||
| if (is_disabled) { | |||||
| layer_collection_parent->flag |= COLLECTION_DISABLED; | |||||
| } | |||||
| LayerCollection *layer_collection_child; | |||||
| layer_collection_child = layer_collection_parent->layer_collections.first; | |||||
| for (int j = 1; j < 4; j++) { | |||||
| if (collections[j].created & (1 << layer)) { | |||||
| layer_collection_child->flag = COLLECTION_VIEWPORT | | |||||
| COLLECTION_RENDER | | |||||
| collections[j].flag_viewport; | |||||
| layer_collection_child = layer_collection_child->next; | |||||
| } | |||||
| } | |||||
| BLI_assert(layer_collection_child == NULL); | |||||
| layer_collection_parent = layer_collection_parent->next; | |||||
| } | |||||
| } | |||||
| BLI_assert(layer_collection_parent == NULL); | |||||
| /* convert active base */ | /* convert active base */ | ||||
| if (scene->basact) { | if (scene->basact) { | ||||
| view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object); | view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object); | ||||
| } | } | ||||
| /* convert selected bases */ | /* convert selected bases */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | for (Base *base = view_layer->object_bases.first; base; base = base->next) { | ||||
| if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { | if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| /* keep lay around for forward compatibility (open those files in 2.79) */ | /* keep lay around for forward compatibility (open those files in 2.79) */ | ||||
| base->lay = base->object->lay; | base->lay = base->object->lay; | ||||
| } | } | ||||
| } | |||||
| /* remove bases once and for all */ | /* remove bases once and for all */ | ||||
| for (Base *base = scene->base.first; base; base = base->next) { | for (Base *base = scene->base.first; base; base = base->next) { | ||||
| id_us_min(&base->object->id); | id_us_min(&base->object->id); | ||||
| } | } | ||||
| BLI_freelistN(&scene->base); | BLI_freelistN(&scene->base); | ||||
| scene->basact = NULL; | scene->basact = NULL; | ||||
| } | } | ||||
| void do_versions_after_linking_280(Main *main) | |||||
| { | |||||
| bool use_collection_compat_28 = true; | |||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | |||||
| use_collection_compat_28 = false; | |||||
| /* Convert group layer visibility flags to hidden nested collection. */ | |||||
| for (Collection *collection = main->collection.first; collection; collection = collection->id.next) { | |||||
| Collection *collection_hidden = NULL; | |||||
| if (collection->flag & (COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER)) { | |||||
| continue; | |||||
| } | |||||
| for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) { | |||||
| cob_next = cob->next; | |||||
| Object *ob = cob->ob; | |||||
| if (!(ob->lay & collection->layer)) { | |||||
| if (collection_hidden == NULL) { | |||||
| collection_hidden = BKE_collection_add(main, collection, "Hidden"); | |||||
| collection_hidden->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; | |||||
| } | |||||
| BKE_collection_object_add(main, collection_hidden, ob); | |||||
| BKE_collection_object_remove(main, collection, ob, true); | |||||
| } | |||||
| } | |||||
| /* Add fake user for all existing groups. */ | |||||
| id_fake_user_set(&collection->id); | |||||
| } | |||||
| /* Convert layers to collections. */ | |||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | |||||
| do_version_layers_to_collections(main, scene); | |||||
| } | } | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | ||||
| for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { | for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { | ||||
| /* same render-layer as do_version_workspaces_after_lib_link will activate, | /* same render-layer as do_version_workspaces_after_lib_link will activate, | ||||
| * so same layer as BKE_view_layer_from_workspace_get would return */ | * so same layer as BKE_view_layer_from_workspace_get would return */ | ||||
| ViewLayer *layer = screen->scene->view_layers.first; | ViewLayer *layer = screen->scene->view_layers.first; | ||||
| for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| for (SpaceLink *view_layer = sa->spacedata.first; view_layer; view_layer = view_layer->next) { | for (SpaceLink *space = sa->spacedata.first; space; space = space->next) { | ||||
| if (view_layer->spacetype == SPACE_OUTLINER) { | if (space->spacetype == SPACE_OUTLINER) { | ||||
| SpaceOops *soutliner = (SpaceOops *)view_layer; | SpaceOops *soutliner = (SpaceOops *)space; | ||||
| soutliner->outlinevis = SO_COLLECTIONS; | soutliner->outlinevis = SO_COLLECTIONS; | ||||
| if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) { | if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) { | ||||
| if (soutliner->treestore == NULL) { | if (soutliner->treestore == NULL) { | ||||
| soutliner->treestore = BLI_mempool_create( | soutliner->treestore = BLI_mempool_create( | ||||
| sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); | sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); | ||||
| } | } | ||||
| Show All 40 Lines | for (Object *object = main->object.first; object; object = object->id.next) { | ||||
| for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) { | for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) { | ||||
| if (psys->part->draw_size == 0.0f) { | if (psys->part->draw_size == 0.0f) { | ||||
| psys->part->draw_size = 0.1f; | psys->part->draw_size = 0.1f; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| { | if (!MAIN_VERSION_ATLEAST(main, 280, 4)) { | ||||
| for (WorkSpace *workspace = main->workspaces.first; workspace; workspace = workspace->id.next) { | for (WorkSpace *workspace = main->workspaces.first; workspace; workspace = workspace->id.next) { | ||||
| if (workspace->view_layer) { | if (workspace->view_layer) { | ||||
| /* During 2.8 work we temporarly stored view-layer in the | /* During 2.8 work we temporarly stored view-layer in the | ||||
| * workspace directly, but should be stored there per-scene. */ | * workspace directly, but should be stored there per-scene. */ | ||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | ||||
| if (BLI_findindex(&scene->view_layers, workspace->view_layer) != -1) { | if (BLI_findindex(&scene->view_layers, workspace->view_layer) != -1) { | ||||
| BKE_workspace_view_layer_set(workspace, workspace->view_layer, scene); | BKE_workspace_view_layer_set(workspace, workspace->view_layer, scene); | ||||
| workspace->view_layer = NULL; | workspace->view_layer = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* While this should apply to most cases, it fails when reading workspaces.blend | /* While this should apply to most cases, it fails when reading workspaces.blend | ||||
| * to get its list of workspaces without actually appending any of them. */ | * to get its list of workspaces without actually appending any of them. */ | ||||
| // BLI_assert(workspace->view_layer == NULL); | // BLI_assert(workspace->view_layer == NULL); | ||||
| } | } | ||||
| } | } | ||||
| { | if (!MAIN_VERSION_ATLEAST(main, 280, 4)) { | ||||
| /* Since we don't have access to FileData we check the (always valid) master collection of the group. */ | |||||
| for (Group *group = main->group.first; group; group = group->id.next) { | |||||
| if (group->collection == NULL) { | |||||
| BKE_group_init(group); | |||||
| SceneCollection *sc = GROUP_MASTER_COLLECTION(group); | |||||
| SceneCollection *sc_hidden = NULL; | |||||
| for (GroupObject *go = group->gobject.first; go; go = go->next) { | |||||
| if (go->ob->lay & group->layer) { | |||||
| BKE_collection_object_add(&group->id, sc, go->ob); | |||||
| } | |||||
| else { | |||||
| if (sc_hidden == NULL) { | |||||
| sc_hidden = BKE_collection_add(&group->id, sc, COLLECTION_TYPE_GROUP_INTERNAL, "Hidden"); | |||||
| } | |||||
| BKE_collection_object_add(&group->id, sc_hidden, go->ob); | |||||
| } | |||||
| } | |||||
| if (sc_hidden != NULL) { | |||||
| LayerCollection *layer_collection_master, *layer_collection_hidden; | |||||
| layer_collection_master = group->view_layer->layer_collections.first; | |||||
| layer_collection_hidden = layer_collection_master->layer_collections.first; | |||||
| layer_collection_hidden->flag |= COLLECTION_DISABLED; | |||||
| } | |||||
| } | |||||
| GroupObject *go; | |||||
| while ((go = BLI_pophead(&group->gobject))) { | |||||
| MEM_freeN(go); | |||||
| } | |||||
| } | |||||
| } | |||||
| { | |||||
| for (Object *object = main->object.first; object; object = object->id.next) { | for (Object *object = main->object.first; object; object = object->id.next) { | ||||
| #ifndef VERSION_280_SUBVERSION_4 | #ifndef VERSION_280_SUBVERSION_4 | ||||
| /* If any object already has an initialized value for | /* If any object already has an initialized value for | ||||
| * duplicator_visibility_flag it means we've already doversioned it. | * duplicator_visibility_flag it means we've already doversioned it. | ||||
| * TODO(all) remove the VERSION_280_SUBVERSION_4 code once the subversion was bumped. */ | * TODO(all) remove the VERSION_280_SUBVERSION_4 code once the subversion was bumped. */ | ||||
| if (object->duplicator_visibility_flag != 0) { | if (object->duplicator_visibility_flag != 0) { | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (scene != NULL) { | ||||
| /* Don't forget to unset! */ | /* Don't forget to unset! */ | ||||
| area->butspacetype = SPACE_EMPTY; | area->butspacetype = SPACE_EMPTY; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void do_version_view_layer_visibility(ViewLayer *view_layer) | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| { | if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(main, 280, 14)) { | ||||
| LayerCollection *layer_collection; | for (Collection *group = main->collection.first; group; group = group->id.next) { | ||||
| for (layer_collection = view_layer->layer_collections.first; | do_version_group_collection_to_collection(main, group); | ||||
| layer_collection; | |||||
| layer_collection = layer_collection->next) | |||||
| { | |||||
| if (layer_collection->flag & COLLECTION_DISABLED) { | |||||
| BKE_collection_enable(view_layer, layer_collection); | |||||
| layer_collection->flag &= ~COLLECTION_DISABLED; | |||||
| } | } | ||||
| if ((layer_collection->flag & (1 << 0)) == 0) { /* !COLLECTION_VISIBLE */ | for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | ||||
| layer_collection->flag |= COLLECTION_DISABLED; | do_version_scene_collection_to_collection(main, scene); | ||||
| } | } | ||||
| layer_collection->flag |= COLLECTION_VIEWPORT | COLLECTION_RENDER; | |||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) | void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) | ||||
| { | { | ||||
| bool use_collection_compat_28 = true; | |||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | if (!MAIN_VERSION_ATLEAST(main, 280, 0)) { | ||||
| if (!DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) { | use_collection_compat_28 = false; | ||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | |||||
| /* Master Collection */ | |||||
| scene->collection = MEM_callocN(sizeof(SceneCollection), "Master Collection"); | |||||
| BLI_strncpy(scene->collection->name, "Master Collection", sizeof(scene->collection->name)); | |||||
| } | |||||
| } | |||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | ||||
| scene->r.gauss = 1.5f; | scene->r.gauss = 1.5f; | ||||
| } | } | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 1)) { | if (!MAIN_VERSION_ATLEAST(main, 280, 1)) { | ||||
| if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) { | if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) { | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | if (error & NTREE_DOVERSION_NEED_OUTPUT) { | ||||
| printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n"); | printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n"); | ||||
| } | } | ||||
| if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { | if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { | ||||
| BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | ||||
| printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n"); | printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n"); | ||||
| } | } | ||||
| if ((DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) && | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| if (use_collection_compat_28 && | |||||
| (DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) && | |||||
| DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) | DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) | ||||
| { | { | ||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | ||||
| ViewLayer *view_layer; | ViewLayer *view_layer; | ||||
| for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| view_layer->flag |= VIEW_LAYER_FREESTYLE; | view_layer->flag |= VIEW_LAYER_FREESTYLE; | ||||
| view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */ | view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */ | ||||
| view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z; | view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z; | ||||
| view_layer->pass_alpha_threshold = 0.5f; | view_layer->pass_alpha_threshold = 0.5f; | ||||
| BKE_freestyle_config_init(&view_layer->freestyle_config); | BKE_freestyle_config_init(&view_layer->freestyle_config); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 3)) { | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(main, 280, 3)) { | |||||
| for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { | ||||
| ViewLayer *view_layer; | ViewLayer *view_layer; | ||||
| for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| do_version_view_layer_visibility(view_layer); | do_version_view_layer_visibility(view_layer); | ||||
| } | } | ||||
| } | } | ||||
| for (Group *group = main->group.first; group; group = group->id.next) { | for (Collection *group = main->collection.first; group; group = group->id.next) { | ||||
| if (group->view_layer != NULL) { | if (group->view_layer != NULL) { | ||||
| do_version_view_layer_visibility(group->view_layer); | do_version_view_layer_visibility(group->view_layer); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| if (!MAIN_VERSION_ATLEAST(main, 280, 6)) { | if (!MAIN_VERSION_ATLEAST(main, 280, 6)) { | ||||
| if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) { | if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) { | ||||
| bScreen *sc; | bScreen *sc; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| SpaceLink *sl; | SpaceLink *sl; | ||||
| /* Update files using invalid (outdated) outlinevis Outliner values. */ | /* Update files using invalid (outdated) outlinevis Outliner values. */ | ||||
| for (sc = main->screen.first; sc; sc = sc->id.next) { | for (sc = main->screen.first; sc; sc = sc->id.next) { | ||||
| for (sa = sc->areabase.first; sa; sa = sa->next) { | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| for (sl = sa->spacedata.first; sl; sl = sl->next) { | for (sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| if (sl->spacetype == SPACE_OUTLINER) { | if (sl->spacetype == SPACE_OUTLINER) { | ||||
| SpaceOops *so = (SpaceOops *)sl; | SpaceOops *so = (SpaceOops *)sl; | ||||
| if (!ELEM(so->outlinevis, | if (!ELEM(so->outlinevis, | ||||
| SO_SCENES, | SO_SCENES, | ||||
| SO_GROUPS, | |||||
| SO_LIBRARIES, | SO_LIBRARIES, | ||||
| SO_SEQUENCE, | SO_SEQUENCE, | ||||
| SO_DATABLOCKS, | SO_DATABLOCKS, | ||||
| SO_ID_ORPHANS, | SO_ID_ORPHANS, | ||||
| SO_COLLECTIONS)) | SO_COLLECTIONS)) | ||||
| { | { | ||||
| so->outlinevis = SO_COLLECTIONS; | so->outlinevis = SO_COLLECTIONS; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||