Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-02-23 16:56:42 +0300
committerBastien Montagne <bastien@blender.org>2022-03-29 18:59:17 +0300
commitd7c802c25f7e41861fe42694131871cccd6f5605 (patch)
tree9b6619ff5a81d00ea8ee033835f84628daf7a5bd /source
parentb5f2c776587d1e155da868cfbe530f56f1182310 (diff)
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}.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/intern/lib_override.c6
-rw-r--r--source/blender/blenkernel/intern/lib_override_proxy_conversion.c1
-rw-r--r--source/blender/blenloader/intern/versioning_300.c45
4 files changed, 42 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 1639a564508..7686fce3aca 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 6
+#define BLENDER_FILE_SUBVERSION 7
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index c0d49105dad..edb23f51308 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -122,6 +122,9 @@ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id)
local_id->override_library->reference = reference_id;
id_us_plus(local_id->override_library->reference);
local_id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK;
+ /* By default initialized libioverrides are 'system overrides', higher-level code is responsible
+ * to unset this flag for specific IDs. */
+ local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
/* TODO: do we want to add tag or flag to referee to mark it as such? */
return local_id->override_library;
}
@@ -300,6 +303,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
* mess in case there are a lot of hidden, non-instantiated, non-properly organized dependencies.
* Ref T94650. */
local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY;
+ local_id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
local_id->override_library->hierarchy_root = local_id;
if (do_tagged_remap) {
@@ -1647,6 +1651,8 @@ static bool lib_override_library_resync(Main *bmain,
if (ID_IS_OVERRIDE_LIBRARY_REAL(id_override_new)) {
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_override_old));
+ id_override_new->override_library->flag = id_override_old->override_library->flag;
+
/* Copy over overrides rules from old override ID to new one. */
BLI_duplicatelist(&id_override_new->override_library->properties,
&id_override_old->override_library->properties);
diff --git a/source/blender/blenkernel/intern/lib_override_proxy_conversion.c b/source/blender/blenkernel/intern/lib_override_proxy_conversion.c
index dc164313788..5e9d8e8c4d0 100644
--- a/source/blender/blenkernel/intern/lib_override_proxy_conversion.c
+++ b/source/blender/blenkernel/intern/lib_override_proxy_conversion.c
@@ -62,6 +62,7 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
ob_proxy->proxy->id.tag |= LIB_TAG_DOIT;
ob_proxy->proxy->id.newid = &ob_proxy->id;
BKE_lib_override_library_init(&ob_proxy->id, &ob_proxy->proxy->id);
+ ob_proxy->id.override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
ob_proxy->proxy->proxy_from = NULL;
ob_proxy->proxy = ob_proxy->proxy_group = NULL;
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. */
+ }
}