This adds support for packed linked data. This is a key part of an improved asset workflow in Blender. Packed IDs remain considered as linked data (i.e. they cannot be edited), but they are stored in the current blendfile. This means that they: * Are not lost in case the library data becomes unavailable. * Are not changed in case the library data is updated. These packed IDs are de-duplicated across blend-files, so e.g. if a shot file and several of its dependencies all use the same util geometry node, there will be a single copy of that geometry node in the shot file. In case there are several versions of a same ID (e.g. linked at different moments from a same library, which has been modified in-between), there will be several packed IDs. Name collisions are averted by storing these packed IDs into a new type of 'archive' libraries (and their namespaces). These libraries: * Only contain packed IDs. * Are owned and managed by their 'real' library data-block, called an 'archive parent'. For more in-depth, technical design: #132167 UI/UX design: #140870 Co-authored-by: Bastien Montagne <bastien@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/133801
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
#include "BKE_main.hh"
|
|
|
|
#include "BLI_map.hh"
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "DNA_ID.h"
|
|
|
|
namespace blender::bke::id_hash {
|
|
|
|
/**
|
|
* The hash of all the root IDs and their dependencies.
|
|
*/
|
|
struct ValidDeepHashes {
|
|
Map<const ID *, IDHash> hashes;
|
|
};
|
|
|
|
struct DeepHashErrors {
|
|
/**
|
|
* A list of missing files paths in the case that the deep hashes could not be computed.
|
|
*/
|
|
VectorSet<std::string> missing_files;
|
|
|
|
/**
|
|
* Files that were modified since the linked ID was loaded. So the currently linked ID would not
|
|
* be matching the deep hash computed based on the source file.
|
|
*/
|
|
VectorSet<std::string> updated_files;
|
|
};
|
|
|
|
using IDHashResult = std::variant<ValidDeepHashes, DeepHashErrors>;
|
|
|
|
/**
|
|
* Compute a hash of the given IDs, including all their dependencies.
|
|
* This needs access to the original .blend files that the linked data-blocks come from to be able
|
|
* to compute their hash.
|
|
*/
|
|
IDHashResult compute_linked_id_deep_hashes(const Main &bmain, Span<const ID *> root_ids);
|
|
|
|
/** Utility to convert the hash into a readable string. */
|
|
std::string id_hash_to_hex(const IDHash &hash);
|
|
|
|
} // namespace blender::bke::id_hash
|