From d7c802c25f7e41861fe42694131871cccd6f5605 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 23 Feb 2022 14:56:42 +0100 Subject: LibOverride: Add initial handling of system overrides in creation/duplication/resync code, and some basic do_version. When creating with hierarchies, core code only generates system overrides, responsibility to define 'user overrides' is then for the higher-level calling code (Editor/Operator-level). do_version code uses fairly basic euristics, should be good enough here though in most cases. and can always be refined later if needed. Ref: {T95707}. --- source/blender/blenloader/intern/versioning_300.c | 45 +++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 37a6619876d..c9d519be450 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -2435,17 +2435,27 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /** - * Versioning code until next subversion bump goes here. - * - * \note Be sure to check when bumping the version: - * - "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. */ + if (!MAIN_VERSION_ATLEAST(bmain, 302, 7)) { + /* Generate 'system' liboverrides IDs. + * NOTE: This is a fairly rough process, based on very basic euristics. Should be enough for a + * do_version code though, this is a new optional feature, not a critical conversion. */ + ID *id; + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || ID_IS_LINKED(id)) { + /* Ignore non-real liboverrides, and linked ones. */ + continue; + } + if (GS(id->name) == ID_OB) { + /* Never 'lock' an object into a system override for now. */ + continue; + } + if (BKE_lib_override_library_is_user_edited(id)) { + /* Do not 'lock' an ID already edited by the user. */ + continue; + } + id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + } + FOREACH_MAIN_ID_END; /* Initialize brush curves sculpt settings. */ LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { @@ -2476,4 +2486,17 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /** + * Versioning code until next subversion bump goes here. + * + * \note Be sure to check when bumping the version: + * - "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. */ + } } -- cgit v1.2.3