Cleanup: code style
[blender.git] / source / blender / blenloader / intern / versioning_280.c
index ffc078c30610b2f1a7ef2b63bc59663ed1ed237f..e7d4e4f33aea0e48932a15b3ff06f79061842d12 100644 (file)
@@ -60,6 +60,7 @@
 #include "BKE_customdata.h"
 #include "BKE_freestyle.h"
 #include "BKE_idprop.h"
+#include "BKE_image.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
@@ -67,6 +68,7 @@
 #include "BKE_report.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
+#include "BKE_studiolight.h"
 #include "BKE_workspace.h"
 
 #include "BLO_readfile.h"
@@ -96,6 +98,9 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
                Scene *scene = screen->scene;
                WorkSpace *workspace;
                ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
+               if (screen->temp) {
+                       continue;
+               }
                if (!layer) {
                        layer = BKE_view_layer_default_view(scene);
                }
@@ -109,7 +114,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
                else {
                        workspace = BKE_workspace_add(bmain, screen->id.name + 2);
                }
-               BKE_workspace_layout_add(workspace, screen, screen->id.name + 2);
+               BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
                BKE_workspace_view_layer_set(workspace, layer, scene);
        }
 }
@@ -671,15 +676,15 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
        scene->basact = NULL;
 }
 
-void do_versions_after_linking_280(Main *main)
+void do_versions_after_linking_280(Main *bmain)
 {
        bool use_collection_compat_28 = true;
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 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) {
+               for (Collection *collection = bmain->collection.first; collection; collection = collection->id.next) {
                        /* Add fake user for all existing groups. */
                        id_fake_user_set(&collection->id);
 
@@ -694,25 +699,25 @@ void do_versions_after_linking_280(Main *main)
 
                                if (!(ob->lay & collection->layer)) {
                                        if (collection_hidden == NULL) {
-                                               collection_hidden = BKE_collection_add(main, collection, "Hidden");
+                                               collection_hidden = BKE_collection_add(bmain, collection, "Hidden");
                                                collection_hidden->id.lib = collection->id.lib;
                                                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);
+                                       BKE_collection_object_add(bmain, collection_hidden, ob);
+                                       BKE_collection_object_remove(bmain, collection, ob, true);
                                }
                        }
                }
 
                /* Convert layers to collections. */
-               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
-                       do_version_layers_to_collections(main, scene);
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+                       do_version_layers_to_collections(bmain, scene);
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
-               for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                        /* same render-layer as do_version_workspaces_after_lib_link will activate,
                         * so same layer as BKE_view_layer_from_workspace_get would return */
                        ViewLayer *layer = screen->scene->view_layers.first;
@@ -746,14 +751,14 @@ void do_versions_after_linking_280(Main *main)
        }
 
        /* New workspace design */
