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
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-09-17 17:22:29 +0300
committerBastien Montagne <bastien@blender.org>2021-09-22 17:55:39 +0300
commit794c2828af60af02a38381c2a9a81f9046381074 (patch)
tree3c2c5c595c1c7e7f8a31598aa149ff6a4333b54c /source/blender/makesdna/DNA_ID.h
parent707bcd5693aedc0c1a461bbb0ce88680e32de561 (diff)
Initial implementation of local ID re-use when appending.
This commit adds to ID struct a new optional 'weak reference' to a linked ID (in the form of a blend file library path and full ID name). This can then be used on next append to try to find a matching local ID instead of re-making the linked data local again. Ref. T90545 NOTE: ID re-use will be disabled for regular append for the time being (3.0 release), and only used for assets. Therefore, this commit should not change anything user-wise. Differential Revision: https://developer.blender.org/D12545
Diffstat (limited to 'source/blender/makesdna/DNA_ID.h')
-rw-r--r--source/blender/makesdna/DNA_ID.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 5b7c99f2545..d829d707a71 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -392,7 +392,14 @@ typedef struct ID {
* that references this ID (the bones of an armature or the modifiers of an object for e.g.).
*/
void *py_instance;
- void *_pad1;
+
+ /**
+ * Weak reference to an ID in a given library file, used to allow re-using already appended data
+ * in some cases, instead of appending it again.
+ *
+ * May be NULL.
+ */
+ struct LibraryWeakReference *library_weak_reference;
} ID;
/**
@@ -426,6 +433,26 @@ typedef struct Library {
short versionfile, subversionfile;
} Library;
+/**
+ * A weak library/ID reference for local data that has been appended, to allow re-using that local
+ * data instead of creating a new copy of it in future appends.
+ *
+ * NOTE: This is by design a week reference, in other words code should be totally fine and perform
+ * a regular append if it cannot find a valid matching local ID.
+ *
+ * NOTE: There should always be only one single ID in current Main matching a given linked
+ * reference.
+ */
+typedef struct LibraryWeakReference {
+ /** Expected to match a `Library.filepath`. */
+ char library_filepath[1024];
+
+ /** MAX_ID_NAME. May be different from the current local ID name. */
+ char library_id_name[66];
+
+ char _pad[2];
+} LibraryWeakReference;
+
/* for PreviewImage->flag */
enum ePreviewImage_Flag {
PRV_CHANGED = (1 << 0),