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:
authorSybren A. Stüvel <sybren@blender.org>2021-10-07 17:44:29 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-07 18:04:47 +0300
commitcc6a3509a05b227f554fdb9a3cfef90a1de273b4 (patch)
tree162a6825584e9539b07cddeb335e46461a64b902 /source/blender/blenkernel/intern/asset_catalog.cc
parent1de922f88c91402b3f8083431e11401892485b4d (diff)
Asset Catalogs: change rules for saving catalog definition files
Change the rules for determining where to save a new catalog definition file (CDF). Old situation (T91681): if a `blender_assets.cats.txt` file already exists in the same directory as the blend file, write to that. If not, see if the blend file is contained in an asset library, and write to its top-level CDF. The new situation swaps the rules: first see if the blend file is contained in an asset library, and if so write to its top-level CDF. If not, write a CDF next to the blend file. As before, any pre-existing CDF is not just bluntly overwritten, but merged with the in-memory catalogs.
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_catalog.cc34
1 files changed, 15 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc b/source/blender/blenkernel/intern/asset_catalog.cc
index 577d916288a..d50942bd9fa 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -327,30 +327,26 @@ CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing(
"A non-empty .blend file path is required to be able to determine where the "
"catalog definition file should be put");
+ /* Ask the asset library API for an appropriate location. */
+ char suitable_root_path[PATH_MAX];
+ const bool asset_lib_root_found = BKE_asset_library_find_suitable_root_path_from_path(
+ blend_file_path.c_str(), suitable_root_path);
+ if (asset_lib_root_found) {
+ char asset_lib_cdf_path[PATH_MAX];
+ BLI_path_join(asset_lib_cdf_path,
+ sizeof(asset_lib_cdf_path),
+ suitable_root_path,
+ DEFAULT_CATALOG_FILENAME.c_str(),
+ NULL);
+ return asset_lib_cdf_path;
+ }
+
/* Determine the default CDF path in the same directory of the blend file. */
char blend_dir_path[PATH_MAX];
BLI_split_dir_part(blend_file_path.c_str(), blend_dir_path, sizeof(blend_dir_path));
const CatalogFilePath cdf_path_next_to_blend = asset_definition_default_file_path_from_dir(
blend_dir_path);
-
- if (BLI_exists(cdf_path_next_to_blend.c_str())) {
- /* - The directory containing the blend file has a blender_assets.cats.txt file?
- * -> Merge with & write to that file. */
- return cdf_path_next_to_blend;
- }
-
- /* - There's no definition file next to the .blend file.
- * -> Ask the asset library API for an appropriate location. */
- char suitable_root_path[PATH_MAX];
- BKE_asset_library_find_suitable_root_path_from_path(blend_file_path.c_str(), suitable_root_path);
- char asset_lib_cdf_path[PATH_MAX];
- BLI_path_join(asset_lib_cdf_path,
- sizeof(asset_lib_cdf_path),
- suitable_root_path,
- DEFAULT_CATALOG_FILENAME.c_str(),
- NULL);
-
- return asset_lib_cdf_path;
+ return cdf_path_next_to_blend;
}
std::unique_ptr<AssetCatalogDefinitionFile> AssetCatalogService::construct_cdf_in_memory(