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:
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c38
-rw-r--r--source/blender/blenloader/intern/writefile.c8
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e4822c4cb7f..9a5f6ac6bbc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -108,11 +108,14 @@
#include "BLI_mempool.h"
#include "BLI_threads.h"
+#include "RNA_types.h"
+
#include "BLT_translation.h"
#include "BKE_action.h"
#include "BKE_anim_data.h"
#include "BKE_armature.h"
+#include "BKE_asset_engine.h"
#include "BKE_brush.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
@@ -2876,6 +2879,12 @@ static void direct_link_id_common(
BLI_listbase_clear((ListBase *)drawdata);
}
+ if (id->uuid) {
+ BLO_read_data_address(reader, &id->uuid);
+ /* Make sure runtime fields are always zeroed out. */
+ BKE_asset_uuid_runtime_reset(id->uuid);
+ }
+
/* Handle 'private IDs'. */
direct_link_id_embedded_id(reader, current_library, id, id_old);
}
@@ -9555,6 +9564,18 @@ static BHead *read_libblock(FileData *fd,
}
}
+ if (id->uuid) {
+ /* Read all data into fd->datamap. */
+ bhead = read_data_into_datamap(fd, bhead, __func__);
+
+ id->uuid = newdataadr(fd, id->uuid);
+ /* Make sure runtime fields are always zeroed out. */
+ BKE_asset_uuid_runtime_reset(id->uuid);
+
+ oldnewmap_clear(fd->datamap);
+ return bhead;
+ }
+
direct_link_id(fd, main, id_tag, id, id_old);
return blo_bhead_next(fd, bhead);
}
@@ -12134,6 +12155,21 @@ static void read_library_linked_ids(FileData *basefd,
* (known case: some directly linked shapekey from a missing lib...). */
/* BLI_assert(*realid != NULL); */
+ if (*realid && id->uuid) {
+ /* it is important to keep the UUID we stored in that .blend file, not the (potentially
+ * different) one we get from the library, updating UUID should be handled by asset
+ * engine later - even though changing UUID is not recommended in any case. */
+ if ((*realid)->uuid != NULL) {
+ MEM_SAFE_FREE((*realid)->uuid);
+ }
+ /* We can give ownership of that pointer to new ID. */
+ (*realid)->uuid = id->uuid;
+ id->uuid = NULL;
+ }
+ else {
+ MEM_SAFE_FREE(id->uuid);
+ }
+
/* Now that we have a real ID, replace all pointers to placeholders in
* fd->libmap with pointers to the real data-blocks. We do this for all
* libraries since multiple might be referencing this ID. */
@@ -12148,6 +12184,8 @@ static void read_library_linked_ids(FileData *basefd,
/* Clear GHash and free link placeholder IDs of the current type. */
BLI_ghash_clear(loaded_ids, NULL, NULL);
+ /* Note: this is currently just freeing ID struct itself, assuming there is no remaining
+ * allocated sub-data owned by this ID. */
BLI_freelistN(&pending_free_ids);
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 4e0325e72fa..d8576b4c6de 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -738,6 +738,9 @@ static void write_iddata(BlendWriter *writer, ID *id)
if (id->properties && !ELEM(GS(id->name), ID_WM)) {
IDP_WriteProperty(id->properties, writer);
}
+ if (id->uuid) {
+ BLO_write_struct(writer, AssetUUID, id->uuid);
+ }
if (id->override_library) {
BLO_write_struct(writer, IDOverrideLibrary, id->override_library);
@@ -3926,6 +3929,11 @@ static void write_libraries(WriteData *wd, Main *main)
BLI_assert(0);
}
writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id);
+ /* It is mandatory to write id's asset uuid reference for placeholders too, otherwise
+ * the whole asset info would be completely lost when reloading the linked data-block,
+ * especially in case it is not immediately found and needs to go through the whole
+ * 'asset engine update' process after main .blend read process is finished. */
+ write_iddata(&writer, id);
}
}
}