2017-11-29 15:05:03 +01:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2016 by Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2020-02-10 16:54:24 +01:00
|
|
|
#pragma once
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2020-02-10 15:05:54 +01:00
|
|
|
*
|
2020-02-15 15:58:06 +11: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-03-19 17:31:39 +01: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 11:51:13 +10: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
|
|
|
|
2020-02-10 18:05:19 +01:00
|
|
|
struct IDOverrideLibrary *BKE_lib_override_library_init(struct ID *local_id,
|
|
|
|
struct ID *reference_id);
|
2020-06-10 16:43:25 +02:00
|
|
|
void BKE_lib_override_library_copy(struct ID *dst_id,
|
|
|
|
const struct ID *src_id,
|
|
|
|
const bool do_full_copy);
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_clear(struct IDOverrideLibrary *override, const bool do_id_user);
|
|
|
|
void BKE_lib_override_library_free(struct IDOverrideLibrary **override, const bool do_id_user);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2021-03-05 08:37:51 +01:00
|
|
|
bool BKE_lib_override_library_is_user_edited(struct ID *id);
|
|
|
|
|
2020-02-10 18:05:19 +01:00
|
|
|
struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain,
|
|
|
|
struct ID *reference_id,
|
|
|
|
const bool do_tagged_remap);
|
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,
|
|
|
|
const struct Library *reference_library,
|
|
|
|
const bool do_no_main);
|
2020-07-15 18:09:30 +02:00
|
|
|
bool BKE_lib_override_library_create(struct Main *bmain,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct ViewLayer *view_layer,
|
|
|
|
struct ID *id_root,
|
2021-06-03 15:00:10 +02:00
|
|
|
struct ID *id_reference,
|
|
|
|
struct ID **r_id_root_override);
|
2021-03-29 09:53:12 +02:00
|
|
|
bool BKE_lib_override_library_template_create(struct ID *id);
|
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);
|
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,
|
2021-04-08 11:27:05 +02:00
|
|
|
const bool do_hierarchy_enforce,
|
2021-05-06 19:04:47 +02:00
|
|
|
const bool do_post_process,
|
|
|
|
struct ReportList *reports);
|
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,
|
|
|
|
struct ReportList *reports);
|
2021-03-05 09:16:26 +01:00
|
|
|
|
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
|
|
|
|
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);
|
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);
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_property_delete(struct IDOverrideLibrary *override,
|
|
|
|
struct IDOverrideLibraryProperty *override_property);
|
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,
|
|
|
|
struct PropertyRNA **r_override_prop);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
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,
|
|
|
|
const int subitem_refindex,
|
|
|
|
const int subitem_locindex,
|
|
|
|
const bool strict,
|
|
|
|
bool *r_strict);
|
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,
|
2017-11-29 15:05:03 +01:00
|
|
|
const short operation,
|
|
|
|
const char *subitem_refname,
|
|
|
|
const char *subitem_locname,
|
|
|
|
const int subitem_refindex,
|
|
|
|
const int subitem_locindex,
|
|
|
|
const bool strict,
|
|
|
|
bool *r_strict,
|
|
|
|
bool *r_created);
|
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
|
|
|
|
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-03-15 15:19:22 +01:00
|
|
|
void BKE_lib_override_library_validate(struct Main *bmain,
|
|
|
|
struct ID *id,
|
|
|
|
struct ReportList *reports);
|
|
|
|
void BKE_lib_override_library_main_validate(struct Main *bmain, struct ReportList *reports);
|
|
|
|
|
2020-02-10 18:05:19 +01:00
|
|
|
bool BKE_lib_override_library_status_check_local(struct Main *bmain, struct ID *local);
|
|
|
|
bool BKE_lib_override_library_status_check_reference(struct Main *bmain, struct ID *local);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2020-06-19 17:00:42 +02:00
|
|
|
bool BKE_lib_override_library_operations_create(struct Main *bmain, struct ID *local);
|
2020-12-27 22:15:20 +01:00
|
|
|
bool BKE_lib_override_library_main_operations_create(struct Main *bmain, const bool force_auto);
|
2017-11-29 15:05:03 +01:00
|
|
|
|
2020-07-23 11:30:48 +02:00
|
|
|
void BKE_lib_override_library_id_reset(struct Main *bmain, struct ID *id_root);
|
|
|
|
void BKE_lib_override_library_id_hierarchy_reset(struct Main *bmain, struct ID *id_root);
|
|
|
|
|
2020-04-16 16:19:44 +02:00
|
|
|
void BKE_lib_override_library_operations_tag(struct IDOverrideLibraryProperty *override_property,
|
|
|
|
const short tag,
|
|
|
|
const bool do_set);
|
|
|
|
void BKE_lib_override_library_properties_tag(struct IDOverrideLibrary *override,
|
|
|
|
const short tag,
|
|
|
|
const bool do_set);
|
|
|
|
void BKE_lib_override_library_main_tag(struct Main *bmain, const short tag, const bool do_set);
|
|
|
|
|
|
|
|
void BKE_lib_override_library_id_unused_cleanup(struct ID *local);
|
|
|
|
void BKE_lib_override_library_main_unused_cleanup(struct Main *bmain);
|
|
|
|
|
2020-02-10 18:05:19 +01:00
|
|
|
void BKE_lib_override_library_update(struct Main *bmain, struct ID *local);
|
|
|
|
void BKE_lib_override_library_main_update(struct Main *bmain);
|
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
|
|
|
|
2020-08-05 11:56:14 +10:00
|
|
|
OverrideLibraryStorage *BKE_lib_override_library_operations_store_init(void);
|
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);
|
|
|
|
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
|