Core: Fix broken CustomData IO with Autosave files #106648
|
@ -4217,6 +4217,16 @@ void CustomData_blend_write_prepare(CustomData &data,
|
|||
}
|
||||
data.totlayer = layers_to_write.size();
|
||||
data.maxlayer = data.totlayer;
|
||||
|
||||
/* Note: data->layers may be null, this happens when adding
|
||||
* a legacy MPoly struct to a mesh with no other face attributes.
|
||||
* This leaves us with no unique ID for DNA to identify the old
|
||||
|
||||
* data with when loading the file.
|
||||
*/
|
||||
if (!data.layers && layers_to_write.size() > 0) {
|
||||
/* We just need an address that's unique. */
|
||||
data.layers = reinterpret_cast<CustomDataLayer *>(&data.layers);
|
||||
Hans Goudey
commented
Would using No strong opinion since this is a bit hacky anyway, but it would look less suspect anyway. Would using `layers_to_write.data()` here be a little less "weird"?
No strong opinion since this is a bit hacky anyway, but it would look less suspect anyway.
Joseph Eagar
commented
There's no guarantee it will always be unique. There's no guarantee it will always be unique.
Hans Goudey
commented
Ah right, this is the best way to get an actually unique pointer I guess. Ah right, this is the best way to get an actually unique pointer I guess.
|
||||
}
|
||||
}
|
||||
|
||||
int CustomData_sizeof(const eCustomDataType type)
|
||||
|
|
|
@ -1240,7 +1240,7 @@ void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh)
|
|||
using namespace blender;
|
||||
using namespace blender::bke;
|
||||
MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
||||
if (attributes.contains("sharp_face")) {
|
||||
if (attributes.contains("sharp_face") || !CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
|
||||
return;
|
||||
}
|
||||
const Span<MPoly> polys(static_cast<const MPoly *>(CustomData_get_layer(&mesh->pdata, CD_MPOLY)),
|
||||
Hans Goudey
commented
Unnecessary white-space change here Unnecessary white-space change here
|
||||
|
|
Loading…
Reference in New Issue
I wonder if there's a more specific wording than "key off of". What about something like "identify the old data with"?
I think my lack of understanding here is the key part of the problem.