[Bf-blender-cvs] [6bae015] asset-engine: Merge branch 'master' into asset-engine

Bastien Montagne noreply at git.blender.org
Tue May 24 15:24:33 CEST 2016


Commit: 6bae0159856a0a4e6c41f7ff0a292e113e0e5a92
Author: Bastien Montagne
Date:   Tue May 24 14:44:13 2016 +0200
Branches: asset-engine
https://developer.blender.org/rB6bae0159856a0a4e6c41f7ff0a292e113e0e5a92

Merge branch 'master' into asset-engine

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



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

diff --cc source/blender/blenkernel/BKE_library.h
index 405728f,2215fbf..c604c2b
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@@ -121,22 -119,9 +121,23 @@@ void BKE_main_lib_objects_recalc_all(st
  /* (MAX_ID_NAME - 2) + 3 */
  void BKE_id_ui_prefix(char name[66 + 1], const struct ID *id);
  
- void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only, bool set_fake);
+ void BKE_library_make_local(
+         struct Main *bmain, const struct Library *lib, const bool untagged_only, const bool set_fake);
  
 +void BKE_library_asset_repository_init(struct Library *lib, const struct AssetEngineType *aet, const char *repo_root);
 +void BKE_library_asset_repository_clear(struct Library *lib);
 +void BKE_library_asset_repository_free(struct Library *lib);
 +struct AssetRef *BKE_library_asset_repository_asset_add(struct Library *lib, const void *idv);
 +void BKE_library_asset_repository_asset_remove(struct Library *lib, const void *idv);
 +struct AssetRef *BKE_library_asset_repository_asset_find(struct Library *lib, const void *idv);
 +void BKE_library_asset_repository_subdata_add(struct AssetRef *aref, const void *idv);
 +void BKE_library_asset_repository_subdata_remove(struct AssetRef *aref, const void *idv);
 +
 +void BKE_libraries_asset_subdata_remove(struct Main *bmain, const void *idv);
 +void BKE_libraries_asset_repositories_clear(struct Main *bmain);
 +void BKE_libraries_asset_repositories_rebuild(struct Main *bmain);
 +struct AssetRef *BKE_libraries_asset_repository_uuid_find(struct Main *bmain, const struct AssetUUID *uuid);
 +
  typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
  typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
  typedef void (*BKE_library_free_editor_id_reference_cb)(const struct ID *);
diff --cc source/blender/editors/space_file/filelist.c
index 26762cd,8e1f781..3d0270e
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@@ -1513,50 -1419,39 +1513,50 @@@ bool filelist_pending(struct FileList *
   * Limited version of full update done by space_file's file_refresh(), to be used by operators and such.
   * Ensures given filelist is ready to be used (i.e. it is filtered and sorted), unless it is tagged for a full refresh.
   */
 -int filelist_files_ensure(FileList *filelist)
 +int filelist_files_ensure(FileList *filelist, FileSelectParams *params)
  {
  	if (!filelist_force_reset(filelist) || !filelist_empty(filelist)) {
 -		filelist_sort(filelist);
 -		filelist_filter(filelist);
 +		filelist_sort_filter(filelist, params);
  	}
  
- 	return filelist->filelist.nbr_entries_filtered;;
+ 	return filelist->filelist.nbr_entries_filtered;
  }
  
 +
 +static FileDirEntry *filelist_file_create_entries_block(FileList *filelist, const int index, const int size);
 +
  static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int index)
  {
 -	FileListInternEntry *entry = filelist->filelist_intern.filtered[index];
  	FileListEntryCache *cache = &filelist->filelist_cache;
  	FileDirEntry *ret;
 -	FileDirEntryRevision *rev;
  
 -	ret = MEM_callocN(sizeof(*ret), __func__);
 -	rev = MEM_callocN(sizeof(*rev), __func__);
 +	if (filelist->ae) {
 +		ret = filelist_file_create_entries_block(filelist, index, 1);
  
 -	rev->size = (uint64_t)entry->st.st_size;
 +		BLI_assert(!ret || !ret->next);
 +	}
 +	else {
 +		FileListInternEntry *entry = filelist->filelist_intern.filtered[index];
 +		FileDirEntryRevision *rev;
 +
 +		ret = MEM_callocN(sizeof(*ret), __func__);
 +		rev = MEM_callocN(sizeof(*rev), __func__);
  
 -	rev->time = (int64_t)entry->st.st_mtime;
 +		rev->size = (uint64_t)entry->st.st_size;
  
 -	ret->entry = rev;
 -	ret->relpath = BLI_strdup(entry->relpath);
 -	ret->name = BLI_strdup(entry->name);
 -	ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
 -	memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
 -	ret->blentype = entry->blentype;
 -	ret->typeflag = entry->typeflag;
 +		rev->time = (int64_t)entry->st.st_mtime;
 +
 +		ret->entry = rev;
 +		ret->relpath = BLI_strdup(entry->relpath);
 +		ret->name = BLI_strdup(entry->name);
 +		ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
 +		memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
 +		ret->blentype = entry->blentype;
 +		ret->typeflag = entry->typeflag;
 +
 +		BLI_addtail(&cache->cached_entries, ret);
 +	}
  
 -	BLI_addtail(&cache->cached_entries, ret);
  	return ret;
  }
  
