Core: Fix broken CustomData IO with Autosave files #106648
|
@ -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)),
|
||||
|
||||
|
|
|
@ -34,22 +34,6 @@ using blender::OffsetIndices;
|
|||
|
||||
static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
|
||||
{
|
||||
/* Autosave files don't have CD_MPOLY layers.
|
||||
*/
|
||||
if (!CustomData_has_layer(&mesh.pdata, CD_MPOLY) && mesh.poly_offset_indices) {
|
||||
MPoly *polys_legacy = static_cast<MPoly *>(
|
||||
CustomData_add_layer(&mesh.pdata, CD_MPOLY, CD_CONSTRUCT, mesh.totpoly));
|
||||
|
||||
/* Getting a link error when using mesh.polys(),
|
||||
* for now just read poly_offset_indices directly.
|
||||
*/
|
||||
for (int poly_i : IndexRange(mesh.totpoly)) {
|
||||
polys_legacy[poly_i].loopstart = mesh.poly_offset_indices[poly_i];
|
||||
polys_legacy[poly_i].totloop = mesh.poly_offset_indices[poly_i + 1] -
|
||||
mesh.poly_offset_indices[poly_i];
|
||||
}
|
||||
}
|
||||
|
||||
BKE_mesh_legacy_convert_flags_to_selection_layers(&mesh);
|
||||
BKE_mesh_legacy_convert_flags_to_hide_layers(&mesh);
|
||||
BKE_mesh_legacy_convert_uvs_to_generic(&mesh);
|
||||
Hans Goudey
commented
It shouldn't be necessary to add this at runtime, since we don't use the polys at all. We're meant to be able to read the new (not legacy format) too already. Is this preventing another crash in some of the functions below? It shouldn't be necessary to add this at runtime, since we don't use the polys at all. We're meant to be able to read the new (not legacy format) too already. Is this preventing another crash in some of the functions below?
Joseph Eagar
commented
A fair number of the conversion functions are using MPolys (it crashes in the sharp face one). A fair number of the conversion functions are using MPolys (it crashes in the sharp face one).
|
||||
|
|
Loading…
Reference in New Issue
Unnecessary white-space change here