Fix #119455: Auto smooth versioning on append applies to existing IDs
When appending objects from an older file, versioning needs to run to add an auto smooth modifier if necessary. However, this was running for all objects rather than just the newly appended objects. It's quite wrong to modify existing objects here, so add an explicit check for that. This could improve performance as well, but skipping checks for objects when the work is unnecessary. The crash will hopefully be resolved by other improvements to the auto smooth versioning (making it properly idempotent and running it again should fix the problem with the hidden legacy flags still set). But I still think this PR is worth committing, to be very explicit about only modifying new objects in versioning code. Pull Request: https://projects.blender.org/blender/blender/pulls/119467
This commit is contained in:
parent
682f984dbe
commit
c6497dd9f7
@ -114,7 +114,7 @@ void BKE_mesh_calc_edges_legacy(Mesh *mesh);
|
||||
|
||||
void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh);
|
||||
|
||||
void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain);
|
||||
void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain, bool new_ids_only = false);
|
||||
|
||||
/**
|
||||
* Calculate/create edges from tessface data
|
||||
|
@ -1375,10 +1375,10 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
|
||||
instantiate_context.active_collection = nullptr;
|
||||
loose_data_instantiate(&instantiate_context);
|
||||
|
||||
BKE_main_mesh_legacy_convert_auto_smooth(*bmain, true);
|
||||
BKE_main_id_newptr_and_tag_clear(bmain);
|
||||
|
||||
blendfile_link_append_proxies_convert(bmain, reports);
|
||||
BKE_main_mesh_legacy_convert_auto_smooth(*bmain);
|
||||
}
|
||||
|
||||
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
|
||||
|
@ -2263,7 +2263,7 @@ static ModifierData *create_auto_smooth_modifier(Object &object,
|
||||
|
||||
} // namespace blender::bke
|
||||
|
||||
void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
|
||||
void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain, const bool new_ids_only)
|
||||
{
|
||||
using namespace blender::bke;
|
||||
|
||||
@ -2279,6 +2279,9 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
|
||||
if (object->type != OB_MESH) {
|
||||
continue;
|
||||
}
|
||||
if (new_ids_only && (object->id.tag & LIB_TAG_NEW) == 0) {
|
||||
continue;
|
||||
}
|
||||
Mesh *mesh = static_cast<Mesh *>(object->data);
|
||||
const float angle = mesh->smoothresh_legacy;
|
||||
if (!(mesh->flag & ME_AUTOSMOOTH_LEGACY)) {
|
||||
|
Loading…
Reference in New Issue
Block a user