diff options
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 8 | ||||
-rw-r--r-- | source/blender/blenloader/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 55 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 19 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 12 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 43 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 285 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_common.cc | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_cycles.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 35 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_legacy.c | 10 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 258 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/tests/blendfile_loading_base_test.cc | 2 |
14 files changed, 402 insertions, 337 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 043f9ffd723..93040fa01ee 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -229,10 +229,10 @@ struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, * \return A BLI_linklist of `BLODataBlockInfo *`. * The links and #BLODataBlockInfo.asset_data should be freed with MEM_freeN. */ -struct LinkNode * /*BLODataBlockInfo */ BLO_blendhandle_get_datablock_info(BlendHandle *bh, - int ofblocktype, - bool use_assets_only, - int *r_tot_info_items); +struct LinkNode * /*BLODataBlockInfo*/ BLO_blendhandle_get_datablock_info(BlendHandle *bh, + int ofblocktype, + bool use_assets_only, + int *r_tot_info_items); /** * Gets the previews of all the data-blocks in a file of a certain type * (e.g. all the scene previews in a file). diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 5ca026ae9a3..f8bf97b17e9 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -19,6 +19,7 @@ set(INC ../windowmanager ../../../intern/clog ../../../intern/guardedalloc + ../bmesh # for writefile.c: dna_type_offsets.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a34ba753912..0182e349fec 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -359,6 +359,11 @@ static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, oldnewmap_insert_or_replace(onm, entry); } +static void oldnewmap_lib_insert(FileData *fd, const void *oldaddr, ID *newaddr, int nr) +{ + oldnewmap_insert(fd->libmap, oldaddr, newaddr, nr); +} + void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr) { oldnewmap_insert(onm, oldaddr, newaddr, nr); @@ -517,7 +522,7 @@ void blo_split_main(ListBase *mainlist, Main *main) while (i--) { ID *id = lbarray[i]->first; if (id == NULL || GS(id->name) == ID_LI) { - /* No ID_LI data-lock should ever be linked anyway, but just in case, better be explicit. */ + /* No ID_LI data-block should ever be linked anyway, but just in case, better be explicit. */ continue; } split_libdata(lbarray[i], lib_main_array, lib_main_array_len); @@ -1667,7 +1672,7 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd) int i = set_listbasepointers(ptr, lbarray); while (i--) { LISTBASE_FOREACH (ID *, id, lbarray[i]) { - oldnewmap_insert(fd->libmap, id, id, GS(id->name)); + oldnewmap_lib_insert(fd, id, id, GS(id->name)); } } } @@ -1993,7 +1998,7 @@ static void lib_link_id(BlendLibReader *reader, ID *id) { /* NOTE: WM IDProperties are never written to file, hence they should always be NULL here. */ BLI_assert((GS(id->name) != ID_WM) || id->properties == NULL); - IDP_BlendReadLib(reader, id->properties); + IDP_BlendReadLib(reader, id->lib, id->properties); AnimData *adt = BKE_animdata_from_id(id); if (adt != NULL) { @@ -2047,7 +2052,7 @@ static void direct_link_id_embedded_id(BlendDataReader *reader, (ID *)*nodetree, id_old != NULL ? (ID *)ntreeFromID(id_old) : NULL, 0); - ntreeBlendReadData(reader, *nodetree); + ntreeBlendReadData(reader, id, *nodetree); } if (GS(id->name) == ID_SCE) { @@ -2059,7 +2064,7 @@ static void direct_link_id_embedded_id(BlendDataReader *reader, &scene->master_collection->id, id_old != NULL ? &((Scene *)id_old)->master_collection->id : NULL, 0); - BKE_collection_blend_read_data(reader, scene->master_collection); + BKE_collection_blend_read_data(reader, scene->master_collection, &scene->id); } } } @@ -2630,9 +2635,6 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, else if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - space_outliner->search_tse.id = restore_pointer_by_name( - id_map, space_outliner->search_tse.id, USER_IGNORE); - if (space_outliner->treestore) { TreeStoreElem *tselem; BLI_mempool_iter iter; @@ -2736,6 +2738,8 @@ void blo_lib_link_restore(Main *oldmain, LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { lib_link_workspace_layout_restore(id_map, newmain, layout); } + workspace->pin_scene = restore_pointer_by_name( + id_map, (ID *)workspace->pin_scene, USER_IGNORE); } LISTBASE_FOREACH (wmWindow *, win, &curwm->windows) { @@ -2749,6 +2753,7 @@ void blo_lib_link_restore(Main *oldmain, if (win->scene == NULL) { win->scene = curscene; } + win->unpinned_scene = restore_pointer_by_name(id_map, (ID *)win->unpinned_scene, USER_IGNORE); if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) { STRNCPY(win->view_layer_name, cur_view_layer->name); } @@ -3164,7 +3169,7 @@ static bool read_libblock_undo_restore_linked(FileData *fd, Main *main, const ID /* Even though we found our linked ID, there is no guarantee its address * is still the same. */ if (id_old != bhead->old) { - oldnewmap_insert(fd->libmap, bhead->old, id_old, GS(id_old->name)); + oldnewmap_lib_insert(fd, bhead->old, id_old, GS(id_old->name)); } /* No need to do anything else for ID_LINK_PLACEHOLDER, it's assumed @@ -3306,7 +3311,7 @@ static bool read_libblock_undo_restore( /* Insert into library map for lookup by newly read datablocks (with pointer value bhead->old). * Note that existing datablocks in memory (which pointer value would be id_old) are not * remapped anymore, so no need to store this info here. */ - oldnewmap_insert(fd->libmap, bhead->old, id_old, bhead->code); + oldnewmap_lib_insert(fd, bhead->old, id_old, bhead->code); *r_id_old = id_old; return true; @@ -3389,7 +3394,7 @@ static BHead *read_libblock(FileData *fd, * Note that existing datablocks in memory (which pointer value would be id_old) are not remapped * remapped anymore, so no need to store this info here. */ ID *id_target = id_old ? id_old : id; - oldnewmap_insert(fd->libmap, bhead->old, id_target, bhead->code); + oldnewmap_lib_insert(fd, bhead->old, id_target, bhead->code); if (r_id) { *r_id = id_target; @@ -4176,7 +4181,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) } if (bhead->code == ID_LINK_PLACEHOLDER) { - /* Placeholder link to data-lock in another library. */ + /* Placeholder link to data-block in another library. */ BHead *bheadlib = find_previous_lib(fd, bhead); if (bheadlib == NULL) { return; @@ -4202,6 +4207,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) /* ID has not been read yet, add placeholder to the main of the * library it belongs to, so that it will be read later. */ read_libblock(fd, libmain, bhead, fd->id_tag_extra | LIB_TAG_INDIRECT, false, &id); + BLI_assert(id != NULL); id_sort_by_name(which_libbase(libmain, GS(id->name)), id, id->prev); /* commented because this can print way too much */ @@ -4228,9 +4234,9 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) * (B) forest.blend: contains Forest collection linking in Tree from tree.blend. * (C) shot.blend: links in both Tree from tree.blend and Forest from forest.blend. */ - oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); + oldnewmap_lib_insert(fd, bhead->old, id, bhead->code); - /* If "id" is a real data-lock and not a placeholder, we need to + /* If "id" is a real data-block and not a placeholder, we need to * update fd->libmap to replace ID_LINK_PLACEHOLDER with the real * ID_* code. * @@ -4264,6 +4270,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) fd->id_tag_extra | LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, false, &id); + BLI_assert(id != NULL); id_sort_by_name(which_libbase(mainvar, GS(id->name)), id, id->prev); } else { @@ -4276,7 +4283,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) /* this is actually only needed on UI call? when ID was already read before, * and another append happens which invokes same ID... * in that case the lookup table needs this entry */ - oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); + oldnewmap_lib_insert(fd, bhead->old, id, bhead->code); /* commented because this can print way too much */ // if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name); } @@ -4396,7 +4403,7 @@ static ID *link_named_part( else { /* already linked */ CLOG_WARN(&LOG, "Append: ID '%s' is already linked", id->name); - oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); + oldnewmap_lib_insert(fd, bhead->old, id, bhead->code); if (!force_indirect && (id->tag & LIB_TAG_INDIRECT)) { id->tag &= ~LIB_TAG_INDIRECT; id->flag &= ~LIB_INDIRECT_WEAK_LINK; @@ -4891,23 +4898,27 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } } - /* Read linked data-locks for each link placeholder, and replace - * the placeholder with the real data-lock. */ + /* Read linked data-blocks for each link placeholder, and replace + * the placeholder with the real data-block. */ read_library_linked_ids(basefd, fd, mainlist, mainptr); - /* Test if linked data-locks need to read further linked data-locks + /* Test if linked data-blocks need to read further linked data-blocks * and create link placeholders for them. */ BLO_expand_main(fd, mainptr); } } } - Main *main_newid = BKE_main_new(); for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) { - /* Drop weak links for which no data-block was found. */ + /* Drop weak links for which no data-block was found. + * Since this can remap pointers in `libmap` of all libraries, it needs to be performed in its + * own loop, before any call to `lib_link_all` (and the freeing of the libraries' filedata). */ read_library_clear_weak_links(basefd, mainlist, mainptr); + } - /* Do versioning for newly added linked data-locks. If no data-locks + Main *main_newid = BKE_main_new(); + for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) { + /* Do versioning for newly added linked data-blocks. If no data-blocks * were read from a library versionfile will still be zero and we can * skip it. */ if (mainptr->versionfile) { diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 67b6ad25d8b..9e5ef41892a 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -54,6 +54,7 @@ #include "BKE_global.h" /* for G */ #include "BKE_lib_id.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" #include "BKE_node_tree_update.h" @@ -425,14 +426,14 @@ static void do_versions_windowmanager_2_50(bScreen *screen) } } -static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) +static void versions_gpencil_add_main(Main *bmain, ListBase *lb, ID *id, const char *name) { BLI_addtail(lb, id); id->us = 1; id->flag = LIB_FAKEUSER; *((short *)id->name) = ID_GD; - BKE_id_new_name_validate(lb, id, name, false); + BKE_id_new_name_validate(bmain, lb, id, name, false); /* alphabetic insertion: is in BKE_id_new_name_validate */ if ((id->tag & LIB_TAG_TEMP_MAIN) == 0) { @@ -455,21 +456,21 @@ static void do_versions_gpencil_2_50(Main *main, bScreen *screen) if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->gpd) { - versions_gpencil_add_main(&main->gpencils, (ID *)v3d->gpd, "GPencil View3D"); + versions_gpencil_add_main(main, &main->gpencils, (ID *)v3d->gpd, "GPencil View3D"); v3d->gpd = NULL; } } else if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; if (snode->gpd) { - versions_gpencil_add_main(&main->gpencils, (ID *)snode->gpd, "GPencil Node"); + versions_gpencil_add_main(main, &main->gpencils, (ID *)snode->gpd, "GPencil Node"); snode->gpd = NULL; } } else if (sl->spacetype == SPACE_SEQ) { SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->gpd) { - versions_gpencil_add_main(&main->gpencils, (ID *)sseq->gpd, "GPencil Node"); + versions_gpencil_add_main(main, &main->gpencils, (ID *)sseq->gpd, "GPencil Node"); sseq->gpd = NULL; } } @@ -477,7 +478,7 @@ static void do_versions_gpencil_2_50(Main *main, bScreen *screen) SpaceImage *sima = (SpaceImage *)sl; #if 0 /* see comment on r28002 */ if (sima->gpd) { - versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image"); + versions_gpencil_add_main(main, &main->gpencil, (ID *)sima->gpd, "GPencil Image"); sima->gpd = NULL; } #else @@ -989,15 +990,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) int a, tot; /* shape keys are no longer applied to the mesh itself, but rather - * to the evaluated #Mesh / #DispList, so here we ensure that the basis + * to the evaluated #Mesh, so here we ensure that the basis * shape key is always set in the mesh coordinates. */ for (me = bmain->meshes.first; me; me = me->id.next) { if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) { data = key->refkey->data; tot = MIN2(me->totvert, key->refkey->totelem); - + MVert *verts = BKE_mesh_verts_for_write(me); for (a = 0; a < tot; a++, data += 3) { - copy_v3_v3(me->mvert[a].co, data); + copy_v3_v3(verts[a].co, data); } } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index e542bc46a28..e4dc8d006ae 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -73,6 +73,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_legacy_convert.h" #include "BKE_node.h" #include "BKE_node_tree_update.h" #include "BKE_paint.h" @@ -366,7 +367,7 @@ static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene) BLI_listbase_clear(&scene->view_layers); if (!scene->master_collection) { - scene->master_collection = BKE_collection_master_add(); + scene->master_collection = BKE_collection_master_add(scene); } /* Convert scene collections. */ @@ -410,7 +411,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Since we don't have access to FileData we check the (always valid) first * render layer instead. */ if (!scene->master_collection) { - scene->master_collection = BKE_collection_master_add(); + scene->master_collection = BKE_collection_master_add(scene); } if (scene->view_layers.first) { @@ -1793,10 +1794,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (DNA_struct_find(fd->filesdna, "MTexPoly")) { for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { /* If we have UV's, so this file will have MTexPoly layers too! */ - if (me->mloopuv != NULL) { + if (CustomData_has_layer(&me->ldata, CD_MLOOPUV)) { CustomData_update_typemap(&me->pdata); CustomData_free_layers(&me->pdata, CD_MTEXPOLY, me->totpoly); - BKE_mesh_update_customdata_pointers(me, false); } } } @@ -2408,7 +2408,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) scene->toolsettings->snap_mode = (1 << 1); /* SCE_SNAP_MODE_EDGE */ break; case 3: - scene->toolsettings->snap_mode = (1 << 2); /* SCE_SNAP_MODE_FACE */ + scene->toolsettings->snap_mode = (1 << 2); /* SCE_SNAP_MODE_FACE_RAYCAST */ break; case 4: scene->toolsettings->snap_mode = (1 << 3); /* SCE_SNAP_MODE_VOLUME */ @@ -3548,7 +3548,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 43)) { ListBase *lb = which_libbase(bmain, ID_BR); - BKE_main_id_repair_duplicate_names_listbase(lb); + BKE_main_id_repair_duplicate_names_listbase(bmain, lb); } if (!MAIN_VERSION_ATLEAST(bmain, 280, 44)) { diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index a15ddc75aa2..b285e1829b7 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -160,7 +160,7 @@ static void seq_convert_transform_crop(const Scene *scene, const uint32_t use_transform_flag = (1 << 16); const uint32_t use_crop_flag = (1 << 17); - const StripElem *s_elem = SEQ_render_give_stripelem(seq, seq->start); + const StripElem *s_elem = seq->strip->stripdata; if (s_elem != NULL) { image_size_x = s_elem->orig_width; image_size_y = s_elem->orig_height; @@ -285,7 +285,7 @@ static void seq_convert_transform_crop_2(const Scene *scene, Sequence *seq, const eSpaceSeq_Proxy_RenderSize render_size) { - const StripElem *s_elem = SEQ_render_give_stripelem(seq, seq->start); + const StripElem *s_elem = seq->strip->stripdata; if (s_elem == NULL) { return; } @@ -350,6 +350,7 @@ static void seq_convert_transform_crop_lb_2(const Scene *scene, static void seq_update_meta_disp_range(Scene *scene) { Editing *ed = SEQ_editing_get(scene); + if (ed == NULL) { return; } @@ -357,8 +358,8 @@ static void seq_update_meta_disp_range(Scene *scene) LISTBASE_FOREACH_BACKWARD (MetaStack *, ms, &ed->metastack) { /* Update ms->disp_range from meta. */ if (ms->disp_range[0] == ms->disp_range[1]) { - ms->disp_range[0] = SEQ_time_left_handle_frame_get(ms->parseq); - ms->disp_range[1] = SEQ_time_right_handle_frame_get(ms->parseq); + ms->disp_range[0] = SEQ_time_left_handle_frame_get(scene, ms->parseq); + ms->disp_range[1] = SEQ_time_right_handle_frame_get(scene, ms->parseq); } /* Update meta strip endpoints. */ @@ -366,6 +367,14 @@ static void seq_update_meta_disp_range(Scene *scene) SEQ_time_right_handle_frame_set(scene, ms->parseq, ms->disp_range[1]); SEQ_transform_fix_single_image_seq_offsets(scene, ms->parseq); + /* Recalculate effects using meta strip. */ + LISTBASE_FOREACH (Sequence *, seq, ms->oldbasep) { + if (seq->seq2) { + seq->start = seq->startdisp = max_ii(seq->seq1->startdisp, seq->seq2->startdisp); + seq->enddisp = min_ii(seq->seq1->enddisp, seq->seq2->enddisp); + } + } + /* Ensure that active seqbase points to active meta strip seqbase. */ MetaStack *active_ms = SEQ_meta_stack_active_get(ed); SEQ_seqbase_active_set(ed, &active_ms->parseq->seqbase); @@ -810,21 +819,21 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) if (MAIN_VERSION_ATLEAST(bmain, 290, 2) && MAIN_VERSION_OLDER(bmain, 291, 1)) { /* In this range, the extrude manifold could generate meshes with degenerated face. */ LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) { - for (MPoly *mp = me->mpoly, *mp_end = mp + me->totpoly; mp < mp_end; mp++) { + for (const MPoly *mp = BKE_mesh_polys(me), *mp_end = mp + me->totpoly; mp < mp_end; mp++) { if (mp->totloop == 2) { bool changed; BKE_mesh_validate_arrays(me, - me->mvert, + BKE_mesh_verts_for_write(me), me->totvert, - me->medge, + BKE_mesh_edges_for_write(me), me->totedge, - me->mface, + (MFace *)CustomData_get_layer(&me->fdata, CD_MFACE), me->totface, - me->mloop, + BKE_mesh_loops_for_write(me), me->totloop, - me->mpoly, + BKE_mesh_polys_for_write(me), me->totpoly, - me->dvert, + BKE_mesh_deform_verts_for_write(me), false, true, &changed); @@ -840,7 +849,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) short id_codes[] = {ID_BR, ID_PAL}; for (int i = 0; i < ARRAY_SIZE(id_codes); i++) { ListBase *lb = which_libbase(bmain, id_codes[i]); - BKE_main_id_repair_duplicate_names_listbase(lb); + BKE_main_id_repair_duplicate_names_listbase(bmain, lb); } } @@ -917,7 +926,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->mode & eModifierMode_Expanded_DEPRECATED) { - md->ui_expand_flag = 1; + md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT; } else { md->ui_expand_flag = 0; @@ -945,7 +954,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (bConstraint *, con, &object->constraints) { if (con->flag & CONSTRAINT_EXPAND_DEPRECATED) { - con->ui_expand_flag = 1; + con->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT; } else { con->ui_expand_flag = 0; @@ -959,7 +968,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) { if (md->mode & eGpencilModifierMode_Expanded_DEPRECATED) { - md->ui_expand_flag = 1; + md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT; } else { md->ui_expand_flag = 0; @@ -973,7 +982,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) { if (fx->mode & eShaderFxMode_Expanded_DEPRECATED) { - fx->ui_expand_flag = 1; + fx->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT; } else { fx->ui_expand_flag = 0; @@ -1688,7 +1697,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Add subpanels for FModifiers, which requires a field to store expansion. */ + /* Add sub-panels for FModifiers, which requires a field to store expansion. */ if (!DNA_struct_elem_find(fd->filesdna, "FModifier", "short", "ui_expand_flag")) { LISTBASE_FOREACH (bAction *, act, &bmain->actions) { LISTBASE_FOREACH (FCurve *, fcu, &act->curves) { diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 97b414d4b4a..1692fd2d747 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -30,6 +30,7 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_lineart_types.h" #include "DNA_listBase.h" +#include "DNA_mask_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" @@ -45,6 +46,7 @@ #include "BKE_asset.h" #include "BKE_attribute.h" #include "BKE_collection.h" +#include "BKE_colortools.h" #include "BKE_curve.h" #include "BKE_data_transfer.h" #include "BKE_deform.h" @@ -55,6 +57,7 @@ #include "BKE_lib_id.h" #include "BKE_lib_override.h" #include "BKE_main.h" +#include "BKE_main_namemap.h" #include "BKE_modifier.h" #include "BKE_node.h" #include "BKE_screen.h" @@ -406,7 +409,7 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis v->speed_control_type = SEQ_SPEED_MULTIPLY; v->speed_fader = globalSpeed * ((float)seq->seq1->len / - max_ff((float)(SEQ_time_right_handle_frame_get(seq->seq1) - + max_ff((float)(SEQ_time_right_handle_frame_get(scene, seq->seq1) - seq->seq1->start), 1.0f)); } @@ -593,6 +596,39 @@ static bNodeTree *add_realize_node_tree(Main *bmain) return node_tree; } +static void seq_speed_factor_fix_rna_path(Sequence *seq, ListBase *fcurves) +{ + char name_esc[(sizeof(seq->name) - 2) * 2]; + BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc)); + char *path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].pitch", name_esc); + FCurve *fcu = BKE_fcurve_find(fcurves, path, 0); + if (fcu != NULL) { + MEM_freeN(fcu->rna_path); + fcu->rna_path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].speed_factor", name_esc); + } + MEM_freeN(path); +} + +static bool seq_speed_factor_set(Sequence *seq, void *user_data) +{ + const Scene *scene = user_data; + if (seq->type == SEQ_TYPE_SOUND_RAM) { + /* Move `pitch` animation to `speed_factor` */ + if (scene->adt && scene->adt->action) { + seq_speed_factor_fix_rna_path(seq, &scene->adt->action->curves); + } + if (scene->adt && !BLI_listbase_is_empty(&scene->adt->drivers)) { + seq_speed_factor_fix_rna_path(seq, &scene->adt->drivers); + } + + seq->speed_factor = seq->pitch; + } + else { + seq->speed_factor = 1.0f; + } + return true; +} + void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) { if (MAIN_VERSION_ATLEAST(bmain, 300, 0) && !MAIN_VERSION_ATLEAST(bmain, 300, 1)) { @@ -796,13 +832,16 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) continue; } SpaceSeq *sseq = (SpaceSeq *)sl; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; sseq->flag |= SEQ_CLAMP_VIEW; if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) { continue; } - ARegion *timeline_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + ARegion *timeline_region = BKE_region_find_in_listbase_by_type(regionbase, + RGN_TYPE_WINDOW); if (timeline_region == NULL) { continue; @@ -814,6 +853,45 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) } } } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 5)) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + Editing *ed = SEQ_editing_get(scene); + if (ed == NULL) { + continue; + } + SEQ_for_each_callback(&ed->seqbase, seq_speed_factor_set, scene); + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 6)) { + /* In the Dope Sheet, for every mode other than Timeline, open the Properties panel. */ + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype != SPACE_ACTION) { + continue; + } + + /* Skip the timeline, it shouldn't get its Properties panel opened. */ + SpaceAction *saction = (SpaceAction *)sl; + if (saction->mode == SACTCONT_TIMELINE) { + continue; + } + + const bool is_first_space = sl == area->spacedata.first; + ListBase *regionbase = is_first_space ? &area->regionbase : &sl->regionbase; + ARegion *region = BKE_region_find_in_listbase_by_type(regionbase, RGN_TYPE_UI); + if (region == NULL) { + continue; + } + + region->flag &= ~RGN_FLAG_HIDDEN; + } + } + } + } + /** * Versioning code until next subversion bump goes here. * @@ -1619,6 +1697,52 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre } } +static void versioning_replace_legacy_mix_rgb_node(bNodeTree *ntree) +{ + version_node_input_socket_name(ntree, SH_NODE_MIX_RGB_LEGACY, "Fac", "Factor_Float"); + version_node_input_socket_name(ntree, SH_NODE_MIX_RGB_LEGACY, "Color1", "A_Color"); + version_node_input_socket_name(ntree, SH_NODE_MIX_RGB_LEGACY, "Color2", "B_Color"); + version_node_output_socket_name(ntree, SH_NODE_MIX_RGB_LEGACY, "Color", "Result_Color"); + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == SH_NODE_MIX_RGB_LEGACY) { + strcpy(node->idname, "ShaderNodeMix"); + node->type = SH_NODE_MIX; + NodeShaderMix *data = (NodeShaderMix *)MEM_callocN(sizeof(NodeShaderMix), __func__); + data->blend_type = node->custom1; + data->clamp_result = node->custom2; + data->clamp_factor = 1; + data->data_type = SOCK_RGBA; + data->factor_mode = NODE_MIX_MODE_UNIFORM; + node->storage = data; + } + } +} + +static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format) +{ + /* Fix bug where curves in image format were not properly copied to file output + * node, incorrectly sharing a pointer with the scene settings. Copy the data + * structure now as it should have been done in the first place. */ + if (format->view_settings.curve_mapping) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + if (format != &scene->r.im_format && ELEM(format->view_settings.curve_mapping, + scene->view_settings.curve_mapping, + scene->r.im_format.view_settings.curve_mapping)) { + format->view_settings.curve_mapping = BKE_curvemapping_copy( + format->view_settings.curve_mapping); + break; + } + } + + /* Remove any invalid curves with missing data. */ + if (format->view_settings.curve_mapping->cm[0].curve == NULL) { + BKE_curvemapping_free(format->view_settings.curve_mapping); + format->view_settings.curve_mapping = NULL; + format->view_settings.flag &= ~COLORMANAGE_VIEW_USE_CURVES; + } + } +} + /* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) { @@ -1943,7 +2067,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Font names were copied directly into ID names, see: T90417. */ if (!MAIN_VERSION_ATLEAST(bmain, 300, 16)) { ListBase *lb = which_libbase(bmain, ID_VF); - BKE_main_id_repair_duplicate_names_listbase(lb); + BKE_main_id_repair_duplicate_names_listbase(bmain, lb); } if (!MAIN_VERSION_ATLEAST(bmain, 300, 17)) { @@ -2842,16 +2966,19 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS); + ARegion *region = BKE_region_find_in_listbase_by_type(regionbase, RGN_TYPE_CHANNELS); if (!region) { - ARegion *tools_region = BKE_area_find_region_type(area, RGN_TYPE_TOOLS); + /* Find sequencer tools region. */ + ARegion *tools_region = BKE_region_find_in_listbase_by_type(regionbase, + RGN_TYPE_TOOLS); region = do_versions_add_region(RGN_TYPE_CHANNELS, "channels region"); BLI_insertlinkafter(regionbase, tools_region, region); region->alignment = RGN_ALIGN_LEFT; region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; } - ARegion *timeline_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + ARegion *timeline_region = BKE_region_find_in_listbase_by_type(regionbase, + RGN_TYPE_WINDOW); if (timeline_region != NULL) { timeline_region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; } @@ -3025,6 +3152,13 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 302, 14)) { + /* Compensate for previously wrong squared distance. */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + scene->r.bake.max_ray_distance = sasqrt(scene->r.bake.max_ray_distance); + } + } + if (!MAIN_VERSION_ATLEAST(bmain, 303, 1)) { FOREACH_NODETREE_BEGIN (bmain, ntree, id) { versioning_replace_legacy_combined_and_separate_color_nodes(ntree); @@ -3082,6 +3216,123 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } FOREACH_NODETREE_END; + + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + LISTBASE_FOREACH (GpencilModifierData *, gpd, &ob->greasepencil_modifiers) { + if (gpd->type == eGpencilModifierType_Lineart) { + LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)gpd; + lmd->shadow_camera_near = 0.1f; + lmd->shadow_camera_far = 200.0f; + lmd->shadow_camera_size = 200.0f; + } + } + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 2)) { + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype == SPACE_CLIP) { + ((SpaceClip *)sl)->mask_info.blend_factor = 1.0; + } + } + } + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 3)) { + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype == SPACE_CLIP) { + ((SpaceClip *)sl)->mask_info.draw_flag |= MASK_DRAWFLAG_SPLINE; + } + else if (sl->spacetype == SPACE_IMAGE) { + ((SpaceImage *)sl)->mask_info.draw_flag |= MASK_DRAWFLAG_SPLINE; + } + } + } + } + + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + ToolSettings *tool_settings = scene->toolsettings; + /* Zero isn't a valid value, use for versioning. */ + if (tool_settings->snap_face_nearest_steps == 0) { + /* Minimum of snap steps for face nearest is 1. */ + tool_settings->snap_face_nearest_steps = 1; + /* Set snap to edited and non-edited as default. */ + tool_settings->snap_flag |= SCE_SNAP_TO_INCLUDE_EDITED | SCE_SNAP_TO_INCLUDE_NONEDITED; + } + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 4)) { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + if (ntree->type == NTREE_COMPOSIT) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == CMP_NODE_OUTPUT_FILE) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + if (sock->storage) { + NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)sock->storage; + version_fix_image_format_copy(bmain, &sockdata->format); + } + } + + if (node->storage) { + NodeImageMultiFile *nimf = (NodeImageMultiFile *)node->storage; + version_fix_image_format_copy(bmain, &nimf->format); + } + } + } + } + } + FOREACH_NODETREE_END; + + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + version_fix_image_format_copy(bmain, &scene->r.im_format); + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 5)) { + /* Fix for T98925 - remove channels region, that was initialized in incorrect editor types. */ + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_CLIP, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ)) { + continue; + } + + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; + ARegion *channels_region = BKE_region_find_in_listbase_by_type(regionbase, + RGN_TYPE_CHANNELS); + if (channels_region) { + BLI_freelinkN(regionbase, channels_region); + } + } + } + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 303, 6)) { + /* Initialize brush curves sculpt settings. */ + LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { + if (brush->ob_mode != OB_MODE_SCULPT_CURVES) { + continue; + } + brush->curves_sculpt_settings->density_add_attempts = 100; + } + + /* Disable 'show_bounds' option of curve objects. Option was set as there was no object mode + * outline implementation. See T95933. */ + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->type == OB_CURVES) { + ob->dtx &= ~OB_DRAWBOUNDOX; + } + } + + BKE_main_namemap_validate_and_fix(bmain); } /** @@ -3095,5 +3346,27 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Image generation information transferred to tiles. */ + if (!DNA_struct_elem_find(fd->filesdna, "ImageTile", "int", "gen_x")) { + for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { + for (ImageTile *tile = ima->tiles.first; tile; tile = tile->next) { + tile->gen_x = ima->gen_x; + tile->gen_y = ima->gen_y; + tile->gen_type = ima->gen_type; + tile->gen_flag = ima->gen_flag; + tile->gen_depth = ima->gen_depth; + copy_v4_v4(tile->gen_color, ima->gen_color); + } + } + } + + /* Convert mix rgb node to new mix node and add storage. */ + { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + versioning_replace_legacy_mix_rgb_node(ntree); + } + FOREACH_NODETREE_END; + } } } diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index d2a55f6f37e..823385727e1 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -18,6 +18,7 @@ #include "BKE_animsys.h" #include "BKE_lib_id.h" #include "BKE_main.h" +#include "BKE_main_namemap.h" #include "BKE_node.h" #include "MEM_guardedalloc.h" @@ -66,6 +67,7 @@ ID *do_versions_rename_id(Main *bmain, } } if (id != nullptr) { + BKE_main_namemap_remove_name(bmain, id, id->name + 2); BLI_strncpy(id->name + 2, name_dst, sizeof(id->name) - 2); /* We know it's unique, this just sorts. */ BLI_libblock_ensure_unique_name(bmain, id->name); diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index e1ceed82ba7..51063f47ef9 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -689,7 +689,6 @@ static void update_vector_math_node_normalize_operator(bNodeTree *ntree) * a value of -1 just to be identified later in the versioning code: * * Average Operator : 2 -> -1 - * */ static void update_vector_math_node_operators_enum_mapping(bNodeTree *ntree) { @@ -867,7 +866,6 @@ static void update_mapping_node_fcurve_rna_path_callback(ID *UNUSED(id), * and check if they control a property of the node, if they do, we update * the path to be that of the corresponding socket in the node or the added * minimum/maximum node. - * */ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree) { @@ -1057,7 +1055,6 @@ static void update_voronoi_node_fac_output(bNodeTree *ntree) * the inputs of the subtract node. * 6. The output of the subtract node is connected to the * appropriate sockets. - * */ static void update_voronoi_node_crackle(bNodeTree *ntree) { diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index f65976ee55f..06903865381 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -23,6 +23,7 @@ #include "DNA_curveprofile_types.h" #include "DNA_gpencil_types.h" #include "DNA_light_types.h" +#include "DNA_mask_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -44,6 +45,7 @@ #include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_main.h" +#include "BKE_main_namemap.h" #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_node.h" @@ -54,6 +56,8 @@ #include "BLO_readfile.h" +#include "BLT_translation.h" + #include "versioning_common.h" /* Make preferences read-only, use versioning_userdef.c. */ @@ -62,8 +66,9 @@ static bool blo_is_builtin_template(const char *app_template) { /* For all builtin templates shipped with Blender. */ - return (!app_template || - STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing")); + return ( + !app_template || + STR_ELEM(app_template, N_("2D_Animation"), N_("Sculpting"), N_("VFX"), N_("Video_Editing"))); } static void blo_update_defaults_screen(bScreen *screen, @@ -133,6 +138,14 @@ static void blo_update_defaults_screen(bScreen *screen, } } } + else { + /* Open properties panel by default. */ + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + if (region->regiontype == RGN_TYPE_UI) { + region->flag &= ~RGN_FLAG_HIDDEN; + } + } + } } else if (area->spacetype == SPACE_GRAPH) { SpaceGraph *sipo = area->spacedata.first; @@ -184,6 +197,8 @@ static void blo_update_defaults_screen(bScreen *screen, else if (area->spacetype == SPACE_CLIP) { SpaceClip *sclip = area->spacedata.first; sclip->around = V3D_AROUND_CENTER_MEDIAN; + sclip->mask_info.blend_factor = 0.7f; + sclip->mask_info.draw_flag = MASK_DRAWFLAG_SPLINE; } } @@ -330,7 +345,8 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) /* Correct default startup UV's. */ Mesh *me = BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2); - if (me && (me->totloop == 24) && (me->mloopuv != NULL)) { + if (me && (me->totloop == 24) && CustomData_has_layer(&me->ldata, CD_MLOOPUV)) { + MLoopUV *mloopuv = CustomData_get_layer(&me->ldata, CD_MLOOPUV); const float uv_values[24][2] = { {0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75}, {0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25}, @@ -338,7 +354,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50}, }; for (int i = 0; i < ARRAY_SIZE(uv_values); i++) { - copy_v2_v2(me->mloopuv[i].uv, uv_values[i]); + copy_v2_v2(mloopuv[i].uv, uv_values[i]); } } @@ -476,8 +492,11 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) /* Default only has one window. */ if (layout->screen) { bScreen *screen = layout->screen; - BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2); - BLI_libblock_ensure_unique_name(bmain, screen->id.name); + if (!STREQ(screen->id.name + 2, workspace->id.name + 2)) { + BKE_main_namemap_remove_name(bmain, &screen->id, screen->id.name + 2); + BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2); + BLI_libblock_ensure_unique_name(bmain, screen->id.name); + } } /* For some reason we have unused screens, needed until re-saving. @@ -563,14 +582,14 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) /* Materials */ for (Material *ma = bmain->materials.first; ma; ma = ma->id.next) { /* Update default material to be a bit more rough. */ - ma->roughness = 0.4f; + ma->roughness = 0.5f; if (ma->nodetree) { LISTBASE_FOREACH (bNode *, node, &ma->nodetree->nodes) { if (node->type == SH_NODE_BSDF_PRINCIPLED) { bNodeSocket *roughness_socket = nodeFindSocket(node, SOCK_IN, "Roughness"); bNodeSocketValueFloat *roughness_data = roughness_socket->default_value; - roughness_data->value = 0.4f; + roughness_data->value = 0.5f; node->custom2 = SHD_SUBSURFACE_RANDOM_WALK; BKE_ntree_update_tag_node_property(ma->nodetree, node); } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 4c27b8b9016..94438acf4fa 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -291,8 +291,8 @@ static void customdata_version_242(Mesh *me) MEM_freeN(me->mcol); } - me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); - me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); + me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_SET_DEFAULT, NULL, me->totface); + me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_SET_DEFAULT, NULL, me->totface); mtf = me->mtface; mcol = me->mcol; @@ -342,8 +342,6 @@ static void customdata_version_242(Mesh *me) mcoln++; } } - - BKE_mesh_update_customdata_pointers(me, true); } /* Only copy render texface layer from active. */ @@ -1468,7 +1466,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) for (me = bmain->meshes.first; me; me = me->id.next) { if (!me->medge) { - BKE_mesh_calc_edges_legacy(me, true); /* true = use mface->edcode */ + BKE_mesh_calc_edges_legacy(me, true); /* true = use #MFace.edcode. */ } else { BKE_mesh_strip_loose_faces(me); @@ -2296,7 +2294,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v; psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v; - /* dupliobjects */ + /* Dupli-objects. */ if (ob->transflag & OB_DUPLIVERTS) { Object *dup = bmain->objects.first; diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 40359500d3c..f8fb3b47570 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -55,259 +55,6 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) #define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver) #define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_uchar(btheme->member, U_theme_default.member) - if (!USER_VERSION_ATLEAST(280, 25)) { - copy_v4_v4_uchar(btheme->space_action.anim_preview_range, btheme->space_action.anim_active); - copy_v4_v4_uchar(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active); - copy_v4_v4_uchar(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active); - } - - if (!USER_VERSION_ATLEAST(280, 26)) { - FROM_DEFAULT_V4_UCHAR(tui.icon_collection); - FROM_DEFAULT_V4_UCHAR(tui.icon_object); - FROM_DEFAULT_V4_UCHAR(tui.icon_object_data); - FROM_DEFAULT_V4_UCHAR(tui.icon_modifier); - FROM_DEFAULT_V4_UCHAR(tui.icon_shading); - } - - if (!USER_VERSION_ATLEAST(280, 27)) { - FROM_DEFAULT_V4_UCHAR(space_action.shade2); - FROM_DEFAULT_V4_UCHAR(space_action.hilite); - FROM_DEFAULT_V4_UCHAR(space_action.group); - FROM_DEFAULT_V4_UCHAR(space_action.group_active); - FROM_DEFAULT_V4_UCHAR(space_action.strip_select); - FROM_DEFAULT_V4_UCHAR(space_action.ds_channel); - FROM_DEFAULT_V4_UCHAR(space_action.ds_subchannel); - FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold); - FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold_select); - } - - if (!USER_VERSION_ATLEAST(280, 28)) { - FROM_DEFAULT_V4_UCHAR(space_action.ds_ipoline); - } - - if (!USER_VERSION_ATLEAST(280, 29)) { - FROM_DEFAULT_V4_UCHAR(space_properties.navigation_bar); - } - if (!USER_VERSION_ATLEAST(280, 31)) { - FROM_DEFAULT_V4_UCHAR(space_clip.list_text); - } - - if (!USER_VERSION_ATLEAST(280, 36)) { - FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed); - FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed_sel); - } - - if (!USER_VERSION_ATLEAST(280, 39)) { - FROM_DEFAULT_V4_UCHAR(space_clip.metadatabg); - FROM_DEFAULT_V4_UCHAR(space_clip.metadatatext); - } - - if (!USER_VERSION_ATLEAST(280, 40)) { - FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar); - copy_v4_v4_uchar(btheme->space_preferences.execution_buts, - btheme->space_preferences.navigation_bar); - } - - if (!USER_VERSION_ATLEAST(280, 41)) { - FROM_DEFAULT_V4_UCHAR(space_view3d.back); - } - - if (!USER_VERSION_ATLEAST(280, 52)) { - FROM_DEFAULT_V4_UCHAR(space_info.info_info); - } - - if (!USER_VERSION_ATLEAST(280, 64)) { - FROM_DEFAULT_V4_UCHAR(tui.icon_scene); - - if (btheme->space_view3d.obcenter_dia == 0) { - btheme->space_view3d.obcenter_dia = U_theme_default.space_view3d.obcenter_dia; - } - - FROM_DEFAULT_V4_UCHAR(space_graph.text); - FROM_DEFAULT_V4_UCHAR(space_action.text); - FROM_DEFAULT_V4_UCHAR(space_nla.text); - FROM_DEFAULT_V4_UCHAR(space_sequencer.text); - FROM_DEFAULT_V4_UCHAR(space_clip.text); - - FROM_DEFAULT_V4_UCHAR(space_graph.time_scrub_background); - FROM_DEFAULT_V4_UCHAR(space_action.time_scrub_background); - FROM_DEFAULT_V4_UCHAR(space_nla.time_scrub_background); - FROM_DEFAULT_V4_UCHAR(space_sequencer.time_scrub_background); - FROM_DEFAULT_V4_UCHAR(space_clip.time_scrub_background); - } - - if (!USER_VERSION_ATLEAST(280, 67)) { - FROM_DEFAULT_V4_UCHAR(space_outliner.selected_object); - FROM_DEFAULT_V4_UCHAR(space_outliner.active_object); - FROM_DEFAULT_V4_UCHAR(space_outliner.edited_object); - FROM_DEFAULT_V4_UCHAR(space_outliner.row_alternate); - } - - if (!USER_VERSION_ATLEAST(281, 3)) { - FROM_DEFAULT_V4_UCHAR(space_outliner.selected_highlight); - FROM_DEFAULT_V4_UCHAR(space_outliner.active); - } - - if (!USER_VERSION_ATLEAST(281, 14)) { - FROM_DEFAULT_V4_UCHAR(space_file.execution_buts); - FROM_DEFAULT_V4_UCHAR(tui.icon_folder); - FROM_DEFAULT_V4_UCHAR(space_clip.path_keyframe_before); - FROM_DEFAULT_V4_UCHAR(space_clip.path_keyframe_after); - copy_v4_v4_uchar(btheme->space_nla.nla_track, btheme->space_nla.header); - } - - if (!USER_VERSION_ATLEAST(282, 5)) { - FROM_DEFAULT_V4_UCHAR(space_sequencer.anim_preview_range); - FROM_DEFAULT_V4_UCHAR(space_text.line_numbers); - FROM_DEFAULT_V4_UCHAR(tui.widget_text_cursor); - FROM_DEFAULT_V4_UCHAR(space_view3d.face_back); - FROM_DEFAULT_V4_UCHAR(space_view3d.face_front); - } - - if (!USER_VERSION_ATLEAST(283, 1)) { - FROM_DEFAULT_V4_UCHAR(space_view3d.bone_locked_weight); - } - - if (!USER_VERSION_ATLEAST(283, 2)) { - FROM_DEFAULT_V4_UCHAR(space_info.info_property); - FROM_DEFAULT_V4_UCHAR(space_info.info_property_text); - FROM_DEFAULT_V4_UCHAR(space_info.info_operator); - FROM_DEFAULT_V4_UCHAR(space_info.info_operator_text); - } - - if (!USER_VERSION_ATLEAST(283, 5)) { - FROM_DEFAULT_V4_UCHAR(space_graph.time_marker_line); - FROM_DEFAULT_V4_UCHAR(space_action.time_marker_line); - FROM_DEFAULT_V4_UCHAR(space_nla.time_marker_line); - FROM_DEFAULT_V4_UCHAR(space_sequencer.time_marker_line); - FROM_DEFAULT_V4_UCHAR(space_clip.time_marker_line); - FROM_DEFAULT_V4_UCHAR(space_graph.time_marker_line_selected); - FROM_DEFAULT_V4_UCHAR(space_action.time_marker_line_selected); - FROM_DEFAULT_V4_UCHAR(space_nla.time_marker_line_selected); - FROM_DEFAULT_V4_UCHAR(space_sequencer.time_marker_line_selected); - FROM_DEFAULT_V4_UCHAR(space_clip.time_marker_line_selected); - } - - if (!USER_VERSION_ATLEAST(283, 6)) { - btheme->space_node.grid_levels = U_theme_default.space_node.grid_levels; - } - - if (!USER_VERSION_ATLEAST(283, 9)) { - FROM_DEFAULT_V4_UCHAR(space_info.info_warning); - } - - if (!USER_VERSION_ATLEAST(283, 10)) { - FROM_DEFAULT_V4_UCHAR(tui.gizmo_view_align); - - FROM_DEFAULT_V4_UCHAR(space_sequencer.active_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.selected_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.color_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.mask); - } - - if (!USER_VERSION_ATLEAST(283, 11)) { - FROM_DEFAULT_V4_UCHAR(tui.transparent_checker_primary); - FROM_DEFAULT_V4_UCHAR(tui.transparent_checker_secondary); - btheme->tui.transparent_checker_size = U_theme_default.tui.transparent_checker_size; - } - if (!USER_VERSION_ATLEAST(291, 2)) { - /* The new defaults for the file browser theme are the same as - * the outliner's, and it's less disruptive to just copy them. */ - copy_v4_v4_uchar(btheme->space_file.back, btheme->space_outliner.back); - copy_v4_v4_uchar(btheme->space_file.row_alternate, btheme->space_outliner.row_alternate); - - FROM_DEFAULT_V4_UCHAR(space_image.grid); - } - - if (!USER_VERSION_ATLEAST(291, 3)) { - for (int i = 0; i < COLLECTION_COLOR_TOT; ++i) { - FROM_DEFAULT_V4_UCHAR(collection_color[i].color); - } - - FROM_DEFAULT_V4_UCHAR(space_properties.match); - - /* New grid theme color defaults are the same as the existing background colors, - * so they are copied to limit disruption. */ - copy_v3_v3_uchar(btheme->space_clip.grid, btheme->space_clip.back); - btheme->space_clip.grid[3] = 255.0f; - - copy_v3_v3_uchar(btheme->space_node.grid, btheme->space_node.back); - } - - if (!USER_VERSION_ATLEAST(291, 9)) { - FROM_DEFAULT_V4_UCHAR(space_graph.vertex_active); - } - - if (!USER_VERSION_ATLEAST(292, 5)) { - for (int i = 0; i < COLLECTION_COLOR_TOT; ++i) { - FROM_DEFAULT_V4_UCHAR(collection_color[i].color); - } - FROM_DEFAULT_V4_UCHAR(space_sequencer.row_alternate); - FROM_DEFAULT_V4_UCHAR(space_node.nodeclass_geometry); - FROM_DEFAULT_V4_UCHAR(space_node.nodeclass_attribute); - } - - if (!USER_VERSION_ATLEAST(292, 12)) { - FROM_DEFAULT_V4_UCHAR(space_node.nodeclass_shader); - } - - if (!USER_VERSION_ATLEAST(293, 15)) { - FROM_DEFAULT_V4_UCHAR(space_properties.active); - - FROM_DEFAULT_V4_UCHAR(space_info.info_error); - FROM_DEFAULT_V4_UCHAR(space_info.info_warning); - FROM_DEFAULT_V4_UCHAR(space_info.info_info); - FROM_DEFAULT_V4_UCHAR(space_info.info_debug); - FROM_DEFAULT_V4_UCHAR(space_info.info_debug_text); - FROM_DEFAULT_V4_UCHAR(space_info.info_property); - FROM_DEFAULT_V4_UCHAR(space_info.info_error); - FROM_DEFAULT_V4_UCHAR(space_info.info_operator); - - btheme->space_spreadsheet = btheme->space_outliner; - } - - if (!USER_VERSION_ATLEAST(300, 5)) { - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.active); - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list); - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list_text); - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.list_text_hi); - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.hilite); - FROM_DEFAULT_V4_UCHAR(space_spreadsheet.selected_highlight); - } - - if (!USER_VERSION_ATLEAST(300, 15)) { - copy_v4_uchar(btheme->space_sequencer.grid, 33); - btheme->space_sequencer.grid[3] = 255; - } - - if (!USER_VERSION_ATLEAST(300, 30)) { - FROM_DEFAULT_V4_UCHAR(space_node.wire); - } - - if (!USER_VERSION_ATLEAST(300, 31)) { - for (int i = 0; i < SEQUENCE_COLOR_TOT; ++i) { - FROM_DEFAULT_V4_UCHAR(strip_color[i].color); - } - } - - if (!USER_VERSION_ATLEAST(300, 33)) { - /* Adjust the frame node alpha now that it is used differently. */ - btheme->space_node.movie[3] = U_theme_default.space_node.movie[3]; - } - - if (!USER_VERSION_ATLEAST(300, 34)) { - btheme->tui.panel_roundness = 0.4f; - } - - if (!USER_VERSION_ATLEAST(300, 37)) { - btheme->space_node.dash_alpha = 0.5f; - } - - if (!USER_VERSION_ATLEAST(300, 39)) { - FROM_DEFAULT_V4_UCHAR(space_node.grid); - btheme->space_node.grid_levels = 7; - } - if (!USER_VERSION_ATLEAST(300, 41)) { memcpy(btheme, &U_theme_default, sizeof(*btheme)); } @@ -336,6 +83,10 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) FROM_DEFAULT_V4_UCHAR(space_sequencer.list_text_hi); } + if (!USER_VERSION_ATLEAST(303, 6)) { + btheme->tui.wcol_view_item = U_theme_default.tui.wcol_view_item; + } + /** * Versioning code until next subversion bump goes here. * @@ -347,7 +98,6 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) */ { /* Keep this block, even when empty. */ - btheme->tui.wcol_view_item = U_theme_default.tui.wcol_view_item; } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 68171f26a66..72337f98000 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -6,7 +6,6 @@ */ /** - * * FILE FORMAT * =========== * @@ -970,10 +969,15 @@ static void write_libraries(WriteData *wd, Main *main) if (found_one) { /* Not overridable. */ + void *runtime_name_data = main->curlib->runtime.name_map; + main->curlib->runtime.name_map = NULL; + BlendWriter writer = {wd}; writestruct(wd, ID_LI, Library, 1, main->curlib); BKE_id_blend_write(&writer, &main->curlib->id); + main->curlib->runtime.name_map = runtime_name_data; + if (main->curlib->packedfile) { BKE_packedfile_blend_write(&writer, main->curlib->packedfile); if (wd->use_memfile == false) { diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc index af570aa9d4b..7df0ce944e4 100644 --- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc +++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc @@ -116,7 +116,7 @@ bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath) } char abspath[FILENAME_MAX]; - BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL); + BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, nullptr); BlendFileReadReport bf_reports = {nullptr}; bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, &bf_reports); |