[Bf-blender-cvs] [21884834561] asset-engine: Merge branch 'blender2.8' into asset-engine

Bastien Montagne noreply at git.blender.org
Mon Dec 4 14:39:37 CET 2017


Commit: 21884834561ebf0c76c271bc1d2fb30ff74483b4
Author: Bastien Montagne
Date:   Mon Dec 4 14:38:47 2017 +0100
Branches: asset-engine
https://developer.blender.org/rB21884834561ebf0c76c271bc1d2fb30ff74483b4

Merge branch 'blender2.8' into asset-engine

Conflicts:
	source/blender/blenloader/BLO_readfile.h
	source/blender/blenloader/intern/readfile.c
	source/blender/windowmanager/intern/wm_files_link.c

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



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

diff --cc source/blender/blenloader/BLO_readfile.h
index f9beff7a871,0da15fe5bbc..c5289e477f3
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@@ -121,20 -119,24 +121,30 @@@ void BLO_blendhandle_close(BlendHandle 
  bool BLO_has_bfile_extension(const char *str);
  bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);
  
+ /* Options controlling behavior of append/link code.
+  * Note: merged with 'user-level' options from operators etc. in 16 lower bits
+  *       (see eFileSel_Params_Flag in DNA_space_types.h). */
+ typedef enum BLO_LibLinkFlags {
+ 	/* Generate a placeholder (empty ID) if not found in current lib file. */
+ 	BLO_LIBLINK_USE_PLACEHOLDERS = 1 << 16,
+ 	/* Force loaded ID to be tagged as LIB_TAG_INDIRECT (used in reload context only). */
+ 	BLO_LIBLINK_FORCE_INDIRECT   = 1 << 17,
++	/* Generate a local override of the linked datablock. */
++	BLO_LIBLINK_GENERATE_OVERRIDE = 1 << 18,
+ } BLO_LinkFlags;
+ 
  struct Main *BLO_library_link_begin(struct Main *mainvar, BlendHandle **bh, const char *filepath);
  struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name);
  struct ID *BLO_library_link_named_part_ex(
          struct Main *mainl, BlendHandle **bh,
-         const short idcode, const char *name, const short flag,
-         struct Scene *scene, struct ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect);
+         const short idcode, const char *name, const int flag,
+         struct Scene *scene, struct ViewLayer *view_layer);
 +struct ID *BLO_library_link_named_part_asset(
 +        struct Main *mainl, BlendHandle **bh, const struct AssetEngineType *aet, const char *root,
-         const short idcode, const char *name, const struct AssetUUID *uuid, const short flag,
-         struct Scene *scene, struct ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect);
++        const short idcode, const char *name, const struct AssetUUID *uuid, const int flag,
++        struct Scene *scene, struct ViewLayer *view_layer);
  void BLO_library_link_end(
-         struct Main *mainl, BlendHandle **bh, short flag, struct Scene *scene, struct ViewLayer *view_layer);
+         struct Main *mainl, BlendHandle **bh, int flag, struct Scene *scene, struct ViewLayer *view_layer);
  
  void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh);
  
diff --cc source/blender/blenloader/intern/readfile.c
index 1cdfbc0a061,6df5a505788..ad606a6576f
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -10470,12 -10499,10 +10541,11 @@@ void BLO_library_link_copypaste(Main *m
  }
  
  static ID *link_named_part_ex(
 -        Main *mainl, FileData *fd, const short idcode, const char *name, const int flag,
 +        Main *mainl, FileData *fd, const AssetEngineType *aet, const char *root,
-         const short idcode, const char *name, const AssetUUID *uuid, const short flag,
-         Scene *scene, ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect)
++        const short idcode, const char *name, const AssetUUID *uuid, const int flag,
+         Scene *scene, ViewLayer *view_layer)
  {
- 	ID *id = link_named_part(mainl, fd, idcode, name, use_placeholders, force_indirect);
+ 	ID *id = link_named_part(mainl, fd, idcode, name, flag);
  
  	if (id && (GS(id->name) == ID_OB)) {	/* loose object: give a base */
  		link_object_postprocess(id, scene, view_layer, flag);
@@@ -10535,40 -10546,11 +10603,38 @@@ ID *BLO_library_link_named_part(Main *m
   */
  ID *BLO_library_link_named_part_ex(
          Main *mainl, BlendHandle **bh,
-         const short idcode, const char *name, const short flag,
-         Scene *scene, ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect)
+         const short idcode, const char *name, const int flag,
+         Scene *scene, ViewLayer *view_layer)
  {
  	FileData *fd = (FileData*)(*bh);
 -	return link_named_part_ex(mainl, fd, idcode, name, flag, scene, view_layer);
 +	return link_named_part_ex(
- 	            mainl, fd, NULL, NULL, idcode, name, NULL, flag, scene, view_layer, use_placeholders, force_indirect);
++	            mainl, fd, NULL, NULL, idcode, name, NULL, flag, scene, view_layer);
 +}
 +
 +/**
 + * Link a named datablock from an external blend file, using given asset engine & asset UUID.
 + * Optionally instantiate the object/group in the scene when the flags are set.
 + *
 + * \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 root the 'path' of the asset repository.
 + * \param idcode The kind of datablock to link.
 + * \param name The name of the datablock (without the 2 char ID prefix).
 + * \param uuid The asset engine's UUID of this datablock (NULL when no asset engine is used).
 + * \param flag Options for linking, used for instantiating.
 + * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done).
 + * \param sl The active SceneLayer (where objects & groups would be instantiated, can be NULL).
 + * \return the linked ID when found.
 + */
 +struct ID *BLO_library_link_named_part_asset(
 +        Main *mainl, BlendHandle **bh, const AssetEngineType *aet, const char *root,
-         const short idcode, const char *name, const AssetUUID *uuid, const short flag,
-         Scene *scene, ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect)
++        const short idcode, const char *name, const AssetUUID *uuid, const int flag,
++        Scene *scene, ViewLayer *view_layer)
 +{
 +	FileData *fd = (FileData*)(*bh);
 +	return link_named_part_ex(
- 	            mainl, fd, aet, root, idcode, name, uuid, flag, scene, view_layer, use_placeholders, force_indirect);
++	            mainl, fd, aet, root, idcode, name, uuid, flag, scene, view_layer);
  }
  
  static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
