Commit: f2f4c4c93d8fa93c95251ca6fd573717df7f7259
Author: Bastien Montagne
Date:   Tue Jun 2 14:04:06 2015 +0200
Branches: asset-engine
https://developer.blender.org/rBf2f4c4c93d8fa93c95251ca6fd573717df7f7259

WIP more work towards inclusion of asset engine/asset uuids in linking process.

===================================================================

M       source/blender/blenkernel/intern/library.c
M       source/blender/blenloader/BLO_readfile.h
M       source/blender/blenloader/intern/readfile.c
M       source/blender/makesdna/DNA_ID.h
M       source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index 5546fb4..d0454cd 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1410,6 +1410,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
        }
 
        id->lib = NULL;
+       MEM_SAFE_FREE(id->uuid);  /* Local ID have no more use for 
asset-related data. */
        id->flag = LIB_LOCAL;
        new_id(which_libbase(bmain, GS(id->name)), id, NULL);
 
@@ -1420,6 +1421,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
 
        if (ntree) {
                ntree->id.lib = NULL;
+               MEM_SAFE_FREE(ntree->id.uuid);
        }
 }
 
diff --git a/source/blender/blenloader/BLO_readfile.h 
b/source/blender/blenloader/BLO_readfile.h
index 5f881c0..60dcf8c 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -36,6 +36,8 @@
 extern "C" {
 #endif
 
+struct AssetEngineType;
+struct AssetUUID;
 struct bScreen;
 struct LinkNode;
 struct Main;
@@ -245,6 +247,23 @@ struct ID *BLO_library_append_named_part(
 struct ID *BLO_library_append_named_part_ex(
         const struct bContext *C, struct Main *mainl, BlendHandle **bh,
         const char *idname, const int idcode, const short flag);
+/**
+ * Link/Append a named datablock from an external blend file.
+ * optionally instance the object in the scene when the flags are set.
+ *
+ * \param C The context, when NULL instancing object in the scene isn't done.
+ * \param mainl The main database to link from (not the active one).
+ * \param bh The blender file handle.
+ * \param aet The asset engine type (NULL when no asset engine is used).
+ * \param idname The name of the datablock (without the 2 char ID prefix)
+ * \param idcode The kind of datablock to link.
+ * \param uuid The asset engine's UUID of this datablock (NULL when no asset 
engine is used).
+ * \param flag Options for linking, used for instancing.
+ * \return the appended ID when found.
+ */
+struct ID *BLO_library_append_named_part_asset(
+        const struct bContext *C, struct Main *mainl, BlendHandle **bh, const 
struct AssetEngineType *aet,
+        const char *idname, const int idcode, const struct AssetUUID *uuid, 
const int flag);
 
 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, 
BlendHandle **bh, int idcode, short flag);
 
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 19d8c79..64fd58c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -109,10 +109,13 @@
 #include "BLI_threads.h"
 #include "BLI_mempool.h"
 
+#include "RNA_types.h"
+
 #include "BLF_translation.h"
 
 #include "BKE_action.h"
 #include "BKE_armature.h"
+#include "BKE_asset.h"
 #include "BKE_brush.h"
 #include "BKE_cloth.h"
 #include "BKE_constraint.h"
@@ -9342,7 +9345,9 @@ void BLO_library_append_all(Main *mainl, BlendHandle *bh)
 }
 
 
-static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, 
const char *idname, const int idcode, const int flag)
+static ID *append_named_part_ex(
+        const bContext *C, Main *mainl, FileData *fd, const AssetEngineType 
*aet,
+        const char *idname, const int idcode, const AssetUUID *uuid, const int 
flag)
 {
        ID *id= append_named_part(mainl, fd, idname, idcode);
 
@@ -9393,7 +9398,15 @@ ID *BLO_library_append_named_part(Main *mainl, 
BlendHandle **bh, const char *idn
 ID *BLO_library_append_named_part_ex(const bContext *C, Main *mainl, 
BlendHandle **bh, const char *idname, const int idcode, const short flag)
 {
        FileData *fd = (FileData*)(*bh);
-       return append_named_part_ex(C, mainl, fd, idname, idcode, flag);
+       return append_named_part_ex(C, mainl, fd, NULL, idname, idcode, NULL, 
flag);
+}
+
+ID *BLO_library_append_named_part_asset(
+        const bContext *C, Main *mainl, BlendHandle **bh, const 
AssetEngineType *aet,
+        const char *idname, const int idcode, const AssetUUID *uuid, const int 
flag)
+{
+       FileData *fd = (FileData*)(*bh);
+       return append_named_part_ex(C, mainl, fd, aet, idname, idcode, uuid, 
flag);
 }
 
 static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index fb76f9b..d23e50c 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -162,8 +162,7 @@ typedef struct Library {
        ID id;
        ID *idblock;
        struct FileData *filedata;
-       /* path name used for reading, can be relative and edited in the 
outliner.
-     * In case it's an asset engine, it's path from asset engine's 'root'. */
+       /* path name used for reading, can be relative and edited in the 
outliner. */
        char name[1024];
 
        /* absolute filepath, this is only for convenience, 'name' is the real 
path used on file read but in
diff --git a/source/blender/windowmanager/intern/wm_operators.c 
b/source/blender/windowmanager/intern/wm_operators.c
index 159892b..3ad32a7 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2656,6 +2656,9 @@ static void wm_link_append_do_libgroup(
        }
 
        if (name) {
+               /* No uuid/asset-handling here, name is never defined in this 
case. */
+               BLI_assert(aet == NULL);
+
                BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, 
flag);
        }
        else {
@@ -2680,13 +2683,18 @@ static void wm_link_append_do_libgroup(
                                curr_idcode = BKE_idcode_from_name(group);
 
                                if ((idcode == curr_idcode) && 
(BLI_path_cmp(curr_libname, libname) == 0)) {
-                                       AssetUUID asset_uuid;
+                                       if (aet) {
+                                               AssetUUID asset_uuid;
 
-                                       RNA_int_get_array(&itemptr, 
"asset_uuid", asset_uuid.uuid_asset);
-                                       RNA_int_get_array(&itemptr, 
"variant_uuid", asset_uuid.uuid_variant);
-                                       RNA_int_get_array(&itemptr, 
"revision_uuid", asset_uuid.uuid_revision);
+                                               RNA_int_get_array(&itemptr, 
"asset_uuid", asset_uuid.uuid_asset);
+                                               RNA_int_get_array(&itemptr, 
"variant_uuid", asset_uuid.uuid_variant);
+                                               RNA_int_get_array(&itemptr, 
"revision_uuid", asset_uuid.uuid_revision);
 
-                                       BLO_library_append_named_part_ex(C, 
mainl, &bh, name, idcode, flag);
+                                               
BLO_library_append_named_part_asset(C, mainl, &bh, aet, name, idcode, 
&asset_uuid, flag);
+                                       }
+                                       else {
+                                               
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
+                                       }
                                }
                                else if (is_first_run) {
                                        BLI_join_dirfile(path, sizeof(path), 
curr_libname, group);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to