Blender
V3.3
|
#include "CLG_log.h"
#include "BLI_linklist.h"
#include "BLI_utildefines.h"
#include "DNA_collection_types.h"
#include "DNA_object_types.h"
#include "BKE_armature.h"
#include "BKE_collection.h"
#include "BKE_curve.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "lib_intern.h"
Go to the source code of this file.
Classes | |
struct | IDRemap |
struct | LibblockRemapMultipleUserData |
struct | LibblockRelinkMultipleUserData |
struct | RelinkToNewIDData |
Typedefs | |
typedef struct IDRemap | IDRemap |
typedef struct LibblockRemapMultipleUserData | LibBlockRemapMultipleUserData |
typedef struct LibblockRelinkMultipleUserData | LibBlockRelinkMultipleUserData |
typedef struct RelinkToNewIDData | RelinkToNewIDData |
Functions | |
void | BKE_library_callback_free_notifier_reference_set (BKE_library_free_notifier_reference_cb func) |
void | BKE_library_callback_remap_editor_id_reference_set (BKE_library_remap_editor_id_reference_cb func) |
static void | foreach_libblock_remap_callback_skip (const ID *UNUSED(id_owner), ID **id_ptr, const int cb_flag, const bool is_indirect, const bool is_reference, const bool violates_never_null, const bool UNUSED(is_obj), const bool is_obj_editmode) |
static void | foreach_libblock_remap_callback_apply (ID *id_owner, ID *id_self, ID **id_ptr, IDRemap *id_remap_data, const struct IDRemapper *mappings, const IDRemapperApplyOptions id_remapper_options, const int cb_flag, const bool is_indirect, const bool violates_never_null, const bool force_user_refcount) |
static int | foreach_libblock_remap_callback (LibraryIDLinkCallbackData *cb_data) |
static void | libblock_remap_data_preprocess_ob (Object *ob, eIDRemapType remap_type, const struct IDRemapper *id_remapper) |
static void | libblock_remap_data_preprocess (ID *id_owner, eIDRemapType remap_type, const struct IDRemapper *id_remapper) |
static void | libblock_remap_data_postprocess_object_update (Main *bmain, Object *old_ob, Object *new_ob, const bool do_sync_collection) |
static void | libblock_remap_data_postprocess_collection_update (Main *bmain, Collection *owner_collection, Collection *UNUSED(old_collection), Collection *new_collection) |
static void | libblock_remap_data_postprocess_obdata_relink (Main *bmain, Object *ob, ID *new_id) |
static void | libblock_remap_data_postprocess_nodetree_update (Main *bmain, ID *new_id) |
static void | libblock_remap_data_update_tags (ID *old_id, ID *new_id, void *user_data) |
static void | libblock_remap_reset_remapping_status_callback (ID *old_id, ID *new_id, void *UNUSED(user_data)) |
static void | libblock_remap_data (Main *bmain, ID *id, eIDRemapType remap_type, struct IDRemapper *id_remapper, const short remap_flags) |
static void | libblock_remap_foreach_idpair_cb (ID *old_id, ID *new_id, void *user_data) |
void | BKE_libblock_remap_multiple_locked (Main *bmain, struct IDRemapper *mappings, const short remap_flags) |
void | BKE_libblock_remap_locked (Main *bmain, void *old_idv, void *new_idv, const short remap_flags) |
void | BKE_libblock_remap (Main *bmain, void *old_idv, void *new_idv, const short remap_flags) |
void | BKE_libblock_remap_multiple (Main *bmain, struct IDRemapper *mappings, const short remap_flags) |
void | BKE_libblock_unlink (Main *bmain, void *idv, const bool do_flag_never_null, const bool do_skip_indirect) |
static void | libblock_relink_foreach_idpair_cb (ID *old_id, ID *new_id, void *user_data) |
void | BKE_libblock_relink_multiple (Main *bmain, LinkNode *ids, const eIDRemapType remap_type, struct IDRemapper *id_remapper, const short remap_flags) |
void | BKE_libblock_relink_ex (Main *bmain, void *idv, void *old_idv, void *new_idv, const short remap_flags) |
static void | libblock_relink_to_newid_prepare_data (Main *bmain, ID *id, RelinkToNewIDData *relink_data) |
static int | id_relink_to_newid_looper (LibraryIDLinkCallbackData *cb_data) |
void | BKE_libblock_relink_to_newid (Main *bmain, ID *id, const int remap_flag) |
Variables | |
static CLG_LogRef | LOG = {.identifier = "bke.lib_remap"} |
BKE_library_free_notifier_reference_cb | free_notifier_reference_cb = NULL |
BKE_library_remap_editor_id_reference_cb | remap_editor_id_reference_cb = NULL |
Contains management of ID's for remapping.
Definition in file lib_remap.c.
typedef struct LibblockRelinkMultipleUserData LibBlockRelinkMultipleUserData |
typedef struct LibblockRemapMultipleUserData LibBlockRemapMultipleUserData |
typedef struct RelinkToNewIDData RelinkToNewIDData |
void BKE_libblock_relink_ex | ( | Main * | bmain, |
void * | idv, | ||
void * | old_idv, | ||
void * | new_idv, | ||
const short | remap_flags | ||
) |
Definition at line 816 of file lib_remap.c.
References BKE_id_remapper_add(), BKE_id_remapper_create(), BKE_id_remapper_free(), BKE_libblock_relink_multiple(), BLI_assert, GS, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, ID::name, LinkNode::next, NULL, and UNUSED_VARS_NDEBUG.
void BKE_libblock_relink_multiple | ( | struct Main * | bmain, |
struct LinkNode * | ids, | ||
eIDRemapType | remap_type, | ||
struct IDRemapper * | id_remapper, | ||
short | remap_flags | ||
) |
Same as BKE_libblock_relink_ex, but applies all rules defined in id_remapper to ids (or does cleanup if ID_REMAP_TYPE_CLEANUP
is specified as remap_type).
Definition at line 754 of file lib_remap.c.
References BKE_id_remapper_is_empty(), BKE_id_remapper_iter(), BLI_assert, BLI_assert_unreachable, DEG_relations_tag_update(), GS, ID_GR, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, ID_SCE, libblock_relink_foreach_idpair_cb(), libblock_remap_data(), libblock_remap_data_postprocess_collection_update(), libblock_remap_data_postprocess_object_update(), ID::name, NULL, and user_data.
Referenced by BKE_lib_override_library_create_from_tag(), BKE_libblock_relink_ex(), BKE_libblock_relink_to_newid(), lib_override_library_remap(), and lib_override_library_resync().
Remaps ID usages of given ID to their id->newid
pointer if not None, and proceeds recursively in the dependency tree of IDs for all data-blocks tagged with LIB_TAG_NEW
.
LIB_TAG_NEW
is cleared.Very specific usage, not sure we'll keep it on the long run, currently only used in Object/Collection duplication code.
Definition at line 894 of file lib_remap.c.
References BKE_id_remapper_create(), BKE_id_remapper_free(), BKE_libblock_relink_multiple(), BLI_assert, BLI_linklist_free(), ID_IS_LINKED, ID_REMAP_SKIP_INDIRECT_USAGE, ID_REMAP_SKIP_OVERRIDE_LIBRARY, ID_REMAP_TYPE_REMAP, RelinkToNewIDData::id_remapper, RelinkToNewIDData::ids, libblock_relink_to_newid_prepare_data(), NULL, and Main::relations.
Referenced by BKE_blendfile_append(), BKE_collection_duplicate(), BKE_object_duplicate(), BKE_scene_duplicate(), copy_object_set_idnew(), ED_object_add_duplicate(), libblock_relink_collection(), make_object_duplilist_real(), and single_object_users().
Definition at line 652 of file lib_remap.c.
References BKE_libblock_remap_locked(), BKE_main_lock(), and BKE_main_unlock().
void BKE_libblock_remap_locked | ( | Main * | bmain, |
void * | old_idv, | ||
void * | new_idv, | ||
const short | remap_flags | ||
) |
Definition at line 642 of file lib_remap.c.
References BKE_id_remapper_add(), BKE_id_remapper_create(), BKE_id_remapper_free(), and BKE_libblock_remap_multiple_locked().
Referenced by BKE_libblock_remap(), and BKE_libblock_unlink().
void BKE_libblock_remap_multiple | ( | Main * | bmain, |
struct IDRemapper * | mappings, | ||
const short | remap_flags | ||
) |
Definition at line 661 of file lib_remap.c.
References BKE_libblock_remap_multiple_locked(), BKE_main_lock(), and BKE_main_unlock().
Referenced by lib_override_library_remap().
void BKE_libblock_remap_multiple_locked | ( | struct Main * | bmain, |
struct IDRemapper * | mappings, | ||
short | remap_flags | ||
) |
Replace all references in given Main using the given mappings
Definition at line 614 of file lib_remap.c.
References BKE_id_remapper_is_empty(), BKE_id_remapper_iter(), DEG_relations_tag_update(), ID_REMAP_TYPE_REMAP, libblock_remap_data(), libblock_remap_foreach_idpair_cb(), NULL, remap_editor_id_reference_cb, and user_data.
Referenced by BKE_libblock_remap_locked(), BKE_libblock_remap_multiple(), and id_delete().
void BKE_libblock_unlink | ( | struct Main * | bmain, |
void * | idv, | ||
bool | do_flag_never_null, | ||
bool | do_skip_indirect | ||
) |
Unlink given id from given bmain (does not touch to indirect, i.e. library, usages of the ID).
do_flag_never_null | If true, all IDs using idv in a 'non-NULL' way are flagged by LIB_TAG_DOIT flag (quite obviously, 'non-NULL' usages can never be unlinked by this function). |
Definition at line 670 of file lib_remap.c.
References BKE_libblock_remap_locked(), BKE_main_lock(), BKE_main_unlock(), ID_REMAP_FLAG_NEVER_NULL_USAGE, ID_REMAP_SKIP_INDIRECT_USAGE, and NULL.
Referenced by BKE_id_free_us().
void BKE_library_callback_free_notifier_reference_set | ( | BKE_library_free_notifier_reference_cb | func | ) |
Definition at line 41 of file lib_remap.c.
References free_notifier_reference_cb.
Referenced by WM_init().
void BKE_library_callback_remap_editor_id_reference_set | ( | BKE_library_remap_editor_id_reference_cb | func | ) |
Definition at line 48 of file lib_remap.c.
References remap_editor_id_reference_cb.
Referenced by WM_init().
|
static |
Definition at line 150 of file lib_remap.c.
References BKE_id_remapper_add(), BKE_id_remapper_clear(), BKE_id_remapper_get_mapping_result(), BKE_id_remapper_result_string(), BKE_object_is_in_editmode(), BLI_assert, BLI_assert_msg, LibraryIDLinkCallbackData::cb_flag, data, ELEM, IDRemap::flag, ID::flag, foreach_libblock_remap_callback_apply(), foreach_libblock_remap_callback_skip(), GS, ID_OB, LibraryIDLinkCallbackData::id_owner, IDRemap::id_owner, LibraryIDLinkCallbackData::id_pointer, ID_REMAP_APPLY_DEFAULT, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, ID_REMAP_FLAG_NEVER_NULL_USAGE, ID_REMAP_FORCE_NEVER_NULL_USAGE, ID_REMAP_FORCE_OBDATA_IN_EDITMODE, ID_REMAP_FORCE_USER_REFCOUNT, ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_RESULT_SOURCE_UNASSIGNED, ID_REMAP_RESULT_SOURCE_UNAVAILABLE, ID_REMAP_SKIP_INDIRECT_USAGE, ID_REMAP_SKIP_NEVER_NULL_USAGE, ID_REMAP_SKIP_OVERRIDE_LIBRARY, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, IDRemap::id_remapper, LibraryIDLinkCallbackData::id_self, IDWALK_CB_EMBEDDED, IDWALK_CB_INDIRECT_USAGE, IDWALK_CB_NEVER_NULL, IDWALK_CB_NEVER_SELF, IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE, IDWALK_RET_NOP, ID::lib, LIB_EMBEDDED_DATA, LIB_TAG_DOIT, ID::name, NULL, ID::tag, IDRemap::type, and LibraryIDLinkCallbackData::user_data.
Referenced by libblock_remap_data().
|
static |
Definition at line 98 of file lib_remap.c.
References BKE_id_remapper_apply_ex(), IDRemap::bmain, DEG_id_tag_update_ex(), ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, ID_RECALC_TRANSFORM, ID_REMAP_IS_LINKED_DIRECT, id_us_ensure_real(), id_us_min(), id_us_plus_no_lib(), IDWALK_CB_USER, IDWALK_CB_USER_ONE, LIB_TAG_NO_MAIN, NULL, ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::status, and ID::tag.
Referenced by foreach_libblock_remap_callback().
|
static |
Definition at line 67 of file lib_remap.c.
References BLI_assert, BLI_assert_unreachable, ID_REMAP_IS_USER_ONE_SKIPPED, IDWALK_CB_USER, IDWALK_CB_USER_ONE, and NULL.
Referenced by foreach_libblock_remap_callback().
|
static |
Definition at line 856 of file lib_remap.c.
References BKE_id_remapper_add(), LibraryIDLinkCallbackData::bmain, LibraryIDLinkCallbackData::cb_flag, id, LibraryIDLinkCallbackData::id_pointer, RelinkToNewIDData::id_remapper, IDWALK_CB_EMBEDDED, IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE, IDWALK_RET_NOP, if(), LIB_TAG_NEW, libblock_relink_to_newid_prepare_data(), ID::newid, NULL, ID::tag, and LibraryIDLinkCallbackData::user_data.
Referenced by libblock_relink_to_newid_prepare_data().
Definition at line 698 of file lib_remap.c.
References BLI_assert, data, GS, ID_GR, ID_OB, ID_SCE, libblock_remap_data_postprocess_collection_update(), libblock_remap_data_postprocess_obdata_relink(), libblock_remap_data_postprocess_object_update(), ID::name, NULL, and user_data.
Referenced by BKE_libblock_relink_multiple().
|
static |
Definition at line 881 of file lib_remap.c.
References BKE_library_foreach_ID_link(), BLI_linklist_prepend(), ID_IS_LINKED, id_relink_to_newid_looper(), RelinkToNewIDData::ids, and LIB_TAG_NEW.
Referenced by BKE_libblock_relink_to_newid(), and id_relink_to_newid_looper().
|
static |
Execute the 'data' part of the remapping (that is, all ID pointers from other ID data-blocks).
Behavior differs depending on whether given id is NULL or not:
bmain | the Main data storage to operate on (must never be NULL). |
id | the data-block to operate on (can be NULL, in which case we operate over all IDs from given bmain). |
old_id | the data-block to dereference (may be NULL if id is non-NULL). |
new_id | the new data-block to replace old_id references with (may be NULL). |
r_id_remap_data | if non-NULL, the IDRemap struct to use (useful to retrieve info about remapping process). |
Definition at line 463 of file lib_remap.c.
References BKE_id_remapper_has_mapping_for(), BKE_id_remapper_iter(), BKE_library_foreach_ID_link(), BKE_library_id_can_use_filter_id(), IDRemap::bmain, IDRemap::flag, foreach_libblock_remap_callback(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, id, IDRemap::id_owner, ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS, IDRemap::id_remapper, IDWALK_DO_INTERNAL_RUNTIME_POINTERS, IDWALK_NOP, ID::lib, libblock_remap_data_preprocess(), libblock_remap_data_update_tags(), libblock_remap_reset_remapping_status_callback(), ID::name, NULL, and IDRemap::type.
Referenced by BKE_libblock_relink_multiple(), and BKE_libblock_remap_multiple_locked().
|
static |
Definition at line 360 of file lib_remap.c.
References BKE_collections_child_remove_nulls(), BKE_main_collection_sync_remap(), BKE_main_collections_parent_relations_rebuild(), and NULL.
Referenced by BKE_libblock_relink_multiple(), libblock_relink_foreach_idpair_cb(), and libblock_remap_foreach_idpair_cb().
Definition at line 400 of file lib_remap.c.
References ntreeUpdateAllUsers().
Referenced by libblock_remap_foreach_idpair_cb().
|
static |
Definition at line 382 of file lib_remap.c.
References BKE_curve_type_test(), BKE_modifiers_test_object(), BKE_object_materials_test(), Object::data, GS, ID_CU_LEGACY, ID_ME, multires_force_sculpt_rebuild(), and ID::name.
Referenced by libblock_relink_foreach_idpair_cb(), and libblock_remap_foreach_idpair_cb().
|
static |
Can be called with both old_ob and new_ob being NULL, this means we have to check whole Main database then.
Definition at line 320 of file lib_remap.c.
References BKE_collections_object_remove_duplicates(), BKE_collections_object_remove_nulls(), BKE_main_collection_sync_remap(), BKE_mball_is_basis(), BKE_mball_is_basis_for(), DEG_id_tag_update(), ListBase::first, ID_RECALC_GEOMETRY, NULL, OB_MBALL, and Main::objects.
Referenced by BKE_libblock_relink_multiple(), libblock_relink_foreach_idpair_cb(), and libblock_remap_foreach_idpair_cb().
|
static |
Definition at line 301 of file lib_remap.c.
References GS, ID_OB, libblock_remap_data_preprocess_ob(), and ID::name.
Referenced by libblock_remap_data().
|
static |
Definition at line 268 of file lib_remap.c.
References BKE_id_remapper_get_mapping_result(), BKE_id_remapper_has_mapping_for(), BKE_pose_clear_pointers(), Object::data, FILTER_ID_AR, bPose::flag, ID_REMAP_APPLY_DEFAULT, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_TYPE_CLEANUP, NULL, OB_ARMATURE, Object::pose, POSE_RECALC, and Object::type.
Referenced by libblock_remap_data_preprocess().
Definition at line 406 of file lib_remap.c.
References IDRemap::flag, ID::flag, id_fake_user_clear(), id_fake_user_set(), ID_REMAP_IS_LINKED_DIRECT, ID_REMAP_SKIP_USER_CLEAR, id_us_clear_real(), LIB_FAKEUSER, LIB_INDIRECT_WEAK_LINK, LIB_TAG_EXTERN, LIB_TAG_INDIRECT, NULL, ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::status, ID::tag, and user_data.
Referenced by libblock_remap_data().
Definition at line 527 of file lib_remap.c.
References BKE_libblock_runtime_reset_remapping_status(), BKE_main_lock(), BKE_main_unlock(), BLI_assert, CLOG_ERROR, data, DEG_relations_tag_update(), ListBase::first, free_notifier_reference_cb, GS, ID_CU_LEGACY, ID_CV, ID_GR, ID_MB, ID_ME, ID_OB, ID_PT, ID_REMAP_IS_USER_ONE_SKIPPED, ID_REMAP_SKIP_USER_CLEAR, id_us_clear_real(), ID_VO, ID::lib, LIB_TAG_EXTERN, LIB_TAG_EXTRAUSER_SET, LIB_TAG_INDIRECT, libblock_remap_data_postprocess_collection_update(), libblock_remap_data_postprocess_nodetree_update(), libblock_remap_data_postprocess_obdata_relink(), libblock_remap_data_postprocess_object_update(), LOG, ID::name, NULL, Main::objects, ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::skipped_direct, ID_Runtime_Remap::skipped_refcounted, ID_Runtime_Remap::status, ID::tag, ID::us, and user_data.
Referenced by BKE_libblock_remap_multiple_locked().
|
static |
Definition at line 430 of file lib_remap.c.
References BKE_libblock_runtime_reset_remapping_status(), and NULL.
Referenced by libblock_remap_data().
BKE_library_free_notifier_reference_cb free_notifier_reference_cb = NULL |
Definition at line 39 of file lib_remap.c.
Referenced by BKE_id_free_ex(), BKE_library_callback_free_notifier_reference_set(), and libblock_remap_foreach_idpair_cb().
|
static |
Definition at line 37 of file lib_remap.c.
Referenced by libblock_remap_foreach_idpair_cb().
BKE_library_remap_editor_id_reference_cb remap_editor_id_reference_cb = NULL |
Definition at line 46 of file lib_remap.c.
Referenced by BKE_id_free_ex(), BKE_libblock_remap_multiple_locked(), and BKE_library_callback_remap_editor_id_reference_set().