2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2016 Blender Foundation. All rights reserved. */
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2020-02-10 16:54:24 +01:00
|
|
|
#pragma once
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2020-02-10 15:05:54 +01:00
|
|
|
*
|
2020-02-15 05:58:06 +01:00
|
|
|
* API to manage data-blocks inside of Blender's Main data-base, or as independent runtime-only
|
2020-02-10 15:05:54 +01:00
|
|
|
* data.
|
|
|
|
*
|
|
|
|
* \note `BKE_lib_` files are for operations over data-blocks themselves, although they might
|
|
|
|
* alter Main as well (when creating/renaming/deleting an ID e.g.).
|
|
|
|
*
|
|
|
|
* \section Function Names
|
|
|
|
*
|
|
|
|
* \warning Descriptions below is ideal goal, current status of naming does not yet fully follow it
|
|
|
|
* (this is WIP).
|
|
|
|
*
|
|
|
|
* - `BKE_lib_override_library_` should be used for function affecting a single ID.
|
|
|
|
* - `BKE_lib_override_library_main_` should be used for function affecting the whole collection
|
|
|
|
* of IDs in a given Main data-base.
|
2017-11-29 15:05:03 +01:00
|
|
|
*/
|
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-06-23 09:51:11 +02:00
|
|
|
struct BlendFileReadReport;
|
2021-07-16 03:48:54 +02:00
|
|
|
struct Collection;
|
2017-11-29 15:05:03 +01:00
|
|
|
struct ID;
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibrary;
|
|
|
|
struct IDOverrideLibraryProperty;
|
|
|
|
struct IDOverrideLibraryPropertyOperation;
|
LibOverride: add recursive resync.
Recursive resync means also resyncing overrides that are linked from
other library files into current working file.
Note that this allows to get 'working' files even when their
dependencies are out of sync. However, since linked data is never
written/saved, this has to be re-done every time the working file is
loaded, until said dependencies are updated properly.
NOTE: This is still missing the 'report' side of things, which is part
of a larger task to enhance reports regarding both linking, and
liboverrides (see T88393).
----------
Technical notes:
Implementing this proved to be slightly more challenging than expected,
mainly because one of the key aspects of the feature was never done in
Blender before: manipulating, re-creating linked data.
This ended up moving the whole resync code to use temp IDs out of bmain,
which is better in the long run anyway (and more aligned with what we
generally want to do when manipulating temp ID data). It should also
give a marginal improvement in performances for regular resync.
This commit also had to carefully 'sort' libraries by level of indirect
usage, as we want to resync first the libraries that are the least directly
used, i.e. libraries that are most used by other libraries.
2021-05-26 16:53:59 +02:00
|
|
|
struct Library;
|
2017-11-29 15:05:03 +01:00
|
|
|
struct Main;
|
2020-09-30 03:51:13 +02:00
|
|
|
struct Object;
|
2020-04-15 17:26:34 +02:00
|
|
|
struct PointerRNA;
|
|
|
|
struct PropertyRNA;
|
2021-03-15 15:19:22 +01:00
|
|
|
struct ReportList;
|
2020-07-15 18:09:30 +02:00
|
|
|
struct Scene;
|
|
|
|
struct ViewLayer;
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Initialize empty overriding of \a reference_id by \a local_id.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibrary *BKE_lib_override_library_init(struct ID *local_id,
|
|
|
|
struct ID *reference_id);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Shallow or deep copy of a whole override from \a src_id to \a dst_id.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_lib_override_library_copy(struct ID *dst_id, const struct ID *src_id, bool do_full_copy);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Clear any overriding data from given \a override.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_lib_override_library_clear(struct IDOverrideLibrary *override, bool do_id_user);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Free given \a override.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_lib_override_library_free(struct IDOverrideLibrary **override, bool do_id_user);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2022-08-02 15:03:11 +02:00
|
|
|
/**
|
2022-08-12 12:42:03 +02:00
|
|
|
* Return the actual #IDOverrideLibrary data 'controlling' the given `id`, and the actual ID owning
|
2022-08-02 15:03:11 +02:00
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* \note This is especially useful when `id` is a non-real override (e.g. embedded ID like a master
|
|
|
|
* collection or root node tree, or a shape key).
|
|
|
|
*
|
2022-08-12 12:42:03 +02:00
|
|
|
* \param owner_id_hint: If not NULL, a potential owner for the given override-embedded `id`.
|
|
|
|
* \param r_owner_id: If given, will be set with the actual ID owning the return liboverride data.
|
2022-08-02 15:03:11 +02:00
|
|
|
*/
|
|
|
|
IDOverrideLibrary *BKE_lib_override_library_get(struct Main *bmain,
|
|
|
|
struct ID *id,
|
2022-08-12 10:39:03 +02:00
|
|
|
struct ID *owner_id_hint,
|
2022-08-02 15:03:11 +02:00
|
|
|
struct ID **r_owner_id);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check if given ID has some override rules that actually indicate the user edited it.
|
|
|
|
*/
|
2022-05-31 17:31:32 +02:00
|
|
|
bool BKE_lib_override_library_is_user_edited(const struct ID *id);
|
2021-03-05 08:37:51 +01:00
|
|
|
|
2022-02-22 17:20:18 +01:00
|
|
|
/**
|
|
|
|
* Check if given ID is a system override.
|
|
|
|
*/
|
2022-05-31 17:31:32 +02:00
|
|
|
bool BKE_lib_override_library_is_system_defined(const struct Main *bmain, const struct ID *id);
|
2022-02-22 17:20:18 +01:00
|
|
|
|
2022-06-10 15:53:46 +02:00
|
|
|
/**
|
|
|
|
* Check if given Override Property for given ID is animated (through a F-Curve in an Action, or
|
|
|
|
* from a driver).
|
|
|
|
*
|
2022-06-30 15:00:55 +02:00
|
|
|
* \param override_rna_prop: if not NULL, the RNA property matching the given path in the
|
2022-06-10 15:53:46 +02:00
|
|
|
* `override_prop`.
|
2022-06-30 15:00:55 +02:00
|
|
|
* \param rnaprop_index: Array in the RNA property, 0 if unknown or irrelevant.
|
2022-06-10 15:53:46 +02:00
|
|
|
*/
|
|
|
|
bool BKE_lib_override_library_property_is_animated(const ID *id,
|
|
|
|
const IDOverrideLibraryProperty *override_prop,
|
|
|
|
const struct PropertyRNA *override_rna_prop,
|
|
|
|
const int rnaprop_index);
|
|
|
|
|
2022-03-24 16:57:16 +01:00
|
|
|
/**
|
|
|
|
* Check if given ID is a leaf in its liboverride hierarchy (i.e. if it does not use any other
|
|
|
|
* override ID).
|
|
|
|
*
|
|
|
|
* NOTE: Embedded IDs of override IDs are not considered as leaves.
|
|
|
|
*/
|
|
|
|
bool BKE_lib_override_library_is_hierarchy_leaf(struct Main *bmain, struct ID *id);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Create an overridden local copy of linked reference.
|
2022-01-05 16:30:15 +01:00
|
|
|
*
|
2022-01-06 03:54:52 +01:00
|
|
|
* \note This function is very basic, low-level. It does not consider any hierarchical dependency,
|
|
|
|
* and also prevents any automatic re-sync of this local override.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain,
|
|
|
|
struct ID *reference_id,
|
2022-01-07 01:38:08 +01:00
|
|
|
bool do_tagged_remap);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Create overridden local copies of all tagged data-blocks in given Main.
|
|
|
|
*
|
2022-09-28 01:41:31 +02:00
|
|
|
* \note Set `id->newid` of overridden libraries with newly created overrides,
|
2021-12-07 07:19:15 +01:00
|
|
|
* caller is responsible to clean those pointers before/after usage as needed.
|
|
|
|
*
|
|
|
|
* \note By default, it will only remap newly created local overriding data-blocks between
|
|
|
|
* themselves, to avoid 'enforcing' those overrides into all other usages of the linked data in
|
|
|
|
* main. You can add more local IDs to be remapped to use new overriding ones by setting their
|
|
|
|
* LIB_TAG_DOIT tag.
|
|
|
|
*
|
2022-02-01 16:11:59 +01:00
|
|
|
* \param owner_library: the library in which the overrides should be created. Besides versioning
|
|
|
|
* and resync code path, this should always be NULL (i.e. the local .blend file).
|
|
|
|
*
|
2022-02-10 14:55:12 +01:00
|
|
|
* \param id_root_reference: the linked ID that is considered as the root of the overridden
|
|
|
|
* hierarchy.
|
|
|
|
*
|
|
|
|
* \param id_hierarchy_root: the override ID that is the root of the hierarchy. May be NULL, in
|
|
|
|
* which case it is assumed that the given `id_root_reference` is tagged for override, and its
|
2022-02-25 12:15:56 +01:00
|
|
|
* newly created override will be used as hierarchy root. Must be NULL if
|
|
|
|
* `id_hierarchy_root_reference` is not NULL.
|
|
|
|
*
|
|
|
|
* \param id_hierarchy_root_reference: the linked ID that is the root of the hierarchy. Must be
|
|
|
|
* tagged for override. May be NULL, in which case it is assumed that the given `id_root_reference`
|
|
|
|
* is tagged for override, and its newly created override will be used as hierarchy root. Must be
|
|
|
|
* NULL if `id_hierarchy_root` is not NULL.
|
2021-12-07 07:19:15 +01:00
|
|
|
*
|
|
|
|
* \param do_no_main: Create the new override data outside of Main database.
|
|
|
|
* Used for resyncing of linked overrides.
|
|
|
|
*
|
2022-05-20 11:59:39 +02:00
|
|
|
* \param do_fully_editable: if true, tag all created overrides as user-editable by default.
|
|
|
|
*
|
2021-12-07 07:19:15 +01:00
|
|
|
* \return \a true on success, \a false otherwise.
|
|
|
|
*/
|
LibOverride: add recursive resync.
Recursive resync means also resyncing overrides that are linked from
other library files into current working file.
Note that this allows to get 'working' files even when their
dependencies are out of sync. However, since linked data is never
written/saved, this has to be re-done every time the working file is
loaded, until said dependencies are updated properly.
NOTE: This is still missing the 'report' side of things, which is part
of a larger task to enhance reports regarding both linking, and
liboverrides (see T88393).
----------
Technical notes:
Implementing this proved to be slightly more challenging than expected,
mainly because one of the key aspects of the feature was never done in
Blender before: manipulating, re-creating linked data.
This ended up moving the whole resync code to use temp IDs out of bmain,
which is better in the long run anyway (and more aligned with what we
generally want to do when manipulating temp ID data). It should also
give a marginal improvement in performances for regular resync.
This commit also had to carefully 'sort' libraries by level of indirect
usage, as we want to resync first the libraries that are the least directly
used, i.e. libraries that are most used by other libraries.
2021-05-26 16:53:59 +02:00
|
|
|
bool BKE_lib_override_library_create_from_tag(struct Main *bmain,
|
2022-02-01 16:11:59 +01:00
|
|
|
struct Library *owner_library,
|
2022-01-12 10:43:42 +01:00
|
|
|
const struct ID *id_root_reference,
|
2022-02-10 14:55:12 +01:00
|
|
|
struct ID *id_hierarchy_root,
|
2022-02-25 12:15:56 +01:00
|
|
|
const struct ID *id_hierarchy_root_reference,
|
2022-05-20 11:59:39 +02:00
|
|
|
bool do_no_main,
|
|
|
|
const bool do_fully_editable);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Advanced 'smart' function to create fully functional overrides.
|
|
|
|
*
|
|
|
|
* \note Currently it only does special things if given \a id_root is an object or collection, more
|
|
|
|
* specific behaviors may be added in the future for other ID types.
|
|
|
|
*
|
|
|
|
* \note It will override all IDs tagged with \a LIB_TAG_DOIT, and it does not clear that tag at
|
|
|
|
* its beginning, so caller code can add extra data-blocks to be overridden as well.
|
|
|
|
*
|
|
|
|
* \param view_layer: the active view layer to search instantiated collections in, can be NULL (in
|
|
|
|
* which case \a scene's master collection children hierarchy is used instead).
|
2022-02-01 16:11:59 +01:00
|
|
|
*
|
|
|
|
* \param owner_library: the library in which the overrides should be created. Besides versioning
|
|
|
|
* and resync code path, this should always be NULL (i.e. the local .blend file).
|
|
|
|
*
|
2022-02-25 12:15:56 +01:00
|
|
|
* \param id_root_reference: The linked root ID to create an override from. May be a sub-root of
|
|
|
|
* the overall hierarchy, in which case calling code is expected to have already tagged required
|
|
|
|
* 'path' of IDs leading from the given `id_hierarchy_root` to the given `id_root`.
|
|
|
|
*
|
|
|
|
* \param id_hierarchy_root_reference: The ID to be used a hierarchy root of the overrides to be
|
|
|
|
* created. Can be either the linked root ID of the whole override hierarchy, (typically the same
|
|
|
|
* as `id_root`, unless a sub-part only of the hierarchy is overridden), or the already existing
|
|
|
|
* override hierarchy root if part of the hierarchy is already overridden.
|
2022-02-01 16:11:59 +01:00
|
|
|
*
|
2022-02-25 12:15:56 +01:00
|
|
|
* \param id_instance_hint: Some ID used as hint/reference to do some post-processing after
|
|
|
|
* overrides have been created, may be NULL. Typically, the Empty object instantiating the linked
|
|
|
|
* collection we override, currently.
|
2022-02-01 16:11:59 +01:00
|
|
|
*
|
2021-12-07 07:19:15 +01:00
|
|
|
* \param r_id_root_override: if not NULL, the override generated for the given \a id_root.
|
2022-02-01 16:11:59 +01:00
|
|
|
*
|
2022-05-20 11:59:39 +02:00
|
|
|
* \param do_fully_editable: if true, tag all created overrides as user-editable by default.
|
|
|
|
*
|
2021-12-07 07:19:15 +01:00
|
|
|
* \return true if override was successfully created.
|
|
|
|
*/
|
2020-07-15 18:09:30 +02:00
|
|
|
bool BKE_lib_override_library_create(struct Main *bmain,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct ViewLayer *view_layer,
|
2022-02-01 16:11:59 +01:00
|
|
|
struct Library *owner_library,
|
2022-02-25 12:15:56 +01:00
|
|
|
struct ID *id_root_reference,
|
|
|
|
struct ID *id_hierarchy_root_reference,
|
|
|
|
struct ID *id_instance_hint,
|
2022-05-20 11:59:39 +02:00
|
|
|
struct ID **r_id_root_override,
|
|
|
|
const bool do_fully_editable);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Create a library override template.
|
|
|
|
*/
|
2021-03-29 09:53:12 +02:00
|
|
|
bool BKE_lib_override_library_template_create(struct ID *id);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Convert a given proxy object into a library override.
|
|
|
|
*
|
|
|
|
* \note This is a thin wrapper around \a BKE_lib_override_library_create, only extra work is to
|
|
|
|
* actually convert the proxy itself into an override first.
|
|
|
|
*
|
|
|
|
* \param view_layer: the active view layer to search instantiated collections in, can be NULL (in
|
|
|
|
* which case \a scene's master collection children hierarchy is used instead).
|
|
|
|
* \return true if override was successfully created.
|
|
|
|
*/
|
2020-09-23 10:47:27 +02:00
|
|
|
bool BKE_lib_override_library_proxy_convert(struct Main *bmain,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct ViewLayer *view_layer,
|
|
|
|
struct Object *ob_proxy);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Convert all proxy objects into library overrides.
|
|
|
|
*
|
|
|
|
* \note Only affects local proxies, linked ones are not affected.
|
|
|
|
*/
|
2021-09-21 15:11:09 +02:00
|
|
|
void BKE_lib_override_library_main_proxy_convert(struct Main *bmain,
|
|
|
|
struct BlendFileReadReport *reports);
|
2022-01-12 10:43:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find and set the 'hierarchy root' ID pointer of all library overrides in given `bmain`.
|
|
|
|
*
|
|
|
|
* NOTE: Cannot be called from `do_versions_after_linking` as this code needs a single complete
|
|
|
|
* Main database, not a split-by-libraries one.
|
|
|
|
*/
|
|
|
|
void BKE_lib_override_library_main_hierarchy_root_ensure(struct Main *bmain);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Advanced 'smart' function to resync, re-create fully functional overrides up-to-date with linked
|
|
|
|
* data, from an existing override hierarchy.
|
|
|
|
*
|
|
|
|
* \param view_layer: the active view layer to search instantiated collections in, can be NULL (in
|
|
|
|
* which case \a scene's master collection children hierarchy is used instead).
|
2022-01-07 15:25:25 +01:00
|
|
|
* \param id_root: The root liboverride ID to resync from.
|
2021-12-07 07:19:15 +01:00
|
|
|
* \return true if override was successfully resynced.
|
|
|
|
*/
|
2020-08-19 16:24:58 +02:00
|
|
|
bool BKE_lib_override_library_resync(struct Main *bmain,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct ViewLayer *view_layer,
|
2021-03-12 12:31:25 +01:00
|
|
|
struct ID *id_root,
|
2021-03-19 17:31:39 +01:00
|
|
|
struct Collection *override_resync_residual_storage,
|
2022-01-07 01:38:08 +01:00
|
|
|
bool do_hierarchy_enforce,
|
2021-06-23 09:51:11 +02:00
|
|
|
struct BlendFileReadReport *reports);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Detect and handle required resync of overrides data, when relations between reference linked IDs
|
|
|
|
* have changed.
|
|
|
|
*
|
|
|
|
* This is a fairly complex and costly operation, typically it should be called after
|
|
|
|
* #BKE_lib_override_library_main_update, which would already detect and tag a lot of cases.
|
|
|
|
*
|
|
|
|
* This function will first detect the remaining cases requiring a resync (namely, either when an
|
|
|
|
* existing linked ID that did not require to be overridden before now would be, or when new IDs
|
|
|
|
* are added to the hierarchy).
|
|
|
|
*
|
|
|
|
* Then it will handle the resync of necessary IDs (through calls to
|
|
|
|
* #BKE_lib_override_library_resync).
|
|
|
|
*
|
|
|
|
* \param view_layer: the active view layer to search instantiated collections in, can be NULL (in
|
|
|
|
* which case \a scene's master collection children hierarchy is used instead).
|
|
|
|
*/
|
2021-03-05 09:16:26 +01:00
|
|
|
void BKE_lib_override_library_main_resync(struct Main *bmain,
|
|
|
|
struct Scene *scene,
|
2021-05-06 19:04:47 +02:00
|
|
|
struct ViewLayer *view_layer,
|
2021-06-23 09:51:11 +02:00
|
|
|
struct BlendFileReadReport *reports);
|
2021-03-05 09:16:26 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Advanced 'smart' function to delete library overrides (including their existing override
|
|
|
|
* hierarchy) and remap their usages to their linked reference IDs.
|
|
|
|
*
|
|
|
|
* \note All IDs tagged with #LIB_TAG_DOIT will be deleted.
|
|
|
|
*
|
|
|
|
* \param id_root: The root liboverride ID to delete.
|
|
|
|
*/
|
2020-08-20 12:35:16 +02:00
|
|
|
void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Make given ID fully local.
|
|
|
|
*
|
|
|
|
* \note Only differs from lower-level #BKE_lib_override_library_free in infamous embedded ID
|
|
|
|
* cases.
|
|
|
|
*/
|
2021-06-28 17:00:08 +02:00
|
|
|
void BKE_lib_override_library_make_local(struct ID *id);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find override property from given RNA path, if it exists.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_find(
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibrary *override, const char *rna_path);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find override property from given RNA path, or create it if it does not exist.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_get(
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibrary *override, const char *rna_path, bool *r_created);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove and free given \a override_property from given ID \a override.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_property_delete(struct IDOverrideLibrary *override,
|
|
|
|
struct IDOverrideLibraryProperty *override_property);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Get the RNA-property matching the \a library_prop override property. Used for UI to query
|
|
|
|
* additional data about the overridden property (e.g. UI name).
|
|
|
|
*
|
|
|
|
* \param idpoin: Pointer to the override ID.
|
|
|
|
* \param library_prop: The library override property to find the matching RNA property for.
|
2022-06-14 06:30:13 +02:00
|
|
|
* \param r_index: The RNA array flat index (i.e. flattened index in case of multi-dimensional
|
|
|
|
* array properties). See #RNA_path_resolve_full family of functions for details.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2020-12-27 22:15:20 +01:00
|
|
|
bool BKE_lib_override_rna_property_find(struct PointerRNA *idpoin,
|
|
|
|
const struct IDOverrideLibraryProperty *library_prop,
|
|
|
|
struct PointerRNA *r_override_poin,
|
2022-06-10 14:44:25 +02:00
|
|
|
struct PropertyRNA **r_override_prop,
|
|
|
|
int *r_index);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find override property operation from given sub-item(s), if it exists.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_find(
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibraryProperty *override_property,
|
2017-11-29 15:05:03 +01:00
|
|
|
const char *subitem_refname,
|
|
|
|
const char *subitem_locname,
|
2022-01-07 01:38:08 +01:00
|
|
|
int subitem_refindex,
|
|
|
|
int subitem_locindex,
|
|
|
|
bool strict,
|
2017-11-29 15:05:03 +01:00
|
|
|
bool *r_strict);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find override property operation from given sub-item(s), or create it if it does not exist.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_get(
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibraryProperty *override_property,
|
2022-01-07 01:38:08 +01:00
|
|
|
short operation,
|
2017-11-29 15:05:03 +01:00
|
|
|
const char *subitem_refname,
|
|
|
|
const char *subitem_locname,
|
2022-01-07 01:38:08 +01:00
|
|
|
int subitem_refindex,
|
|
|
|
int subitem_locindex,
|
|
|
|
bool strict,
|
2017-11-29 15:05:03 +01:00
|
|
|
bool *r_strict,
|
|
|
|
bool *r_created);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove and free given \a override_property_operation from given ID \a override_property.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_property_operation_delete(
|
2019-06-14 23:16:04 +02:00
|
|
|
struct IDOverrideLibraryProperty *override_property,
|
|
|
|
struct IDOverrideLibraryPropertyOperation *override_property_operation);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Validate that required data for a given operation are available.
|
|
|
|
*/
|
2020-04-15 17:26:34 +02:00
|
|
|
bool BKE_lib_override_library_property_operation_operands_validate(
|
|
|
|
struct IDOverrideLibraryPropertyOperation *override_property_operation,
|
|
|
|
struct PointerRNA *ptr_dst,
|
|
|
|
struct PointerRNA *ptr_src,
|
|
|
|
struct PointerRNA *ptr_storage,
|
|
|
|
struct PropertyRNA *prop_dst,
|
|
|
|
struct PropertyRNA *prop_src,
|
|
|
|
struct PropertyRNA *prop_storage);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check against potential \a bmain.
|
|
|
|
*/
|
2021-03-15 15:19:22 +01:00
|
|
|
void BKE_lib_override_library_validate(struct Main *bmain,
|
|
|
|
struct ID *id,
|
|
|
|
struct ReportList *reports);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check against potential \a bmain.
|
|
|
|
*/
|
2021-03-15 15:19:22 +01:00
|
|
|
void BKE_lib_override_library_main_validate(struct Main *bmain, struct ReportList *reports);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check that status of local data-block is still valid against current reference one.
|
|
|
|
*
|
|
|
|
* It means that all overridable, but not overridden, properties' local values must be equal to
|
|
|
|
* reference ones. Clears #LIB_TAG_OVERRIDE_OK if they do not.
|
|
|
|
*
|
|
|
|
* This is typically used to detect whether some property has been changed in local and a new
|
|
|
|
* #IDOverrideProperty (of #IDOverridePropertyOperation) has to be added.
|
|
|
|
*
|
2022-01-14 00:47:50 +01:00
|
|
|
* \return true if status is OK, false otherwise.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
bool BKE_lib_override_library_status_check_local(struct Main *bmain, struct ID *local);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check that status of reference data-block is still valid against current local one.
|
|
|
|
*
|
|
|
|
* It means that all non-overridden properties' local values must be equal to reference ones.
|
|
|
|
* Clears LIB_TAG_OVERRIDE_OK if they do not.
|
|
|
|
*
|
|
|
|
* This is typically used to detect whether some reference has changed and local
|
|
|
|
* needs to be updated against it.
|
|
|
|
*
|
2022-01-14 00:47:50 +01:00
|
|
|
* \return true if status is OK, false otherwise.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
bool BKE_lib_override_library_status_check_reference(struct Main *bmain, struct ID *local);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Compare local and reference data-blocks and create new override operations as needed,
|
|
|
|
* or reset to reference values if overriding is not allowed.
|
|
|
|
*
|
2022-12-20 15:36:29 +01:00
|
|
|
* \param r_report_flags #eRNAOverrideMatchResult flags giving info about the result of this call.
|
|
|
|
*
|
2021-12-07 07:19:15 +01:00
|
|
|
* \note Defining override operations is only mandatory before saving a `.blend` file on disk
|
|
|
|
* (not for undo!).
|
|
|
|
* Knowing that info at runtime is only useful for UI/UX feedback.
|
|
|
|
*
|
|
|
|
* \note This is by far the biggest operation (the more time-consuming) of the three so far,
|
|
|
|
* since it has to go over all properties in depth (all overridable ones at least).
|
|
|
|
* Generating differential values and applying overrides are much cheaper.
|
|
|
|
*
|
|
|
|
* \return true if any library operation was created.
|
|
|
|
*/
|
2022-12-20 15:36:29 +01:00
|
|
|
void BKE_lib_override_library_operations_create(struct Main *bmain,
|
|
|
|
struct ID *local,
|
|
|
|
int *r_report_flags);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check all overrides from given \a bmain and create/update overriding operations as needed.
|
2022-12-20 15:36:29 +01:00
|
|
|
*
|
|
|
|
* \param r_report_flags #eRNAOverrideMatchResult flags giving info about the result of this call.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2022-12-20 15:36:29 +01:00
|
|
|
void BKE_lib_override_library_main_operations_create(struct Main *bmain,
|
|
|
|
bool force_auto,
|
|
|
|
int *r_report_flags);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Reset all overrides in given \a id_root, while preserving ID relations.
|
2022-03-24 16:57:16 +01:00
|
|
|
*
|
2022-03-31 04:00:10 +02:00
|
|
|
* \param do_reset_system_override: If \a true, reset the given ID as a system override one (i.e.
|
2022-03-24 16:57:16 +01:00
|
|
|
* non-editable).
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2022-03-24 16:57:16 +01:00
|
|
|
void BKE_lib_override_library_id_reset(struct Main *bmain,
|
|
|
|
struct ID *id_root,
|
|
|
|
bool do_reset_system_override);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Reset all overrides in given \a id_root and its dependencies, while preserving ID relations.
|
2022-03-24 16:57:16 +01:00
|
|
|
*
|
2022-03-31 04:00:10 +02:00
|
|
|
* \param do_reset_system_override: If \a true, reset the given ID and all of its descendants in
|
|
|
|
* the override hierarchy as system override ones (i.e. non-editable).
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2022-03-24 16:57:16 +01:00
|
|
|
void BKE_lib_override_library_id_hierarchy_reset(struct Main *bmain,
|
|
|
|
struct ID *id_root,
|
|
|
|
bool do_reset_system_override);
|
2020-07-23 11:30:48 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Set or clear given tag in all operations in that override property data.
|
|
|
|
*/
|
2020-04-16 16:19:44 +02:00
|
|
|
void BKE_lib_override_library_operations_tag(struct IDOverrideLibraryProperty *override_property,
|
2022-01-07 01:38:08 +01:00
|
|
|
short tag,
|
|
|
|
bool do_set);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Set or clear given tag in all properties and operations in that override data.
|
|
|
|
*/
|
2020-04-16 16:19:44 +02:00
|
|
|
void BKE_lib_override_library_properties_tag(struct IDOverrideLibrary *override,
|
2022-01-07 01:38:08 +01:00
|
|
|
short tag,
|
|
|
|
bool do_set);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Set or clear given tag in all properties and operations in that Main's ID override data.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_lib_override_library_main_tag(struct Main *bmain, short tag, bool do_set);
|
2020-04-16 16:19:44 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove all tagged-as-unused properties and operations from that ID override data.
|
|
|
|
*/
|
2020-04-16 16:19:44 +02:00
|
|
|
void BKE_lib_override_library_id_unused_cleanup(struct ID *local);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove all tagged-as-unused properties and operations from that Main's ID override data.
|
|
|
|
*/
|
2020-04-16 16:19:44 +02:00
|
|
|
void BKE_lib_override_library_main_unused_cleanup(struct Main *bmain);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Update given override from its reference (re-applying overridden properties).
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_update(struct Main *bmain, struct ID *local);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Update all overrides from given \a bmain.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_main_update(struct Main *bmain);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* In case an ID is used by another liboverride ID, user may not be allowed to delete it.
|
|
|
|
*/
|
2021-09-28 18:29:02 +02:00
|
|
|
bool BKE_lib_override_library_id_is_user_deletable(struct Main *bmain, struct ID *id);
|
|
|
|
|
2017-11-29 15:05:03 +01:00
|
|
|
/* Storage (.blend file writing) part. */
|
|
|
|
|
|
|
|
/* For now, we just use a temp main list. */
|
2019-06-14 23:16:04 +02:00
|
|
|
typedef struct Main OverrideLibraryStorage;
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Initialize an override storage.
|
|
|
|
*/
|
2020-08-05 03:56:14 +02:00
|
|
|
OverrideLibraryStorage *BKE_lib_override_library_operations_store_init(void);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Generate suitable 'write' data (this only affects differential override operations).
|
|
|
|
*
|
|
|
|
* Note that \a local ID is no more modified by this call,
|
|
|
|
* all extra data are stored in its temp \a storage_id copy.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
struct ID *BKE_lib_override_library_operations_store_start(
|
|
|
|
struct Main *bmain, OverrideLibraryStorage *override_storage, struct ID *local);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Restore given ID modified by #BKE_lib_override_library_operations_store_start, to its
|
|
|
|
* original state.
|
|
|
|
*/
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_operations_store_end(OverrideLibraryStorage *override_storage,
|
|
|
|
struct ID *local);
|
|
|
|
void BKE_lib_override_library_operations_store_finalize(OverrideLibraryStorage *override_storage);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|