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
AgeCommit message (Collapse)Author
2022-02-11File headers: SPDX License migrationCampbell Barton
Use a shorter/simpler license convention, stops the header taking so much space. Follow the SPDX license specification: https://spdx.org/licenses - C/C++/objc/objc++ - Python - Shell Scripts - CMake, GNUmakefile While most of the source tree has been included - `./extern/` was left out. - `./intern/cycles` & `./intern/atomic` are also excluded because they use different header conventions. doc/license/SPDX-license-identifiers.txt has been added to list SPDX all used identifiers. See P2788 for the script that automated these edits. Reviewed By: brecht, mont29, sergey Ref D14069
2022-01-24Cleanup: spelling in commentsCampbell Barton
2021-12-21Fix T93960: Asset Catalogs I/O fails with unicode file paths on WindowsSybren A. Stüvel
On Windows, encode file paths as UTF-16 before trying to open the file for reading/writing. This introduces a new class `blender::fstream`, which wraps `std::fstream` and provides this UTF-16 encoding. This class should also be used in other areas, like the Alembic importer/exporter. Manifest Task: T93960 Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D13633
2021-12-21Assets: log message when catalog definitions cannot be loadedSybren A. Stüvel
Log a message (via `CLOG`) when asset catalog definitions cannot be loaded. Reviewed by @jacqueslucke in D13633
2021-12-07Cleanup: move public doc-strings into headers for 'blenkernel'Campbell Barton
- Added space below non doc-string comments to make it clear these aren't comments for the symbols directly below them. - Use doxy sections for some headers. - Minor improvements to doc-strings. Ref T92709
2021-11-23Merge remote-tracking branch 'origin/blender-v3.0-release'Sybren A. Stüvel
2021-11-23Asset Browser: add operator for installing asset bundlesSybren A. Stüvel
Add an operator "Copy to Asset Library" for installing asset bundles into already-existing asset libraries. The operator is shown when: - the "Current File" library is selected, - the blend file name matches `*_bundle.blend`, and - the file is not already located in an asset library. The user can select a target asset library, then gets a "Save As" dialogue box to select where in that library the file should be saved. This allows for renaming, saving in a subdirectory, etc. The Asset Catalogs from the asset bundle are merged into the target asset library. The operator will refuse to run when external files are referenced. This is not done in its poll function, as it's quite an extensive operator (it loops over all ID datablocks). Reviewed by: Severin Differential Revision: https://developer.blender.org/D13312
2021-11-01Cleanup: Remove unused headers in asset filesJulian Eisel
Also move system includes first, like we have it elsewhere in Blender.
2021-10-24Cleanup: spelling in commentsCampbell Barton
2021-10-22Asset Browser: Show "orphaned" assets in "Unassigned" catalogSybren A. Stüvel
Show assets that have an unknown catalog ID assigned in the "Unassigned" catalog. Another catalog named "Orphans" was considered as well, but that would clash with the usual handling of Blender (discarding orphan data on save) and thus that idea was discarded. Manifest Task: T91949
2021-10-22Asset Catalogs: support reloading without losing local changesSybren A. Stüvel
Keep track of unsaved asset catalog changes, in a more granular way than just one boolean per asset library. Individual catalogs can now be marked with a flag `has_unsaved_changes`. This is taken into account when reloading data from the catalog definition file (CDF): - New catalog in CDF: gets loaded - Already-known catalog in CDF: - local unsaved changes: on-disk catalog is ignored - otherwise: on-disk catalog replaces in-memory one - Already-known catalog that does not exist in CDF: - local unsaved changes: catalog is kept around - otherwise: catalog is deleted. Because this saving-is-also-loading behaviour, the "has unsaved changes" flags are all stored in the undo buffer; undoing after saving will not change the CDF, but at least it'll undo the loading from disk, and it'll re-mark any changes as "not saved". Reviewed By: Severin Differential Revision: https://developer.blender.org/D12967
2021-10-21Asset Catalogs: refresh simple name when renaming catalogSybren A. Stüvel
When renaming an asset catalog, also update its simple name. Catalogs will most likely be created from within Blender, so via the catalog tree in the asset browser. Here catalogs are always named "Catalog" until the user renames them, which was reflected in all simple names being "Catalog".
2021-10-21Asset Catalogs: treat first-loaded catalog as main catalogSybren A. Stüvel
When there are multiple catalogs with the same path (so different UUIDs all mapped to the same catalog path), treat the first-loaded one as the main catalog for that path, and the rest as aliases. This ensures that the UUID of a catalog (as chosen in the tree UI and thus interacted with by users) is stable, regardless of whether by some coincidence later another catalog with the same UUID is created.
2021-10-19Asset Browser: Improved workflow for asset catalog savingSybren A. Stüvel
No longer save asset catalogs on blendfile save. Instead: - extend the confirmation prompt for unsaved changes to show unsaved catalogs. - In the confirmation prompt, make catalog saving explicit & optional, just like we do it for external images. {F10881736} - In the Asset Browser catalog tree, show an operator icon to save the catalogs to disk. It's grayed out if there are no changes to save, or if the .blend wasn't saved yet (required to know where to save the catalog definitions to). {F10881743} Much of the work was done by @Severin and reviewed by me, then we swapped roles. Reviewed By: Severin Differential Revision: https://developer.blender.org/D12796
2021-10-14Cleanup: reserve C++ comments for disabled codeCampbell Barton
2021-10-12Address warning about breaking copy elision of temporary objectJulian Eisel
Using `std::move()` on temporary objects prevents copy elision done by compilers. Apple Clang warns about this. Generally `std::move()` should be used sparingly: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
2021-10-12Asset Catalogs: expose undo/redo operators to UISybren A. Stüvel
Ensure that catalog operations create an undo snapshot, and show undo/redo operators in the asset browser. A hidden operator `ASSET_OT_catalog_undo_push` is also added such that add-ons can also set undo snapshots if they need.
2021-10-12Cleanup: asset catalogs, rename store_undo_snapshot to undo_pushSybren A. Stüvel
Rename `bke::AssetCatalogService::store_undo_snapshot` to `undo_push`. This makes the function named the same way as the global Blender "undo push" function. No functional changes.
2021-10-12Asset Catalogs: undo stack for catalog editsSybren A. Stüvel
Add an undo stack for catalog edits. This only implements the backend, no operators or UI yet. A bunch of `this->xxx` has been replaced by `catalog_collection_->xxx`. Things are getting a bit long, and the class is turning into a god object; refactoring the class is tracked in T92114. Reviewed By: Severin Maniphest Tasks: T92047 Differential Revision: https://developer.blender.org/D12825
2021-10-12Asset Catalogs: recursive deletion of catalogs & childrenSybren A. Stüvel
Recursively delete asset catalogs with `AssetCatalogService:prune_...` functions. This deletes the catalog and all of its children. The old `delete_catalog` function has been renamed to `delete_catalog_by_id()`, and is now a lower-level function (no deletion of children, no rebuilding of the tree). The `prune_catalogs_by_path()` and `prune_catalogs_by_id()` do delete children and do rebuild the catalog tree. Manifest task: T91634
2021-10-11Cleanup: Asset Catalogs, add divider between sections in codeSybren A. Stüvel
No functional changes.
2021-10-08Cleanup: asset catalogs, move functions to their siblingsSybren A. Stüvel
Moved function definitions around so that all members of a class are next to each other. Previously some functions of one class were sitting between functions of another class. No functional changes.
2021-10-07Asset Catalogs: change rules for saving catalog definition filesSybren A. Stüvel
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.
2021-10-04Asset Browser: Support dragging assets into catalogsJulian Eisel
With this it is possible to select any number of assets in the Asset Browser and drag them into catalogs. The assets will be moved to that catalog then. However, this will only work in the "Current File" asset library, since that is the only library that allows changing assets, which is what's done here. While dragging assets over the tree row, a tooltip is shown explaining what's going to happen. In preparation to this, the new UI tree-view API was already extended with custom drop support, see 4ee2d9df428d. ---- Changes here to the `wmDrag` code were needed to support dragging multiple assets. Some of it is considered temporary because a) a proper #AssetHandle design should replace some ugly parts of this patch and b) the multi-item support in `wmDrag` isn't that great yet. The entire API will have to be written anyway (see D4071). Maniphest Tasks: T91573 Differential Revision: https://developer.blender.org/D12713 Reviewed by: Sybren Stüvel
2021-10-01Asset Catalogs: always have an Asset Catalog Tree availableSybren A. Stüvel
Always create an `AssetCatalogTree` in the `AssetCatalogService`. This ensures that newly-created catalogs are immediately visible in the UI (because they insert themselves into an already-existing tree).
2021-10-01Asset Catalogs: add catalog filter for the asset browserSybren A. Stüvel
Given an "active catalog" (i.e. the one selected in the UI), construct an `AssetCatalogFilter` instance. This filter can determine whether an asset should be shown or not. It returns `true` when The asset's catalog ID is: - the active catalog, - an alias of the active catalog (so different UUID that maps to the same path), - a sub-catalog of the active catalog. Not yet hooked up to the UI.
2021-10-01Cleanup: asset catalogs, make function constSybren A. Stüvel
Declare `AssetCatalogService::find_catalog()` as `const`, as it's not requiring modification off the service object. No functional changes.
2021-09-30Asset Catalogs: create missing parent catalogsSybren A. Stüvel
For every known catalog, ensure its parent catalog also exists. This ensures that assets can be assigned to parent catalogs, even when they didn't exist in the Catalog Definition File yet.
2021-09-30Cleanup: remove `CatalogPath` aliasSybren A. Stüvel
The `CatalogPath` name was an alias for `std::string`, so that it could be easily switched over to something else. This happened in the previous commit (switched to `AssetCatalogPath`), so the alias is no longer necessary. This commit removes the `CatalogPath` alias. No functional changes.
2021-09-30Asset Catalog: introduce `AssetCatalogPath` classSybren A. Stüvel
So far we have used `std::string` for asset catalog paths. Some operations are better described on a dedicated class for this, though. This commits switches catalog paths from using `std::string` to a dedicated `blender::bke::AssetCatalogPath` class. The `using CatalogPath = AssetCatalogPath` alias is still there, and will be removed in a following cleanup commit. New `AssetCatalogPath` code reviewed by @severin in D12710.
2021-09-29Support loading catalogs in the Current File asset libraryJulian Eisel
When the Asset Browser shows the "Current File" asset library, now it also attempts to load an asset catalog definition file from location of the current .blend file. This happens as follows: * First, see if the file is inside of an asset library that is "mounted" in the Preferences. Load the catalogs from there if so. * Otherwise, if the file is saved, load the catalogs from the directory the file is saved in. * If the file is not saved, no catalogs will be loaded. Unit tests are being worked on in D12689. Creating catalogs from the "Current File" asset library still doesn't work, as the asset catalog service doesn't construct an in-memory catalog definition file in that case yet. Differential Revision: https://developer.blender.org/D12675
2021-09-28Cleanup: asset catalog, remove obsolete TODOSybren A. Stüvel
No functional changes.
2021-09-28Cleanup: asset catalogs, move file header definition to constantSybren A. Stüvel
Define the standard catalog definition file header in a constant, separating it from the function that writes the entire file. No functional changes.
2021-09-28Cleanup: asset catalog service, remove obsolete `write_to_disk` functionSybren A. Stüvel
Remove `AssetCatalogService::write_to_disk()` function. It has been superseded by `write_to_disk_on_blendfile_save()`; the handful of test functions that called the old function have been adjusted to use the new one. No functional changes to Blender itself.
2021-09-28Asset Catalog Service: add function to change catalog pathSybren A. Stüvel
Add `AssetCatalogService::update_catalog_path()` to change the catalog path of the given catalog, and also change the path of all the catalogs contained within the given catalog. Rebuilds the tree structure for the UI, but does not save the new catalog definitions to disk. No user-facing changes, just backend preparation for UI work.
2021-09-27Cleanup: Asset catalogs, fix clang-tidy warningSybren A. Stüvel
Change `auto &catalog` to `const auto &catalog`. No functional changes.
2021-09-27Asset Catalogs: write catalogs to disk when saving the blend fileSybren A. Stüvel
The Asset Catalog Definition File is now saved whenever the blend file is saved. The location of the CDF depends on where the blend file is saved, and whether previously a CDF was already loaded, according to the following rules. The first matching rule wins: 1. Already loaded a CDF from disk? -> Always write to that file. 2. The directory containing the blend file has a `blender_assets.cats.txt` file? -> Merge with & write to that file. 3. The directory containing the blend file is part of an asset library, as per the user's preferences? -> Merge with & write to `${ASSET_LIBRARY_ROOT}/blender_assets.cats.txt` 4. Create a new file `blender_assets.cats.txt` next to the blend file.
2021-09-27Assets: Additions/fixes to the catalog system in preparation for the UIJulian Eisel
* Fixes missing update of the catalog tree when adding catalogs. * Adds iterators for the catalogs, needed for UI code. * Store catalog ID in the catalog tree items, needed for UI code. * Other smaller API additions for the UI. * Improve comments and smaller cleanups. New functions are covered with unit tests. Differential Revision: https://developer.blender.org/D12618 Reviewed by: Sybren Stüvel
2021-09-24Asset Catalogs: write catalogs sorted by path & UUIDSybren A. Stüvel
When writing asset catalog definition files, order the catalogs by (path, UUID). This ensures that every write produces the same file, playing nice with versioning / synchronisation systems.
2021-09-23Cleanup: asset catalogs, correct assertion messageSybren A. Stüvel
There is no such thing as a "relative path" when it comes to asset catalog paths (they're always absolute). No functional changes.
2021-09-23Asset Catalogs: explicit version number in catalog definition filesSybren A. Stüvel
Declare the current format used for asset catalog definition files as version 1, and write that to the files. Files without that version number will be rejected. This makes it much easier to move to different versions later, with the opportunity to do versioning on file load. The version is not associated with any version of Blender, but a separate integer that's simply incremented when a non-backward-compatible change happens.
2021-09-23Assets: add Asset Catalog systemSybren A. Stüvel
Catalogs work like directories on disk (without hard-/symlinks), in that an asset is only contained in one catalog. See T90066 for design considerations. #### Known Limitations Only a single catalog definition file (CDF), is supported, at `${ASSET_LIBRARY_ROOT}/blender_assets.cats.txt`. In the future this is to be expanded to support arbitrary CDFs (like one per blend file, one per subdirectory, etc.). The current implementation is based on the asset browser, which in practice means that the asset browser owns the `AssetCatalogService` instance for the selected asset library. In the future these instances will be accessible via a less UI-bound asset system. The UI is still very rudimentary, only showing the catalog ID for the currently selected asset. Most notably, the loaded catalogs are not shown yet. The UI is being implemented and will be merged soon. #### Catalog Identifiers Catalogs are internally identified by UUID. In older designs this was a human-readable name, which has the problem that it has to be kept in sync with its semantics (so when renaming a catalog from X to Y, the UUID can be kept the same). Since UUIDs don't communicate any human-readable information, the mapping from catalog UUID to its path (stored in the Catalog Definition File, CDF) is critical for understanding which asset is stored in which human-readable catalog. To make this less critical, and to allow manual data reconstruction after a CDF is lost/corrupted, each catalog also has a "simple name" that's stored along with the UUID. This is also stored on each asset, next to the catalog UUID. #### Writing to Disk Before saving asset catalogs to disk, the to-be-overwritten file gets inspected. Any new catalogs that are found thre are loaded to memory before writing the catalogs back to disk: - Changed catalog path: in-memory data wins - Catalogs deleted on disk: they are recreated based on in-memory data - Catalogs deleted in memory: deleted on disk as well - New catalogs on disk: are loaded and thus survive the overwriting #### Tree Design This implements the initial tree structure to load catalogs into. See T90608, and the basic design in T90066. Reviewed By: Severin Maniphest Tasks: T91552 Differential Revision: https://developer.blender.org/D12589
2021-08-02Revert "Asset Catalogs: loading a catalog definition file"Sybren A. Stüvel
This reverts commit 1f0d6f763573b22772dcdb61320a12e1c11949e0 and the cleanup 06cb48e1b284e6438ce14f1ea543143fcc74ca59. Committed too early on Monday morning, still has issues that should be resolved first.
2021-08-02Asset Catalogs: loading a catalog definition fileSybren A. Stüvel
Initial, limited implementation of loading a single asset catalog definition file. These files are structured as follows: CATALOG_ID virtual/path/of/catalog SUBCATALOG_ID virtual/path/of/catalog/child SOMETHING_ELSE some/unrelated/hierarchy These virtual paths will be used to show the catalog in a tree structure; the tree structure itself is not part of this commit. Each asset will have one catalog ID that determines where in that tree the asset shows up. Currently only a single catalog definition file can be read; merging data from multiple such files, and writing them out again after changes are made, is for future commits. This commit only contains the code to load a single file, and unittests to check that this actually works. No UI, no user-facing functionality yet.