-       if (!MAIN_VERSION_ATLEAST(main, 280, 1)) {
-               do_version_workspaces_after_lib_link(main);
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
+               do_version_workspaces_after_lib_link(bmain);
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
                /* Cleanup any remaining SceneRenderLayer data for files that were created
                 * with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
-               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                        for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
                                if (srl->prop) {
                                        IDP_FreeProperty(srl->prop);
@@ -765,10 +770,10 @@ void do_versions_after_linking_280(Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 3)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
                /* Due to several changes to particle RNA and draw code particles from older files may no longer
                 * be visible. Here we correct this by setting a default draw size for those files. */
-               for (Object *object = main->object.first; object; object = object->id.next) {
+               for (Object *object = bmain->object.first; object; object = object->id.next) {
                        for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
                                if (psys->part->draw_size == 0.0f) {
                                        psys->part->draw_size = 0.1f;
@@ -777,8 +782,8 @@ void do_versions_after_linking_280(Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 4)) {
-               for (Object *object = main->object.first; object; object = object->id.next) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
+               for (Object *object = bmain->object.first; object; object = object->id.next) {
 #ifndef VERSION_280_SUBVERSION_4
                        /* If any object already has an initialized value for
                         * duplicator_visibility_flag it means we've already doversioned it.
@@ -810,9 +815,9 @@ void do_versions_after_linking_280(Main *main)
        }
 
        /* SpaceTime & SpaceLogic removal/replacing */
-       if (!MAIN_VERSION_ATLEAST(main, 280, 9)) {
-               const wmWindowManager *wm = main->wm.first;
-               const Scene *scene = main->scene.first;
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 9)) {
+               const wmWindowManager *wm = bmain->wm.first;
+               const Scene *scene = bmain->scene.first;
 
                if (wm != NULL) {
                        /* Action editors need a scene for creation. First, update active
@@ -832,7 +837,7 @@ void do_versions_after_linking_280(Main *main)
                        }
                }
                if (scene != NULL) {
-                       for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                                for (ScrArea *area = screen->areabase.first; area; area = area->next) {
                                        if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
                                                /* Areas that were already handled won't be handled again */
@@ -847,39 +852,39 @@ void do_versions_after_linking_280(Main *main)
        }
 
 #ifdef USE_COLLECTION_COMPAT_28
-       if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(main, 280, 14)) {
-               for (Collection *group = main->collection.first; group; group = group->id.next) {
-                       do_version_group_collection_to_collection(main, group);
+       if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
+               for (Collection *group = bmain->collection.first; group; group = group->id.next) {
+                       do_version_group_collection_to_collection(bmain, group);
                }
 
-               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
-                       do_version_scene_collection_to_collection(main, scene);
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+                       do_version_scene_collection_to_collection(bmain, scene);
                }
        }
 #endif
 }
 
-void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
+void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 {
        bool use_collection_compat_28 = true;
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
                use_collection_compat_28 = false;
 
-               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                        scene->r.gauss = 1.5f;
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 1)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
                if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) {
-                       for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+                       for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
                                la->bleedexp = 2.5f;
                        }
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
-                       for (Camera *ca = main->camera.first; ca; ca = ca->id.next) {
+                       for (Camera *ca = bmain->camera.first; ca; ca = ca->id.next) {
                                ca->gpu_dof.ratio = 1.0f;
                        }
                }
@@ -887,7 +892,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                /* MTexPoly now removed. */
                if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
                        const int cd_mtexpoly = 15;  /* CD_MTEXPOLY, deprecated */
-                       for (Mesh *me = main->mesh.first; me; me = me->id.next) {
+                       for (Mesh *me = bmain->mesh.first; me; me = me->id.next) {
                                /* If we have UV's, so this file will have MTexPoly layers too! */
                                if (me->mloopuv != NULL) {
                                        CustomData_update_typemap(&me->pdata);
@@ -898,9 +903,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
                if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) {
-                       for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+                       for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
                                la->cascade_max_dist = 1000.0f;
                                la->cascade_count = 4;
                                la->cascade_exponent = 0.8f;
@@ -909,7 +914,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) {
-                       for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+                       for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
                                la->contact_dist = 1.0f;
                                la->contact_bias = 0.03f;
                                la->contact_spread = 0.2f;
@@ -918,7 +923,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "vis_bias")) {
-                       for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) {
+                       for (LightProbe *probe = bmain->lightprobe.first; probe; probe = probe->id.next) {
                                probe->vis_bias = 1.0f;
                                probe->vis_blur = 0.2f;
                        }
@@ -937,7 +942,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                 * Also, metallic node is now unified into the principled node. */
                eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
 
-               FOREACH_NODETREE(main, ntree, id) {
+               FOREACH_NODETREE(bmain, ntree, id) {
                        if (ntree->type == NTREE_SHADER) {
                                for (bNode *node = ntree->nodes.first; node; node = node->next) {
                                        if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
@@ -986,7 +991,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                    (DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) &&
                    DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers"))
                {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                ViewLayer *view_layer;
                                for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
                                        view_layer->flag |= VIEW_LAYER_FREESTYLE;
@@ -1001,15 +1006,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
        }
 
 #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) {
+       if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                        ViewLayer *view_layer;
                        for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
                                do_version_view_layer_visibility(view_layer);
                        }
                }
 
-               for (Collection *group = main->collection.first; group; group = group->id.next) {
+               for (Collection *group = bmain->collection.first; group; group = group->id.next) {
                        if (group->view_layer != NULL) {
                                do_version_view_layer_visibility(group->view_layer);
                        }
@@ -1017,14 +1022,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
        }
 #endif
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 6)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
                if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) {
                        bScreen *sc;
                        ScrArea *sa;
                        SpaceLink *sl;
 
                        /* Update files using invalid (outdated) outlinevis Outliner values. */
-                       for (sc = main->screen.first; sc; sc = sc->id.next) {
+                       for (sc = bmain->screen.first; sc; sc = sc->id.next) {
                                for (sa = sc->areabase.first; sa; sa = sa->next) {
                                        for (sl = sa->spacedata.first; sl; sl = sl->next) {
                                                if (sl->spacetype == SPACE_OUTLINER) {
@@ -1046,12 +1051,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
-                       for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) {
+                       for (LightProbe *probe = bmain->lightprobe.first; probe; probe = probe->id.next) {
                                probe->intensity = 1.0f;
                        }
                }
 
-               for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+               for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
                        bConstraint *con, *con_next;
                        con = ob->constraints.first;
                        while (con) {
@@ -1066,12 +1071,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "Scene", "int", "orientation_index_custom")) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                scene->orientation_index_custom = -1;
                        }
                }
 
-               for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+               for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
                        for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
                                for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                        if (sl->spacetype == SPACE_VIEW3D) {
@@ -1081,7 +1086,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 
                                                /* Assume (demo) files written with 2.8 want to show
                                                 * Eevee renders in the viewport. */
-                                               if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
+                                               if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
                                                        v3d->drawtype = OB_MATERIAL;
                                                }
                                        }
@@ -1090,20 +1095,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 7)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 7)) {
                /* Render engine storage moved elsewhere and back during 2.8
                 * development, we assume any files saved in 2.8 had Eevee set
                 * as scene render engine. */
-               if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+               if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
                        }
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 8)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
                /* Blender Internal removal */
-               for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                        if (STREQ(scene->r.engine, "BLENDER_RENDER") ||
                            STREQ(scene->r.engine, "BLENDER_GAME"))
                        {
@@ -1113,7 +1118,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                        scene->r.bake_mode = 0;
                }
 
-               for (Tex *tex = main->tex.first; tex; tex = tex->id.next) {
+               for (Tex *tex = bmain->tex.first; tex; tex = tex->id.next) {
                        /* Removed envmap, pointdensity, voxeldata, ocean textures. */
                        if (ELEM(tex->type, 10, 14, 15, 16)) {
                                tex->type = 0;
@@ -1121,10 +1126,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 11)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
 
                /* Remove info editor, but only if at the top of the window. */
-               for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                        /* Calculate window width/height from screen vertices */
                        int win_width = 0, win_height = 0;
                        for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
@@ -1154,8 +1159,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 11)) {
-               for (Lamp *lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
+               for (Lamp *lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
                        if (lamp->mode & (1 << 13)) { /* LA_SHAD_RAY */
                                lamp->mode |= LA_SHADOW;
                                lamp->mode &= ~(1 << 13);
@@ -1163,9 +1168,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 12)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
                /* Remove tool property regions. */
-               for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                        if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
@@ -1185,16 +1190,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 13)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 13)) {
                /* Initialize specular factor. */
                if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "spec_fac")) {
-                       for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+                       for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
                                la->spec_fac = 1.0f;
                        }
                }
 
                /* Initialize new view3D options. */
