diff options
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 55 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 135 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_common.cc | 54 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_common.h | 8 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 35 |
7 files changed, 234 insertions, 58 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0b69395b4f8..600abcca818 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2211,6 +2211,9 @@ static void direct_link_id_common( if (id->asset_data) { BLO_read_data_address(reader, &id->asset_data); BKE_asset_metadata_read(reader, id->asset_data); + /* Restore runtime asset type info. */ + const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); + id->asset_data->local_type_info = id_type->asset_type_info; } /* Link direct data of ID properties. */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index e6247750759..e809d580fd2 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1717,18 +1717,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) } } - /** - * Versioning code until next subversion bump goes here. - * - * \note Be sure to check when bumping the version: - * - #blo_do_versions_280 in this file. - * - "versioning_userdef.c", #blo_do_versions_userdef - * - "versioning_userdef.c", #do_versions_theme - * - * \note Keep this message at the bottom of the function. - */ - { - /* Keep this block, even when empty. */ + /* Old forgotten versioning code. */ + if (!MAIN_VERSION_ATLEAST(bmain, 300, 39)) { /* Paint Brush. This ensure that the brush paints by default. Used during the development and * patch review of the initial Sculpt Vertex Colors implementation (D5975) */ LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { @@ -1748,6 +1738,20 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) } } } + + /** + * Versioning code until next subversion bump goes here. + * + * \note Be sure to check when bumping the version: + * - #blo_do_versions_280 in this file. + * - "versioning_userdef.c", #blo_do_versions_userdef + * - "versioning_userdef.c", #do_versions_theme + * + * \note Keep this message at the bottom of the function. + */ + { + /* Keep this block, even when empty. */ + } } /* NOTE: This version patch is intended for versions < 2.52.2, @@ -5066,17 +5070,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /** - * Versioning code until next subversion bump goes here. - * - * \note Be sure to check when bumping the version: - * - #do_versions_after_linking_280 in this file. - * - "versioning_userdef.c", #blo_do_versions_userdef - * - "versioning_userdef.c", #do_versions_theme - * - * \note Keep this message at the bottom of the function. - */ - { + /* Old forgotten versioning code. */ + if (!MAIN_VERSION_ATLEAST(bmain, 300, 39)) { /* Set the cloth wind factor to 1 for old forces. */ if (!DNA_struct_elem_find(fd->filesdna, "PartDeflect", "float", "f_wind_factor")) { LISTBASE_FOREACH (Object *, ob, &bmain->objects) { @@ -5096,10 +5091,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { /* Don't rotate light with the viewer by default, make it fixed. Shading settings can't be - * edited and this flag should always be set. So we can always execute this. */ + * edited and this flag should always be set. */ wm->xr.session_settings.shading.flag |= V3D_SHADING_WORLD_ORIENTATION; } + } + /** + * Versioning code until next subversion bump goes here. + * + * \note Be sure to check when bumping the version: + * - #do_versions_after_linking_280 in this file. + * - "versioning_userdef.c", #blo_do_versions_userdef + * - "versioning_userdef.c", #do_versions_theme + * + * \note Keep this message at the bottom of the function. + */ + { /* Keep this block, even when empty. */ } } diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index d2c722f8be7..def14768ec6 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -1985,7 +1985,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 293, 18)) { FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_GEOMETRY) { - version_node_socket_name(ntree, GEO_NODE_VOLUME_TO_MESH, "Grid", "Density"); + version_node_socket_name(ntree, GEO_NODE_LEGACY_VOLUME_TO_MESH, "Grid", "Density"); } } FOREACH_NODETREE_END; diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 8168b917b5e..68faa4c0672 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -535,7 +535,7 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree) } /* Also realize instances for the profile input of the curve to mesh node. */ if (node->type == GEO_NODE_CURVE_TO_MESH) { - bNodeSocket *profile_socket = node->inputs.last; + bNodeSocket *profile_socket = (bNodeSocket *)BLI_findlink(&node->inputs, 1); add_realize_instances_before_socket(ntree, node, profile_socket); } } @@ -967,7 +967,7 @@ static bool geometry_node_is_293_legacy(const short node_type) /* Maybe legacy: Special case for grid names? Or finish patch from level set branch to * generate a mesh for all grids in the volume. */ - case GEO_NODE_VOLUME_TO_MESH: + case GEO_NODE_LEGACY_VOLUME_TO_MESH: return false; /* Legacy: Transferred *all* attributes before, will not transfer all built-ins now. */ @@ -1218,6 +1218,56 @@ static void do_version_bones_roll(ListBase *lb) } } +static void version_geometry_nodes_set_position_node_offset(bNodeTree *ntree) +{ + /* Add the new Offset socket. */ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type != GEO_NODE_SET_POSITION) { + continue; + } + if (BLI_listbase_count(&node->inputs) < 4) { + /* The offset socket didn't exist in the file yet. */ + return; + } + bNodeSocket *old_offset_socket = BLI_findlink(&node->inputs, 3); + if (old_offset_socket->type == SOCK_VECTOR) { + /* Versioning happened already. */ + return; + } + /* Change identifier of old socket, so that the there is no name collision. */ + STRNCPY(old_offset_socket->identifier, "Offset_old"); + nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_VECTOR, PROP_TRANSLATION, "Offset", "Offset"); + } + + /* Relink links that were connected to Position while Offset was enabled. */ + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + if (link->tonode->type != GEO_NODE_SET_POSITION) { + continue; + } + if (!STREQ(link->tosock->identifier, "Position")) { + continue; + } + bNodeSocket *old_offset_socket = BLI_findlink(&link->tonode->inputs, 3); + /* This assumes that the offset is not linked to something else. That seems to be a reasonable + * assumption, because the node is probably only ever used in one or the other mode. */ + const bool offset_enabled = + ((bNodeSocketValueBoolean *)old_offset_socket->default_value)->value; + if (offset_enabled) { + /* Relink to new offset socket. */ + link->tosock = old_offset_socket->next; + } + } + + /* Remove old Offset socket. */ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type != GEO_NODE_SET_POSITION) { + continue; + } + bNodeSocket *old_offset_socket = BLI_findlink(&node->inputs, 3); + nodeRemoveSocket(ntree, node, old_offset_socket); + } +} + /* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) { @@ -2021,6 +2071,79 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 300, 39)) { + LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) { + wm->xr.session_settings.base_scale = 1.0f; + wm->xr.session_settings.draw_flags |= (V3D_OFSDRAW_SHOW_SELECTION | + V3D_OFSDRAW_XR_SHOW_CONTROLLERS | + V3D_OFSDRAW_XR_SHOW_CUSTOM_OVERLAYS); + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 300, 40)) { + /* Update the `idnames` for renamed geometry and function nodes. */ + LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { + if (ntree->type != NTREE_GEOMETRY) { + continue; + } + version_node_id(ntree, FN_NODE_SLICE_STRING, "FunctionNodeSliceString"); + version_geometry_nodes_set_position_node_offset(ntree); + version_node_id(ntree, GEO_NODE_LEGACY_VOLUME_TO_MESH, "GeometryNodeLegacyVolumeToMesh"); + } + + /* Add storage to viewer node. */ + LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { + if (ntree->type != NTREE_GEOMETRY) { + continue; + } + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == GEO_NODE_VIEWER) { + if (node->storage == NULL) { + NodeGeometryViewer *data = (NodeGeometryViewer *)MEM_callocN( + sizeof(NodeGeometryViewer), __func__); + data->data_type = CD_PROP_FLOAT; + node->storage = data; + } + } + } + } + + LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { + if (ntree->type == NTREE_GEOMETRY) { + version_node_input_socket_name( + ntree, GEO_NODE_DISTRIBUTE_POINTS_ON_FACES, "Geometry", "Mesh"); + version_node_input_socket_name(ntree, GEO_NODE_POINTS_TO_VOLUME, "Geometry", "Points"); + version_node_output_socket_name(ntree, GEO_NODE_POINTS_TO_VOLUME, "Geometry", "Volume"); + version_node_socket_name(ntree, GEO_NODE_SUBDIVISION_SURFACE, "Geometry", "Mesh"); + version_node_socket_name(ntree, GEO_NODE_RESAMPLE_CURVE, "Geometry", "Curve"); + version_node_socket_name(ntree, GEO_NODE_SUBDIVIDE_CURVE, "Geometry", "Curve"); + version_node_socket_name(ntree, GEO_NODE_SET_CURVE_RADIUS, "Geometry", "Curve"); + version_node_socket_name(ntree, GEO_NODE_SET_CURVE_TILT, "Geometry", "Curve"); + version_node_socket_name(ntree, GEO_NODE_SET_CURVE_HANDLES, "Geometry", "Curve"); + version_node_socket_name(ntree, GEO_NODE_TRANSLATE_INSTANCES, "Geometry", "Instances"); + version_node_socket_name(ntree, GEO_NODE_ROTATE_INSTANCES, "Geometry", "Instances"); + version_node_socket_name(ntree, GEO_NODE_SCALE_INSTANCES, "Geometry", "Instances"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_BOOLEAN, "Geometry", "Mesh"); + version_node_input_socket_name(ntree, GEO_NODE_MESH_BOOLEAN, "Geometry 1", "Mesh 1"); + version_node_input_socket_name(ntree, GEO_NODE_MESH_BOOLEAN, "Geometry 2", "Mesh 2"); + version_node_socket_name(ntree, GEO_NODE_SUBDIVIDE_MESH, "Geometry", "Mesh"); + version_node_socket_name(ntree, GEO_NODE_TRIANGULATE, "Geometry", "Mesh"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_CONE, "Geometry", "Mesh"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_CUBE, "Geometry", "Mesh"); + version_node_output_socket_name( + ntree, GEO_NODE_MESH_PRIMITIVE_CYLINDER, "Geometry", "Mesh"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_GRID, "Geometry", "Mesh"); + version_node_output_socket_name( + ntree, GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE, "Geometry", "Mesh"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_CIRCLE, "Geometry", "Mesh"); + version_node_output_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_LINE, "Geometry", "Mesh"); + version_node_output_socket_name( + ntree, GEO_NODE_MESH_PRIMITIVE_UV_SPHERE, "Geometry", "Mesh"); + version_node_socket_name(ntree, GEO_NODE_SET_POINT_RADIUS, "Geometry", "Points"); + } + } + } + /** * Versioning code until next subversion bump goes here. * @@ -2030,15 +2153,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) * * \note Keep this message at the bottom of the function. */ - { - /* Update the `idnames` for renamed geometry and function nodes. */ - LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { - if (ntree->type != NTREE_GEOMETRY) { - continue; - } - version_node_id(ntree, FN_NODE_SLICE_STRING, "FunctionNodeSliceString"); - } /* Keep this block, even when empty. */ } } diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 6c4996ba9b2..ecc944defba 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -87,6 +87,18 @@ ID *do_versions_rename_id(Main *bmain, return id; } +static void change_node_socket_name(ListBase *sockets, const char *old_name, const char *new_name) +{ + LISTBASE_FOREACH (bNodeSocket *, socket, sockets) { + if (STREQ(socket->name, old_name)) { + BLI_strncpy(socket->name, new_name, sizeof(socket->name)); + } + if (STREQ(socket->identifier, old_name)) { + BLI_strncpy(socket->identifier, new_name, sizeof(socket->name)); + } + } +} + void version_node_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, @@ -94,22 +106,32 @@ void version_node_socket_name(bNodeTree *ntree, { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == node_type) { - LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) { - if (STREQ(socket->name, old_name)) { - BLI_strncpy(socket->name, new_name, sizeof(socket->name)); - } - if (STREQ(socket->identifier, old_name)) { - BLI_strncpy(socket->identifier, new_name, sizeof(socket->name)); - } - } - LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) { - if (STREQ(socket->name, old_name)) { - BLI_strncpy(socket->name, new_name, sizeof(socket->name)); - } - if (STREQ(socket->identifier, old_name)) { - BLI_strncpy(socket->identifier, new_name, sizeof(socket->name)); - } - } + change_node_socket_name(&node->inputs, old_name, new_name); + change_node_socket_name(&node->outputs, old_name, new_name); + } + } +} + +void version_node_input_socket_name(bNodeTree *ntree, + const int node_type, + const char *old_name, + const char *new_name) +{ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == node_type) { + change_node_socket_name(&node->inputs, old_name, new_name); + } + } +} + +void version_node_output_socket_name(bNodeTree *ntree, + const int node_type, + const char *old_name, + const char *new_name) +{ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == node_type) { + change_node_socket_name(&node->outputs, old_name, new_name); } } } diff --git a/source/blender/blenloader/intern/versioning_common.h b/source/blender/blenloader/intern/versioning_common.h index 1826182be21..8697e8e2639 100644 --- a/source/blender/blenloader/intern/versioning_common.h +++ b/source/blender/blenloader/intern/versioning_common.h @@ -43,6 +43,14 @@ void version_node_socket_name(struct bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name); +void version_node_input_socket_name(struct bNodeTree *ntree, + const int node_type, + const char *old_name, + const char *new_name); +void version_node_output_socket_name(struct bNodeTree *ntree, + const int node_type, + const char *old_name, + const char *new_name); void version_node_id(struct bNodeTree *ntree, const int node_type, const char *new_name); diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 170e6be715a..4234570af6c 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -27,9 +27,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#ifdef WITH_INTERNATIONAL -# include "BLT_translation.h" -#endif +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_collection_types.h" @@ -60,10 +58,6 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) { #define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver) - if (!USER_VERSION_ATLEAST(280, 20)) { - memcpy(btheme, &U_theme_default, sizeof(*btheme)); - } - #define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_uchar(btheme->member, U_theme_default.member) if (!USER_VERSION_ATLEAST(280, 25)) { @@ -314,6 +308,15 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) 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, 40)) { + memcpy(btheme, &U_theme_default, sizeof(*btheme)); + } + /** * Versioning code until next subversion bump goes here. * @@ -923,6 +926,24 @@ void blo_do_versions_userdef(UserDef *userdef) userdef->dupflag |= USER_DUP_SPEAKER; } + if (!USER_VERSION_ATLEAST(300, 40)) { + /* Rename the default asset library from "Default" to "User Library" */ + LISTBASE_FOREACH (bUserAssetLibrary *, asset_library, &userdef->asset_libraries) { + if (STREQ(asset_library->name, DATA_("Default"))) { + BKE_preferences_asset_library_name_set( + userdef, asset_library, BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME); + } + } + } + + if (!USER_VERSION_ATLEAST(300, 40)) { + LISTBASE_FOREACH (uiStyle *, style, &userdef->uistyles) { + const int default_title_points = 11; /* UI_DEFAULT_TITLE_POINTS */ + style->paneltitle.points = default_title_points; + style->grouplabel.points = default_title_points; + } + } + /** * Versioning code until next subversion bump goes here. * |