diff --cc source/blender/windowmanager/intern/wm_files_link.c
index 5e97a63,2e4a4b6..1dbd230
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@@ -525,325 -513,8 +545,328 @@@ void WM_OT_append(wmOperatorType *ot
  	        FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
  
  	wm_link_append_properties_common(ot, false);
- 	RNA_def_boolean(ot->srna, "set_fake", false, "Fake User", "Set Fake User for appended items (except Objects and Groups)");
+ 	RNA_def_boolean(ot->srna, "set_fake", false, "Fake User",
+ 	                "Set Fake User for appended items (except Objects and Groups)");
+ 	RNA_def_boolean(ot->srna, "use_recursive", true, "Localize All",
+ 	                "Localize all appended data, including those indirectly linked from other libraries");
  }
 +
 +
 +/** \name Asset-related operators.
 + *
 + * \{ */
 +
 +typedef struct AssetUpdateCheckEngine {
 +	struct AssetUpdateCheckEngine *next, *prev;
 +	AssetEngine *ae;
 +
 +	/* Note: We cannot store IDs themselves in non-locking async task... so we'll have to check again for
 +	 *       UUID/IDs mapping on each update call... Not ideal, but don't think it will be that big of an override
 +	 *       in practice. */
 +	AssetUUIDList uuids;
 +	int ae_job_id;
 +	short status;
 +} AssetUpdateCheckEngine;
 +
 +typedef struct AssetUpdateCheckJob {
 +	ListBase engines;
 +	short flag;
 +
 +	float *progress;
 +	short *stop;
 +} AssetUpdateCheckJob;
 +
 +/* AssetUpdateCheckEngine.status */
 +enum {
 +	AUCE_UPDATE_CHECK_DONE  = 1 << 0,  /* Update check is finished for this engine. */
 +	AUCE_ENSURE_ASSETS_DONE = 1 << 1,  /* Asset ensure is finished for this engine (if applicable). */
 +};
 +
 +/* AssetUpdateCheckJob.flag */
 +enum {
 +	AUCJ_ENSURE_ASSETS = 1 << 0,  /* Try to perform the 'ensure' task too. */
 +};
 +
 +/* Helper to fetch a set of assets to handle, regrouped by asset engine. */
 +static void asset_update_engines_uuids_fetch(
 +        ListBase *engines,
 +        Main *bmain, AssetUUIDList *uuids, const short uuid_tags,
 +        const bool do_reset_tags)
 +{
 +	for (Library *lib = bmain->library.first; lib; lib = lib->id.next) {
 +		if (lib->asset_repository) {
 +			printf("Checking lib file %s (engine %s, ver. %d)\n", lib->filepath,
 +			       lib->asset_repository->asset_engine, lib->asset_repository->asset_engine_version);
 +
 +			AssetUpdateCheckEngine *auce = NULL;
 +			AssetEngineType *ae_type = BKE_asset_engines_find(lib->asset_repository->asset_engine);
 +			bool copy_engine = false;
 +
 +			if (ae_type == NULL) {
 +				printf("ERROR! Unknown asset engine!\n");
 +			}
 +
 +			for (AssetRef *aref = lib->asset_repository->assets.first; aref; aref = aref->next) {
 +				ID *id = ((LinkData *)aref->id_list.first)->data;
 +				BLI_assert(id->uuid);
 +
 +				if (uuid_tags && !(id->uuid->tag & uuid_tags)) {
 +					continue;
 +				}
 +
 +				if (uuids) {
 +					int i = uuids->nbr_uuids;
 +					bool skip = true;
 +					for (AssetUUID *uuid = uuids->uuids; i--; uuid++) {
 +						if (ASSETUUID_COMPARE(id->uuid, uuid)) {
 +							skip = false;
 +							break;
 +						}
 +					}
 +					if (skip) {
 +						continue;
 +					}
 +				}
 +
 +				if (ae_type == NULL) {
 +					if (do_reset_tags) {
 +						id->uuid->tag = UUID_TAG_ENGINE_MISSING;
 +					}
 +					else {
 +						id->uuid->tag |= UUID_TAG_ENGINE_MISSING;
 +					}
 +					G.f |= G_ASSETS_FAIL;
 +					continue;
 +				}
 +
 +				if (auce == NULL) {
 +					for (auce = engines->first; auce; auce = auce->next) {
 +						if (auce->ae->type == ae_type) {
 +							/* In case we have several engine versions for the same engine, we create several
 +							 * AssetUpdateCheckEngine structs (since an uuid list can only handle one ae version), using
 +							 * the same (shallow) copy of the actual asset engine. */
 +							copy_engine = (auce->uuids.asset_engine_version != lib->asset_repository->asset_engine_version);
 +							break;
 +						}
 +					}
 +					if (copy_engine || auce == NULL) {
 +						AssetUpdateCheckEngine *auce_prev = auce;
 +						auce = MEM_callocN(sizeof(*auce), __func__);
 +						auce->ae = copy_engine ? BKE_asset_engine_copy(auce_prev->ae) :
 +						                         BKE_asset_engine_create(ae_type, NULL);
 +						auce->ae_job_id = AE_JOB_ID_UNSET;
 +						auce->uuids.asset_engine_version = lib->asset_repository->asset_engine_version;
 +						BLI_addtail(engines, auce);
 +					}
 +				}
 +
 +				printf("\tWe need to check for updated asset %s...\n", id->name);
 +				if (do_reset_tags) {
 +					id->uuid->tag = (id->tag & LIB_TAG_MISSING) ? UUID_TAG_ASSET_MISSING : 0;
 +				}
 +
 +				/* XXX horrible, need to use some mempool, stack or something :) */
 +				auce->uuids.nbr_uuids++;
 +				if (auce->uuids.uuids) {
 +					auce->uuids.uuids = MEM_reallocN_id(auce->uuids.uuids, sizeof(*auce->uuids.uuids) * (size_t)auce->uuids.nbr_uuids, __func__);
 +				}
 +				else {
 +					auce->uuids.uuids = MEM_mallocN(sizeof(*auce->uuids.uuids) * (size_t)auce->uuids.nbr_uuids, __func__);
 +				}
 +				auce->uuids.uuids[auce->uuids.nbr_uuids - 1] = *id->uuid;
 +			}
 +		}
 +	}
 +}
 +
 +static void asset_updatecheck_startjob(void *aucjv, short *stop, short *do_update, float *progress)
 +{
 +	AssetUpdateCheckJob *aucj = aucjv;
 +
 +	aucj->progress = progress;
 +	aucj->stop = stop;
 +	/* Using AE engine, worker thread here is just sleeping! */
 +	while (!*stop) {
 +		*do_update = true;
 +		PIL_sleep_ms(100);
 +	}
 +}
 +
 +static void asset_updatecheck_update(void *aucjv)
 +{
 +	AssetUpdateCheckJob *aucj = aucjv;
 +	Main *bmain = G.main;
 +
 +	const bool do_ensure = ((aucj->flag & AUCJ_ENSURE_AS

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list