[Bf-blender-cvs] [74aeb8e] asset-engine: Merge branch 'asset-experiments' into asset-engine
Bastien Montagne
noreply at git.blender.org
Thu May 28 14:46:25 CEST 2015
Commit: 74aeb8ef116f21e3f6560f1447585896542ee429
Author: Bastien Montagne
Date: Thu May 28 14:46:10 2015 +0200
Branches: asset-engine
https://developer.blender.org/rB74aeb8ef116f21e3f6560f1447585896542ee429
Merge branch 'asset-experiments' into asset-engine
Conflicts:
source/blender/windowmanager/intern/wm_operators.c
===================================================================
===================================================================
diff --cc source/blender/windowmanager/intern/wm_operators.c
index 4d545a3,a37ea98..1603f80
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@@ -2727,11 -2645,8 +2667,11 @@@ static void wm_link_append_do_libgroup
int curr_idcode;
RNA_string_get(&itemptr, "name", relname);
+ RNA_int_get_array(&itemptr, "asset_uuid", asset_uuid);
+
+ printf("asset uuid %s: %d, %d, %d, %d\n", relname, asset_uuid[0], asset_uuid[1], asset_uuid[2], asset_uuid[3]);
- BLI_join_dirfile(path, sizeof(path), dir, relname);
+ BLI_join_dirfile(path, sizeof(path), root, relname);
if (BLO_library_path_explode(path, curr_libname, &group, &name)) {
if (!group || !name) {
@@@ -2764,68 -2681,90 +2706,98 @@@
BLI_assert(BLI_findindex(&bmain->library, lib) != -1);
BKE_library_make_local(bmain, lib, true);
}
+ }
- BLO_blendhandle_close(bh);
+ static int wm_link_append_exec(bContext *C, wmOperator *op)
+ {
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ PropertyRNA *prop;
+ char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX], *group, *name;
+ int totfiles = 0;
+ short flag;
- if (todo_libraries) {
- GSetIterator libs_it;
++ char asset_engine[BKE_ST_MAXNAME];
++ AssetEngineType *aet = NULL;
+
- GSET_ITER(libs_it, todo_libraries) {
- char *libpath = (char *)BLI_gsetIterator_getKey(&libs_it);
+ GSet *todo_libraries = NULL;
- BLO_library_path_explode(libpath, libname, &group, NULL);
- BLI_assert(group);
- idcode = BKE_idcode_from_name(group);
+ RNA_string_get(op->ptr, "filename", relname);
+ RNA_string_get(op->ptr, "directory", root);
- bh = BLO_blendhandle_from_file(libname, op->reports);
+ BLI_join_dirfile(path, sizeof(path), root, relname);
- if (bh == NULL) {
- /* unlikely since we just browsed it, but possible
- * error reports will have been made by BLO_blendhandle_from_file() */
- continue;
- }
++ RNA_string_get(op->ptr, "asset_engine", asset_engine);
++ if (asset_engine[0] != '\0') {
++ aet = BKE_asset_engines_find(asset_engine);
++ }
+
- /* here appending/linking starts */
- mainl = BLO_library_append_begin(bmain, &bh, libname);
- lib = mainl->curlib;
- BLI_assert(lib);
+ /* test if we have a valid data */
+ if (!BLO_library_path_explode(path, libname, &group, &name)) {
+ BKE_report(op->reports, RPT_ERROR, "Not a library");
+ return OPERATOR_CANCELLED;
+ }
+ else if (!group) {
+ BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
+ return OPERATOR_CANCELLED;
+ }
+ else if (BLI_path_cmp(bmain->name, libname) == 0) {
+ BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library");
+ return OPERATOR_CANCELLED;
+ }
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- char curr_libname[FILE_MAX];
- int curr_idcode;
+ /* check if something is indicated for append/link */
+ prop = RNA_struct_find_property(op->ptr, "files");
+ if (prop) {
+ totfiles = RNA_property_collection_length(op->ptr, prop);
+ if (totfiles == 0) {
+ if (!name) {
+ BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
+ else if (!name) {
+ BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
+ return OPERATOR_CANCELLED;
+ }
- RNA_string_get(&itemptr, "name", relname);
+ flag = wm_link_append_flag(op);
- BLI_join_dirfile(path, sizeof(path), dir, relname);
+ /* sanity checks for flag */
+ if (scene->id.lib && (flag & FILE_GROUP_INSTANCE)) {
+ /* TODO, user never gets this message */
+ BKE_reportf(op->reports, RPT_WARNING, "Scene '%s' is linked, group instance disabled", scene->id.name + 2);
+ flag &= ~FILE_GROUP_INSTANCE;
+ }
- if (BLO_library_path_explode(path, curr_libname, &group, &name)) {
- if (!group || !name) {
- continue;
- }
+ /* from here down, no error returns */
- curr_idcode = BKE_idcode_from_name(group);
+ /* now we have or selected, or an indicated file */
+ if (RNA_boolean_get(op->ptr, "autoselect"))
+ BKE_scene_base_deselect_all(scene);
+
+ /* tag everything, all untagged data can be made local
+ * its also generally useful to know what is new
+ *
+ * take extra care BKE_main_id_flag_all(LIB_LINK_TAG, false) is called after! */
+ BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, 1);
- if ((idcode == curr_idcode) && (BLI_path_cmp(curr_libname, libname) == 0)) {
- BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
- }
- }
- }
- RNA_END;
+ if (totfiles != 0) {
+ name = NULL;
+ }
- BLO_library_append_end(C, mainl, &bh, idcode, flag);
+ wm_link_append_do_libgroup(C, op, root, libname, group, name, flag, &todo_libraries);
- /* mark all library linked objects to be updated */
- BKE_main_lib_objects_recalc_all(bmain);
- IMB_colormanagement_check_file_config(bmain);
+ if (todo_libraries) {
+ GSetIterator libs_it;
- /* append, rather than linking */
- if ((flag & FILE_LINK) == 0) {
- BLI_assert(BLI_findindex(&bmain->library, lib) != -1);
- BKE_library_make_local(bmain, lib, true);
- }
+ GSET_ITER(libs_it, todo_libraries) {
+ char *libpath = (char *)BLI_gsetIterator_getKey(&libs_it);
+
+ BLO_library_path_explode(libpath, libname, &group, NULL);
- BLO_blendhandle_close(bh);
+ wm_link_append_do_libgroup(C, op, root, libname, group, NULL, flag, &todo_libraries);
}
BLI_gset_free(todo_libraries, MEM_freeN);
More information about the Bf-blender-cvs
mailing list