diff --cc source/blender/editors/space_file/space_file.c
index 7cfe3837471,3f26604c23a..b978b1285c6
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@@ -48,8 -45,11 +48,9 @@@
  #include "BKE_screen.h"
  #include "BKE_global.h"
  
 -#include "RNA_access.h"
 -
  #include "WM_api.h"
  #include "WM_types.h"
+ #include "WM_message.h"
  
  #include "ED_space_api.h"
  #include "ED_screen.h"
diff --cc source/blender/windowmanager/intern/wm_files_link.c
index e42299e3003,cd6a38cb9a8..19f86e0d225
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@@ -233,90 -213,8 +233,90 @@@ static WMLinkAppendDataItem *wm_link_ap
  	return item;
  }
  
 +static int path_to_idcode(const char *path)
 +{
 +	const int filetype = ED_path_extension_type(path);
 +	switch (filetype) {
 +		case FILE_TYPE_IMAGE:
 +		case FILE_TYPE_MOVIE:
 +			return ID_IM;
 +		case FILE_TYPE_FTFONT:
 +			return ID_VF;
 +		case FILE_TYPE_SOUND:
 +			return ID_SO;
 +		case FILE_TYPE_PYSCRIPT:
 +		case FILE_TYPE_TEXT:
 +			return ID_TXT;
 +		default:
 +			return 0;
 +	}
 +}
 +
 +static void wm_link_virtual_lib(
-         WMLinkAppendData *lapp_data, Main *bmain, AssetEngineType *aet, const int lib_idx, const bool generate_overrides)
++        WMLinkAppendData *lapp_data, Main *bmain, AssetEngineType *aet, const int lib_idx)
 +{
++	const bool generate_overrides = (lapp_data->flag & BLO_LIBLINK_GENERATE_OVERRIDE) != 0;
 +	LinkNode *itemlink;
 +	int item_idx;
 +
 +	BLI_assert(aet);
 +
 +	/* Find or add virtual library matching current asset engine. */
 +	Library *virtlib = BKE_library_asset_virtual_ensure(bmain, aet);
 +
 +	for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) {
 +		WMLinkAppendDataItem *item = itemlink->link;
 +		ID *new_id = NULL;
 +		bool id_exists = false;
 +
 +		if (!BLI_BITMAP_TEST(item->libraries, lib_idx)) {
 +			continue;
 +		}
 +
 +		switch (item->idcode) {
 +			case ID_IM:
 +				new_id = (ID *)BKE_image_load_exists_ex(item->name, &id_exists);
 +				if (id_exists) {
 +					if (!new_id->uuid || !ASSETUUID_COMPARE(new_id->uuid, item->uuid)) {
 +						/* Fake 'same ID' (same path, but different uuid or whatever), force loading into new ID. */
 +						BLI_assert(new_id->lib != virtlib);
 +						new_id = (ID *)BKE_image_load(bmain, item->name);
 +						id_exists = false;
 +					}
 +				}
 +				break;
 +			default:
 +				break;
 +		}
 +
 +		if (new_id) {
 +			new_id->lib = virtlib;
 +			new_id->tag |= LIB_TAG_EXTERN | LIB_ASSET;
 +
 +			if (!id_exists) {
 +				new_id->uuid = MEM_mallocN(sizeof(*new_id->uuid), __func__);
 +				*new_id->uuid = *item->uuid;
 +			}
 +
 +			if (generate_overrides) {
 +				/* Create local override of virtually linked datablock, since we nearly always want to be able
 +				 * to edit pretty much everything about it. */
 +				new_id = BKE_override_static_create_from(bmain, new_id);
 +				/* TODO: will need to protect some fields on type-by-type case (path field). */
 +			}
 +
 +			/* If the link is sucessful, clear item's libs 'todo' flags.
 +			 * This avoids trying to link same item with other libraries to come. */
 +			BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries);
 +			item->new_id = new_id;
 +		}
 +	}
 +	BKE_libraries_asset_repositories_rebuild(bmain);
 +}
 +
  static void wm_link_do(
 -        WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, Scene *scene, ViewLayer *view_layer)
 +        WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, AssetEngineType *aet,
-         Scene *scene, ViewLayer *view_layer,
-         const bool use_placeholders, const bool force_indirect, const bool generate_overrides)
++        Scene *scene, ViewLayer *view_layer)
  {
  	Main *mainl;
  	BlendHandle *bh;
@@@ -332,12 -230,6 +332,12 @@@
  	for (lib_idx = 0, liblink = lapp_data->libraries.list; liblink; lib_idx++, liblink = liblink->next) {
  	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list