Merge branch 'blender-v4.0-release' into main
This commit is contained in:
@@ -284,10 +284,14 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root);
|
||||
/**
|
||||
* Make given ID fully local.
|
||||
*
|
||||
* \param bmain If given, all liboverrides hierarchy roots will be re-validated/generated after
|
||||
* clearing the liboverride data from given \a id. If nullptr, caller is responsible to perform
|
||||
* this action (call #BKE_lib_override_library_main_hierarchy_root_ensure) itself.
|
||||
*
|
||||
* \note Only differs from lower-level #BKE_lib_override_library_free in infamous embedded ID
|
||||
* cases.
|
||||
*/
|
||||
void BKE_lib_override_library_make_local(ID *id);
|
||||
void BKE_lib_override_library_make_local(Main *bmain, ID *id);
|
||||
|
||||
/**
|
||||
* Find override property from given RNA path, if it exists.
|
||||
|
||||
@@ -506,7 +506,7 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
|
||||
if (force_local) {
|
||||
BKE_lib_id_clear_library_data(bmain, id, flags);
|
||||
if ((flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0) {
|
||||
BKE_lib_override_library_make_local(id);
|
||||
BKE_lib_override_library_make_local(bmain, id);
|
||||
}
|
||||
BKE_lib_id_expand_local(bmain, id, flags);
|
||||
}
|
||||
@@ -1826,7 +1826,9 @@ void BKE_library_make_local(Main *bmain,
|
||||
ELEM(lib, nullptr, id->override_library->reference->lib) &&
|
||||
((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING)))
|
||||
{
|
||||
BKE_lib_override_library_make_local(id);
|
||||
/* Validating liboverride hierarchy root pointers will happen later in this function,
|
||||
* rather than doing it for each and every localized ID. */
|
||||
BKE_lib_override_library_make_local(nullptr, id);
|
||||
}
|
||||
}
|
||||
/* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data
|
||||
@@ -1966,6 +1968,10 @@ void BKE_library_make_local(Main *bmain,
|
||||
}
|
||||
}
|
||||
|
||||
/* Making some liboverride local may have had some impact on validity of liboverrides hierarchy
|
||||
* roots, these need to be re-validated/re-generated. */
|
||||
BKE_lib_override_library_main_hierarchy_root_ensure(bmain);
|
||||
|
||||
#ifdef DEBUG_TIME
|
||||
printf("Step 4: Remap local usages of old (linked) ID to new (local) ID: Done.\n");
|
||||
TIMEIT_VALUE_PRINT(make_local);
|
||||
|
||||
@@ -1573,9 +1573,15 @@ static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int
|
||||
BKE_lib_override_library_get(bmain, id, nullptr, &id_owner);
|
||||
return lib_override_root_find(bmain, id_owner, curr_level + 1, &best_level_placeholder);
|
||||
}
|
||||
/* This way we won't process again that ID, should we encounter it again through another
|
||||
* relationship hierarchy. */
|
||||
entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
|
||||
|
||||
if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS) {
|
||||
/* Re-processing an entry already being processed higher in the callgraph (re-entry caused by a
|
||||
* dependency loops). Just do nothing, there is no more usefull info to provide here. */
|
||||
return nullptr;
|
||||
}
|
||||
/* Flag this entry to avoid re-processing it in case some dependency loop leads to it again
|
||||
* downwards in the callstack. */
|
||||
entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS;
|
||||
|
||||
int best_level_candidate = curr_level;
|
||||
ID *best_root_id_candidate = id;
|
||||
@@ -1618,6 +1624,11 @@ static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int
|
||||
BLI_assert(best_root_id_candidate != nullptr);
|
||||
BLI_assert((best_root_id_candidate->flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE) == 0);
|
||||
|
||||
/* This way this ID won't be processed again, should it be encountered again through another
|
||||
* relationship hierarchy. */
|
||||
entry->tags &= ~MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS;
|
||||
entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
|
||||
|
||||
*r_best_level = best_level_candidate;
|
||||
return best_root_id_candidate;
|
||||
}
|
||||
@@ -1663,7 +1674,10 @@ static void lib_override_root_hierarchy_set(
|
||||
bmain->relations->relations_from_pointers, id->override_library->reference));
|
||||
BLI_assert(entry != nullptr);
|
||||
|
||||
bool do_replace_root = false;
|
||||
/* Enforce replacing hierarchy root if the current one is invalid. */
|
||||
bool do_replace_root = (!id->override_library->hierarchy_root ||
|
||||
!ID_IS_OVERRIDE_LIBRARY_REAL(id->override_library->hierarchy_root) ||
|
||||
id->override_library->hierarchy_root->lib != id->lib);
|
||||
for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != nullptr;
|
||||
from_id_entry = from_id_entry->next)
|
||||
{
|
||||
@@ -1770,6 +1784,7 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
|
||||
}
|
||||
|
||||
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
|
||||
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS, false);
|
||||
|
||||
int best_level = 0;
|
||||
ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level);
|
||||
@@ -3572,7 +3587,7 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
|
||||
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
|
||||
}
|
||||
|
||||
void BKE_lib_override_library_make_local(ID *id)
|
||||
void BKE_lib_override_library_make_local(Main *bmain, ID *id)
|
||||
{
|
||||
if (!ID_IS_OVERRIDE_LIBRARY(id)) {
|
||||
return;
|
||||
@@ -3602,6 +3617,10 @@ void BKE_lib_override_library_make_local(ID *id)
|
||||
if (node_tree != nullptr) {
|
||||
node_tree->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
|
||||
}
|
||||
|
||||
/* In case a liboverride hierarchy root is 'made local', i.e. is not a liboverride anymore, all
|
||||
* hierarchy roots of all liboverrides need to be validated/re-generated again. */
|
||||
BKE_lib_override_library_main_hierarchy_root_ensure(bmain);
|
||||
}
|
||||
|
||||
/* We only build override GHash on request. */
|
||||
|
||||
@@ -2340,7 +2340,7 @@ int BLI_bvhtree_find_nearest_projected(const BVHTree *tree,
|
||||
BVHNode *root = tree->nodes[tree->leaf_num];
|
||||
if (root != NULL) {
|
||||
BVHNearestProjectedData *data = (BVHNearestProjectedData *)alloca(
|
||||
sizeof(*data) + (sizeof(*clip_plane) * max_ii(1, clip_plane_len)));
|
||||
sizeof(*data) + (sizeof(*clip_plane) * (size_t)max_ii(1, clip_plane_len)));
|
||||
|
||||
dist_squared_to_projected_aabb_precalc(&data->precalc, projmat, winsize, mval);
|
||||
|
||||
|
||||
@@ -1017,7 +1017,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
|
||||
template_id_liboverride_hierarchy_make(C, bmain, template_ui, &idptr, &undo_push_label);
|
||||
}
|
||||
else {
|
||||
BKE_lib_override_library_make_local(id);
|
||||
BKE_lib_override_library_make_local(bmain, id);
|
||||
/* Reassign to get proper updates/notifiers. */
|
||||
idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
|
||||
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr);
|
||||
|
||||
@@ -1002,7 +1002,7 @@ static void id_local_fn(bContext *C,
|
||||
}
|
||||
}
|
||||
else if (ID_IS_OVERRIDE_LIBRARY_REAL(tselem->id)) {
|
||||
BKE_lib_override_library_make_local(tselem->id);
|
||||
BKE_lib_override_library_make_local(CTX_data_main(C), tselem->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1095,7 +1095,7 @@ static ID *rna_ID_make_local(ID *self, Main *bmain, bool /*clear_proxy*/)
|
||||
BKE_lib_id_make_local(bmain, self, 0);
|
||||
}
|
||||
else if (ID_IS_OVERRIDE_LIBRARY_REAL(self)) {
|
||||
BKE_lib_override_library_make_local(self);
|
||||
BKE_lib_override_library_make_local(bmain, self);
|
||||
}
|
||||
|
||||
ID *ret_id = self->newid ? self->newid : self;
|
||||
|
||||
Reference in New Issue
Block a user