|
Blender V4.3
|
#include "CLG_log.h"#include "BLI_array.hh"#include "BLI_linklist.h"#include "BLI_utildefines.h"#include "DNA_collection_types.h"#include "DNA_object_types.h"#include "BKE_armature.hh"#include "BKE_collection.hh"#include "BKE_curve.hh"#include "BKE_layer.hh"#include "BKE_lib_id.hh"#include "BKE_lib_query.hh"#include "BKE_lib_remap.hh"#include "BKE_main.hh"#include "BKE_material.h"#include "BKE_mball.hh"#include "BKE_modifier.hh"#include "BKE_multires.hh"#include "BKE_node.hh"#include "BKE_node_tree_update.hh"#include "BKE_object.hh"#include "DEG_depsgraph.hh"#include "DEG_depsgraph_build.hh"#include "lib_intern.hh"Go to the source code of this file.
Classes | |
| struct | IDRemap |
| struct | 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 *, ID **id_ptr, const int cb_flag, const bool is_indirect, const bool is_reference, const bool violates_never_null, const bool, 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 IDRemapper &mappings, const IDRemapperApplyOptions id_remapper_options, const int cb_flag, const bool is_indirect, const bool violates_never_null) |
| static int | foreach_libblock_remap_callback (LibraryIDLinkCallbackData *cb_data) |
| static void | libblock_remap_data_preprocess_ob (Object *ob, eIDRemapType remap_type, const IDRemapper &id_remapper) |
| static void | libblock_remap_data_preprocess (ID *id_owner, eIDRemapType remap_type, const IDRemapper &id_remapper) |
| static void | libblock_remap_data_postprocess_object_update (Main *bmain, Object *old_ob, Object *, const bool do_sync_collection) |
| static void | libblock_remap_data_postprocess_collection_update (Main *bmain, Collection *owner_collection, 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, IDRemap *id_remap_data) |
| static void | libblock_remap_reset_remapping_status_fn (ID *old_id, ID *new_id) |
| static void | libblock_remap_data (Main *bmain, ID *id, eIDRemapType remap_type, IDRemapper &id_remapper, const int remap_flags) |
| static void | libblock_remap_foreach_idpair (ID *old_id, ID *new_id, Main *bmain, int remap_flags) |
| void | BKE_libblock_remap_multiple_locked (Main *bmain, IDRemapper &mappings, const int remap_flags) |
| void | BKE_libblock_remap_multiple_raw (Main *bmain, IDRemapper &mappings, const int remap_flags) |
| void | BKE_libblock_remap_locked (Main *bmain, void *old_idv, void *new_idv, const int remap_flags) |
| void | BKE_libblock_remap (Main *bmain, void *old_idv, void *new_idv, const int remap_flags) |
| void | BKE_libblock_remap_multiple (Main *bmain, IDRemapper &mappings, const int remap_flags) |
| void | BKE_libblock_unlink (Main *bmain, void *idv, const bool do_skip_indirect) |
| static void | libblock_relink_foreach_idpair (ID *old_id, ID *new_id, Main *bmain, const blender::Span< ID * > ids) |
| void | BKE_libblock_relink_multiple (Main *bmain, const blender::Span< ID * > ids, const eIDRemapType remap_type, IDRemapper &id_remapper, const int remap_flags) |
| void | BKE_libblock_relink_ex (Main *bmain, void *idv, void *old_idv, void *new_idv, const int 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 = {"bke.lib_remap"} |
| BKE_library_free_notifier_reference_cb | free_notifier_reference_cb = nullptr |
| BKE_library_remap_editor_id_reference_cb | remap_editor_id_reference_cb = nullptr |
Contains management of ID's for remapping.
Definition in file lib_remap.cc.
| void BKE_libblock_relink_ex | ( | Main * | bmain, |
| void * | idv, | ||
| void * | old_idv, | ||
| void * | new_idv, | ||
| int | remap_flags ) |
Similar to libblock_remap, but only affects IDs used by given idv ID.
| old_idv | Unlike BKE_libblock_remap, can be NULL, in which case all ID usages by given idv will be cleared. |
| bmain | May be NULL, in which case there won't be depsgraph updates nor post-processing on some ID types (like collections or objects) to ensure their runtime data is valid. |
Definition at line 844 of file lib_remap.cc.
References blender::bke::id::IDRemapper::add(), BKE_libblock_relink_multiple(), BLI_assert, GS, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, ID::name, and UNUSED_VARS_NDEBUG.
Referenced by BKE_lib_override_library_create_from_id(), id_free(), and scene_copy_data().
| void BKE_libblock_relink_multiple | ( | Main * | bmain, |
| const blender::Span< ID * > | ids, | ||
| eIDRemapType | remap_type, | ||
| blender::bke::id::IDRemapper & | id_remapper, | ||
| int | 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 782 of file lib_remap.cc.
References BLI_assert, BLI_assert_unreachable, DEG_relations_tag_update(), GS, ID_GR, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, ID_SCE, blender::bke::id::IDRemapper::is_empty(), blender::bke::id::IDRemapper::iter(), libblock_relink_foreach_idpair(), libblock_remap_data(), libblock_remap_data_postprocess_collection_update(), and libblock_remap_data_postprocess_object_update().
Referenced by BKE_lib_override_library_create_from_tag(), BKE_libblock_relink_ex(), BKE_libblock_relink_to_newid(), BKE_main_merge(), id_delete(), id_swap(), 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 ID_TAG_NEW.
ID_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 921 of file lib_remap.cc.
References BKE_libblock_relink_multiple(), BLI_assert, ID_IS_LINKED, ID_REMAP_SKIP_INDIRECT_USAGE, ID_REMAP_SKIP_OVERRIDE_LIBRARY, ID_REMAP_TYPE_REMAP, libblock_relink_to_newid_prepare_data(), and Main::relations.
Referenced by blender::ed::object::add_duplicate(), BKE_blendfile_append(), BKE_collection_duplicate(), BKE_object_duplicate(), BKE_scene_duplicate(), blender::ed::object::copy_object_set_idnew(), blender::ed::object::libblock_relink_collection(), blender::ed::object::make_object_duplilist_real(), and blender::ed::object::single_object_users().
Definition at line 692 of file lib_remap.cc.
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 int | remap_flags ) |
Definition at line 683 of file lib_remap.cc.
References blender::bke::id::IDRemapper::add(), and BKE_libblock_remap_multiple_locked().
Referenced by BKE_libblock_remap(), and BKE_libblock_unlink().
| void BKE_libblock_remap_multiple | ( | Main * | bmain, |
| IDRemapper & | mappings, | ||
| const int | remap_flags ) |
Definition at line 701 of file lib_remap.cc.
References BKE_libblock_remap_multiple_locked(), BKE_main_lock(), and BKE_main_unlock().
Referenced by blender::bke::greasepencil::convert::legacy_main(), and lib_override_library_remap().
| void BKE_libblock_remap_multiple_locked | ( | Main * | bmain, |
| blender::bke::id::IDRemapper & | mappings, | ||
| const int | remap_flags ) |
Replace all references in given Main using the given mappings
Definition at line 645 of file lib_remap.cc.
References DEG_relations_tag_update(), ID_REMAP_TYPE_REMAP, blender::bke::id::IDRemapper::is_empty(), blender::bke::id::IDRemapper::iter(), libblock_remap_data(), libblock_remap_foreach_idpair(), and remap_editor_id_reference_cb.
Referenced by BKE_libblock_remap_locked(), BKE_libblock_remap_multiple(), id_delete(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().
| void BKE_libblock_remap_multiple_raw | ( | Main * | bmain, |
| blender::bke::id::IDRemapper & | mappings, | ||
| const int | remap_flags ) |
Bare raw remapping of IDs, with no other processing than actually updating the ID pointers. No user-count, direct vs indirect linked status update, depsgraph tagging, etc.
This is way more efficient than regular remapping from BKE_libblock_remap_multiple & co, but it implies that calling code handles all the other aspects described above. This is typically the case e.g. in read-file process.
WARNING: This call will likely leave the given BMain in invalid state in many aspects.
Definition at line 669 of file lib_remap.cc.
References ID_REMAP_SKIP_UPDATE_TAGGING, ID_REMAP_SKIP_USER_REFCOUNT, ID_REMAP_TYPE_REMAP, blender::bke::id::IDRemapper::is_empty(), and libblock_remap_data().
Referenced by blender::bke::asset_main_create_from_ID(), and setup_app_data().
| void BKE_libblock_unlink | ( | Main * | bmain, |
| void * | idv, | ||
| bool | do_skip_indirect ) |
Unlink given id from given bmain (does not touch to indirect, i.e. library, usages of the ID).
Definition at line 710 of file lib_remap.cc.
References BKE_libblock_remap_locked(), BKE_main_lock(), BKE_main_unlock(), and ID_REMAP_SKIP_INDIRECT_USAGE.
Referenced by BKE_id_free_us().
| void BKE_library_callback_free_notifier_reference_set | ( | BKE_library_free_notifier_reference_cb | func | ) |
Definition at line 47 of file lib_remap.cc.
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 54 of file lib_remap.cc.
References remap_editor_id_reference_cb.
Referenced by WM_init().
|
static |
Definition at line 174 of file lib_remap.cc.
References blender::bke::id::IDRemapper::add(), BKE_object_is_in_editmode(), BLI_assert, BLI_assert_msg, blender::StringRefNull::c_str(), LibraryIDLinkCallbackData::cb_flag, blender::bke::id::IDRemapper::clear(), ELEM, ID::flag, IDRemap::flag, foreach_libblock_remap_callback_apply(), foreach_libblock_remap_callback_skip(), blender::bke::id::IDRemapper::get_mapping_result(), GS, ID_FLAG_EMBEDDED_DATA, ID_OB, IDRemap::id_owner, LibraryIDLinkCallbackData::id_pointer, ID_REMAP_APPLY_DEFAULT, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, ID_REMAP_FORCE_NEVER_NULL_USAGE, ID_REMAP_FORCE_OBDATA_IN_EDITMODE, 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_STORE_NEVER_NULL_USAGE, ID_REMAP_TYPE_CLEANUP, ID_REMAP_TYPE_REMAP, IDRemap::id_remapper, 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, ID::name, blender::bke::id::IDRemapper::never_null_users_add(), LibraryIDLinkCallbackData::owner_id, printf, blender::bke::id::IDRemapper::result_to_string(), LibraryIDLinkCallbackData::self_id, IDRemap::type, and LibraryIDLinkCallbackData::user_data.
Referenced by libblock_remap_data().
|
static |
Definition at line 104 of file lib_remap.cc.
References blender::bke::id::IDRemapper::apply(), BKE_ntree_update_tag_all(), BLI_assert, IDRemap::bmain, DEG_id_tag_update_ex(), IDRemap::flag, GS, ID_NT, ID_RECALC_GEOMETRY, ID_RECALC_SYNC_TO_EVAL, ID_RECALC_TRANSFORM, ID_REMAP_FORCE_USER_REFCOUNT, ID_REMAP_IS_LINKED_DIRECT, ID_REMAP_SKIP_UPDATE_TAGGING, ID_REMAP_SKIP_USER_REFCOUNT, ID_TAG_NO_MAIN, id_us_ensure_real(), id_us_min(), id_us_plus_no_lib(), IDWALK_CB_USER, IDWALK_CB_USER_ONE, ID::name, ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::status, and ID::tag.
Referenced by foreach_libblock_remap_callback().
|
static |
Definition at line 73 of file lib_remap.cc.
References BLI_assert, BLI_assert_unreachable, ID_REMAP_IS_USER_ONE_SKIPPED, IDWALK_CB_USER, and IDWALK_CB_USER_ONE.
Referenced by foreach_libblock_remap_callback().
|
static |
Definition at line 882 of file lib_remap.cc.
References blender::bke::id::IDRemapper::add(), LibraryIDLinkCallbackData::bmain, LibraryIDLinkCallbackData::cb_flag, LibraryIDLinkCallbackData::id_pointer, RelinkToNewIDData::id_remapper, ID_TAG_NEW, IDWALK_CB_EMBEDDED, IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE, IDWALK_RET_NOP, libblock_relink_to_newid_prepare_data(), and LibraryIDLinkCallbackData::user_data.
Referenced by libblock_relink_to_newid_prepare_data().
|
static |
Definition at line 729 of file lib_remap.cc.
References BLI_assert, 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(), and ID::name.
Referenced by BKE_libblock_relink_multiple().
|
static |
Definition at line 908 of file lib_remap.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BKE_library_foreach_ID_link(), ID_IS_LINKED, id_relink_to_newid_looper(), and RelinkToNewIDData::ids.
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 nullptr or not:
| bmain | the Main data storage to operate on (may be nullptr, in which case part of the post-process/depsgraph update won't happen). |
| id | the data-block to operate on (can be nullptr, in which case we operate over all IDs from given bmain). |
| old_id | the data-block to dereference (may be nullptr if id is non-nullptr). |
| new_id | the new data-block to replace old_id references with (may be nullptr). |
| r_id_remap_data | if non-nullptr, the IDRemap struct to use (useful to retrieve info about remapping process). |
Definition at line 487 of file lib_remap.cc.
References BKE_id_owner_get(), BKE_library_foreach_ID_link(), BKE_library_id_can_use_filter_id(), blender::bke::id::IDRemapper::contains_mappings_for_any(), foreach_libblock_remap_callback(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, ID_FLAG_EMBEDDED_DATA, IDRemap::id_owner, ID_REMAP_DO_LIBRARY_POINTERS, ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS, ID_REMAP_FORCE_UI_POINTERS, ID_REMAP_NO_ORIG_POINTERS_ACCESS, IDWALK_DO_INTERNAL_RUNTIME_POINTERS, IDWALK_DO_LIBRARY_POINTER, IDWALK_INCLUDE_UI, IDWALK_NO_ORIG_POINTERS_ACCESS, IDWALK_NOP, blender::bke::id::IDRemapper::iter(), libblock_remap_data_preprocess(), libblock_remap_data_update_tags(), libblock_remap_reset_remapping_status_fn(), and printf.
Referenced by BKE_libblock_relink_multiple(), BKE_libblock_remap_multiple_locked(), and BKE_libblock_remap_multiple_raw().
|
static |
Definition at line 386 of file lib_remap.cc.
References BKE_collections_child_remove_nulls(), BKE_main_collection_sync_remap(), and BKE_main_collections_parent_relations_rebuild().
Referenced by BKE_libblock_relink_multiple(), libblock_relink_foreach_idpair(), and libblock_remap_foreach_idpair().
Definition at line 426 of file lib_remap.cc.
References blender::bke::node_tree_update_all_users().
Referenced by libblock_remap_foreach_idpair().
|
static |
Definition at line 408 of file lib_remap.cc.
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(), and libblock_remap_foreach_idpair().
|
static |
Can be called with both old_ob and new_ob being nullptr, this means we have to check whole Main database then.
Definition at line 350 of file lib_remap.cc.
References BKE_collections_object_remove_invalids(), BKE_main_collection_sync_remap(), BKE_mball_is_basis(), BKE_mball_is_basis_for(), DEG_id_tag_update(), ListBase::first, ID_RECALC_GEOMETRY, OB_MBALL, and Main::objects.
Referenced by BKE_libblock_relink_multiple(), libblock_relink_foreach_idpair(), and libblock_remap_foreach_idpair().
|
static |
Definition at line 331 of file lib_remap.cc.
References GS, ID_OB, libblock_remap_data_preprocess_ob(), and ID::name.
Referenced by libblock_remap_data().
|
static |
Definition at line 298 of file lib_remap.cc.
References BKE_pose_clear_pointers(), blender::bke::id::IDRemapper::contains_mappings_for_any(), Object::data, FILTER_ID_AR, bPose::flag, blender::bke::id::IDRemapper::get_mapping_result(), ID_REMAP_APPLY_DEFAULT, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_TYPE_CLEANUP, OB_ARMATURE, Object::pose, POSE_RECALC, and Object::type.
Referenced by libblock_remap_data_preprocess().
|
static |
Definition at line 432 of file lib_remap.cc.
References ID::flag, IDRemap::flag, id_fake_user_clear(), id_fake_user_set(), ID_FLAG_FAKEUSER, ID_REMAP_IS_LINKED_DIRECT, ID_REMAP_SKIP_USER_CLEAR, ID_TAG_EXTERN, ID_TAG_INDIRECT, id_us_clear_real(), ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::status, and ID::tag.
Referenced by libblock_remap_data().
|
static |
Definition at line 555 of file lib_remap.cc.
References BKE_libblock_runtime_reset_remapping_status(), BKE_main_lock(), BKE_main_unlock(), BLI_assert, CLOG_ERROR, 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_ALLOW_IDTYPE_MISMATCH, ID_REMAP_IS_USER_ONE_SKIPPED, ID_REMAP_SKIP_USER_CLEAR, ID_TAG_EXTERN, ID_TAG_EXTRAUSER_SET, ID_TAG_INDIRECT, id_us_clear_real(), ID_VO, ID::lib, 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, Main::objects, ID_Runtime::remap, ID::runtime, ID_Runtime_Remap::skipped_direct, ID_Runtime_Remap::skipped_refcounted, ID_Runtime_Remap::status, ID::tag, and ID::us.
Referenced by BKE_libblock_remap_multiple_locked().
Definition at line 456 of file lib_remap.cc.
References BKE_libblock_runtime_reset_remapping_status().
Referenced by libblock_remap_data().
| BKE_library_free_notifier_reference_cb free_notifier_reference_cb = nullptr |
Definition at line 45 of file lib_remap.cc.
Referenced by BKE_library_callback_free_notifier_reference_set(), id_free(), and libblock_remap_foreach_idpair().
|
static |
Definition at line 43 of file lib_remap.cc.
Referenced by libblock_remap_foreach_idpair().
| BKE_library_remap_editor_id_reference_cb remap_editor_id_reference_cb = nullptr |
Definition at line 52 of file lib_remap.cc.
Referenced by BKE_libblock_remap_multiple_locked(), BKE_library_callback_remap_editor_id_reference_set(), and id_free().