No user visible changes expected. For brush assets, we need a way to store a reference to a brush in .blend files, so that the last active brush can be restored from the file. See #101908. It seems like a generally useful thing to have. Adds a new DNA struct to store a "weak" asset reference, that is, a reference that can break under a number of circumstances, but should work reliably enough under normal usage. There's no way to reliably reference an asset currently, so this works on a "best effort" basis. It can break when assets are moved inside the asset library, asset libraries are unregistered from the Preferences, or a file is opened on a different machine with different Preferences, for example. It can also break currently if an asset library is renamed. It contains: - Information to identify the asset library the asset can be found in. - A relative "identifier" (currently a relative path) for the asset within the asset library. There's further code to resolve a weak reference to file paths and Blender library paths. Part of #101908. Co-authored-by: Bastien Montagne <bastien@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/105603
41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup asset_system
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct AssetMetaData;
|
|
struct AssetWeakReference;
|
|
|
|
/** C handle for #asset_system::AssetRepresentation. */
|
|
typedef struct AssetRepresentation AssetRepresentation;
|
|
|
|
const char *AS_asset_representation_name_get(const AssetRepresentation *asset)
|
|
ATTR_WARN_UNUSED_RESULT;
|
|
AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset)
|
|
ATTR_WARN_UNUSED_RESULT;
|
|
struct ID *AS_asset_representation_local_id_get(const AssetRepresentation *asset)
|
|
ATTR_WARN_UNUSED_RESULT;
|
|
bool AS_asset_representation_is_local_id(const AssetRepresentation *asset) ATTR_WARN_UNUSED_RESULT;
|
|
bool AS_asset_representation_is_never_link(const AssetRepresentation *asset)
|
|
ATTR_WARN_UNUSED_RESULT;
|
|
|
|
/**
|
|
* C version of #AssetRepresentation::make_weak_reference. Returned pointer needs freeing with
|
|
* #MEM_delete() or #BKE_asset_weak_reference_free().
|
|
*/
|
|
AssetWeakReference *AS_asset_representation_weak_reference_create(const AssetRepresentation *asset)
|
|
ATTR_WARN_UNUSED_RESULT;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|