Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_280.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_genfile.h" | #include "DNA_genfile.h" | ||||
| #include "DNA_gpencil_types.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_colortools.h" | |||||
| #include "BKE_freestyle.h" | #include "BKE_freestyle.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | |||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.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_studiolight.h" | #include "BKE_studiolight.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BKE_gpencil.h" | |||||
| #include "BKE_paint.h" | |||||
| #include "BKE_object.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) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 663 Lines • ▼ Show 20 Lines | for (Collection *group = bmain->collection.first; group; group = group->id.next) { | ||||
| do_version_group_collection_to_collection(bmain, group); | do_version_group_collection_to_collection(bmain, group); | ||||
| } | } | ||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | ||||
| do_version_scene_collection_to_collection(bmain, scene); | do_version_scene_collection_to_collection(bmain, scene); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) | void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) | ||||
| { | { | ||||
| bool use_collection_compat_28 = true; | bool use_collection_compat_28 = true; | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { | if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { | ||||
| use_collection_compat_28 = false; | use_collection_compat_28 = false; | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) { | ||||
| * | * | ||||
| * Also, metallic node is now unified into the principled node. */ | * Also, metallic node is now unified into the principled node. */ | ||||
| eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR; | eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR; | ||||
| FOREACH_NODETREE(bmain, ntree, id) { | FOREACH_NODETREE(bmain, ntree, id) { | ||||
| if (ntree->type == NTREE_SHADER) { | if (ntree->type == NTREE_SHADER) { | ||||
| for (bNode *node = ntree->nodes.first; node; node = node->next) { | for (bNode *node = ntree->nodes.first; node; node = node->next) { | ||||
| if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && | if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && | ||||
| STREQ(node->idname, "ShaderNodeOutputMetallic")) | STREQ(node->idname, "ShaderNodeOutputMetallic")) | ||||
| { | { | ||||
| BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); | BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); | ||||
| error |= NTREE_DOVERSION_NEED_OUTPUT; | error |= NTREE_DOVERSION_NEED_OUTPUT; | ||||
| } | } | ||||
| else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { | else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { | ||||
| BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); | BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); | ||||
| error |= NTREE_DOVERSION_NEED_OUTPUT; | error |= NTREE_DOVERSION_NEED_OUTPUT; | ||||
| } | } | ||||
| else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && | else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && | ||||
| STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) | STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) | ||||
| { | { | ||||
| node->type = SH_NODE_OUTPUT_MATERIAL; | node->type = SH_NODE_OUTPUT_MATERIAL; | ||||
| BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); | BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); | ||||
| } | } | ||||
| else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && | else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && | ||||
| STREQ(node->idname, "ShaderNodeEeveeMetallic")) | STREQ(node->idname, "ShaderNodeEeveeMetallic")) | ||||
| { | { | ||||
| node->type = SH_NODE_BSDF_PRINCIPLED; | node->type = SH_NODE_BSDF_PRINCIPLED; | ||||
| BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); | BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); | ||||
| node->custom1 = SHD_GLOSSY_MULTI_GGX; | node->custom1 = SHD_GLOSSY_MULTI_GGX; | ||||
| error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION; | error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } FOREACH_NODETREE_END | } FOREACH_NODETREE_END | ||||
| if (error & NTREE_DOVERSION_NEED_OUTPUT) { | if (error & NTREE_DOVERSION_NEED_OUTPUT) { | ||||
| 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 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"); | ||||
| } | } | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| if (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, "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 = bmain->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->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 | #endif | ||||
| { | |||||
| /* Grease pencil sculpt and paint cursors */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "weighttype")) { | |||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | |||||
| /* sculpt brushes */ | |||||
| GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt; | |||||
| if (gset) { | |||||
| gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT; | |||||
| } | |||||
| } | |||||
| } | |||||
| { | |||||
| float curcolor_add[3], curcolor_sub[3]; | |||||
| ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f); | |||||
| ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f); | |||||
| GP_EditBrush_Data *gp_brush; | |||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| /* sculpt brushes */ | |||||
| GP_BrushEdit_Settings *gset = &ts->gp_sculpt; | |||||
| for (int i = 0; i < TOT_GP_EDITBRUSH_TYPES; ++i) { | |||||
| gp_brush = &gset->brush[i]; | |||||
| gp_brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR; | |||||
| copy_v3_v3(gp_brush->curcolor_add, curcolor_add); | |||||
| copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Init grease pencil edit line color */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) { | |||||
| for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) { | |||||
| ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f); | |||||
| } | |||||
| } | |||||
| /* Init grease pencil pixel size factor */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "bGPDdata", "int", "pixfactor")) { | |||||
| for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) { | |||||
| gpd->pixfactor = GP_DEFAULT_PIX_FACTOR; | |||||
| } | |||||
| } | |||||
| /* Grease pencil multiframe falloff curve */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "CurveMapping", "cur_falloff")) { | |||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | |||||
| /* sculpt brushes */ | |||||
| GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt; | |||||
| if ((gset) && (gset->cur_falloff == NULL)) { | |||||
| gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | |||||
| curvemapping_initialize(gset->cur_falloff); | |||||
| curvemap_reset(gset->cur_falloff->cm, | |||||
| &gset->cur_falloff->clipr, | |||||
| CURVE_PRESET_GAUSS, | |||||
| CURVEMAP_SLOPE_POSITIVE); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) { | if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) { | ||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->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 (Collection *group = bmain->collection.first; group; group = group->id.next) { | for (Collection *group = bmain->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 | #endif | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) { | |||||
| /* init grease pencil grids and paper */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "gp_paper_opacity", "float", "gpencil_paper_color[3]")) { | |||||
| for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { | |||||
| for (ScrArea *area = screen->areabase.first; area; area = area->next) { | |||||
| for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { | |||||
| if (sl->spacetype == SPACE_VIEW3D) { | |||||
| View3D *v3d = (View3D *)sl; | |||||
| v3d->gpencil_grid_size[0] = GP_DEFAULT_GRID_SIZE; | |||||
| v3d->gpencil_grid_size[1] = GP_DEFAULT_GRID_SIZE; | |||||
| ARRAY_SET_ITEMS(v3d->gpencil_paper_color, 1.0f, 1.0f, 1.0f, 0.7f); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) { | if (!MAIN_VERSION_ATLEAST(bmain, 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 = bmain->screen.first; sc; sc = sc->id.next) { | for (sc = bmain->screen.first; sc; sc = sc->id.next) { | ||||
| ▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) { | ||||
| } | } | ||||
| for (Tex *tex = bmain->tex.first; tex; tex = tex->id.next) { | for (Tex *tex = bmain->tex.first; tex; tex = tex->id.next) { | ||||
| /* Removed envmap, pointdensity, voxeldata, ocean textures. */ | /* Removed envmap, pointdensity, voxeldata, ocean textures. */ | ||||
| if (ELEM(tex->type, 10, 14, 15, 16)) { | if (ELEM(tex->type, 10, 14, 15, 16)) { | ||||
| tex->type = 0; | tex->type = 0; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) { | if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) { | ||||
| /* Remove info editor, but only if at the top of the window. */ | /* Remove info editor, but only if at the top of the window. */ | ||||
| for (bScreen *screen = bmain->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 */ | /* Calculate window width/height from screen vertices */ | ||||
| int win_width = 0, win_height = 0; | int win_width = 0, win_height = 0; | ||||
| ▲ Show 20 Lines • Show All 592 Lines • ▼ Show 20 Lines | if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) { | ||||
| } | } | ||||
| } | } | ||||
| if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) { | if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) { | ||||
| for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { | ||||
| BKE_screen_view3d_shading_init(&scene->display.shading); | BKE_screen_view3d_shading_init(&scene->display.shading); | ||||
| } | } | ||||
| } | } | ||||
| /* initialize grease pencil view data */ | |||||
| if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) { | |||||
| 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) { | |||||
| View3D *v3d = (View3D *)sl; | |||||
| v3d->vertex_opacity = 1.0f; | |||||
| v3d->flag3 |= V3D_GP_SHOW_EDIT_LINES; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||