-               for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                        if (sl->spacetype == SPACE_VIEW3D) {
@@ -1213,10 +1218,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_find(fd->filesdna, "View3DCursor")) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                unit_qt(scene->cursor.rotation);
                        }
-                       for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                                for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                        for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                                if (sl->spacetype == SPACE_VIEW3D) {
@@ -1229,34 +1234,34 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 280, 14)) {
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
                if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
                        /* Initialize new scene.SceneDisplay */
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                copy_v3_v3(scene->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
                        }
                }
                if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                scene->display.shadow_shift = 0.1;
                        }
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "Object", "ObjectDisplay", "display")) {
                        /* Initialize new object.ObjectDisplay */
-                       for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+                       for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
                                ob->display.flag = OB_SHOW_SHADOW;
                        }
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                scene->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEAN;
                        }
                }
 
                if (!DNA_struct_find(fd->filesdna, "SceneEEVEE")) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                /* First set the default for all the properties. */
 
                                scene->eevee.gi_diffuse_bounces = 3;
@@ -1438,21 +1443,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
 
-               if (!MAIN_VERSION_ATLEAST(main, 280, 15)) {
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
-                               scene->display.matcap_icon = 1;
-                               scene->display.matcap_type = CLAY_MATCAP_NONE;
-                               scene->display.matcap_hue = 0.5f;
-                               scene->display.matcap_saturation = 0.5f;
-                               scene->display.matcap_value = 0.5f;
+               if (!MAIN_VERSION_ATLEAST(bmain, 280, 15)) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                scene->display.matcap_ssao_distance = 0.2f;
                                scene->display.matcap_ssao_attenuation = 1.0f;
-                               scene->display.matcap_ssao_factor_cavity = 1.0f;
-                               scene->display.matcap_ssao_factor_edge = 1.0f;
                                scene->display.matcap_ssao_samples = 16;
                        }
 
-                       for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                                for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                        for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                                if (sl->spacetype == SPACE_OUTLINER) {
@@ -1464,7 +1462,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                                }
                        }
 
-                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
                                switch (scene->toolsettings->snap_mode) {
                                        case 0: scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT; break;
                                        case 1: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX   ; break;
@@ -1485,7 +1483,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
 
                        ParticleSettings *part;
-                       for (part = main->particle.first; part; part = part->id.next) {
+                       for (part = bmain->particle.first; part; part = part->id.next) {
                                part->shape_flag = PART_SHAPE_CLOSE_TIP;
                                part->shape = 0.0f;
                                part->rad_root = 1.0f;
@@ -1497,11 +1495,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
        }
        {
                if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "roughness")) {
-                       for (Material *mat = main->mat.first; mat; mat = mat->id.next) {
+                       for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) {
                                if (mat->use_nodes) {
-                                       if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
+                                       if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
                                                mat->roughness = mat->gloss_mir;
-                                       } else {
+                                       }
+                                       else {
                                                mat->roughness = 0.25f;
                                        }
                                }
@@ -1511,7 +1510,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                                mat->metallic = mat->ray_mirror;
                        }
 
-                       for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                                for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                        for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                                if (sl->spacetype == SPACE_VIEW3D) {
@@ -1524,7 +1523,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                }
 
                if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
-                       for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                                for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                        for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                                                if (sl->spacetype == SPACE_VIEW3D) {
@@ -1535,5 +1534,69 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                                }
                        }
                }
+               if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
+                       StudioLight *default_matcap = BKE_studiolight_find_first(STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+                       /* when loading the internal file is loaded before the matcaps */
+                       if (default_matcap) {
+                               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+                                       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+                                               for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+                                                       if (sl->spacetype == SPACE_VIEW3D) {
+                                                               View3D *v3d = (View3D *)sl;
+                                                               BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+                               for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+                                       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_VIEW3D) {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       v3d->overlay.wireframe_threshold = 0.5f;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+                               for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+                                       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_VIEW3D) {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       v3d->shading.cavity_valley_factor = 1.0f;
+                                                       v3d->shading.cavity_ridge_factor = 1.0f;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_selection_alpha")) {
+                       for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+                               for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+                                       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_VIEW3D) {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       v3d->overlay.bone_selection_alpha = 0.5f;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "renderslot")) {
+                       for (Image *ima = bmain->image.first; ima; ima = ima->id.next) {
+                               if (ima->type == IMA_TYPE_R_RESULT) {
+                                       for (int i = 0; i < 8; i++) {
+                                               RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image Render Slot Init");
+                                               BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", i + 1);
+                                               BLI_addtail(&ima->renderslots, slot);
+                                       }
+                               }
+                       }
+               }
        }
 }