Fix: Write hide status attributes for undo steps

We don't convert to the old mesh format when writing undo steps to
avoid overhead. So we can't skip writing the hide attributes then.
This commit is contained in:
Hans Goudey 2022-08-23 13:50:47 -04:00
parent 35c601269b
commit e36ced1dce
3 changed files with 10 additions and 6 deletions

View File

@ -718,7 +718,7 @@ void CustomData_data_transfer(const struct MeshPairRemap *me_remap,
*/
void CustomData_blend_write_prepare(CustomData &data,
blender::Vector<CustomDataLayer, 16> &layers_to_write,
const blender::Set<blender::StringRef> &skip_names = {});
const blender::Set<std::string> &skip_names = {});
/**
* \param layers_to_write: Layers created by #CustomData_blend_write_prepare.

View File

@ -4355,7 +4355,7 @@ void CustomData_file_write_info(int type, const char **r_struct_name, int *r_str
void CustomData_blend_write_prepare(CustomData &data,
Vector<CustomDataLayer, 16> &layers_to_write,
const Set<StringRef> &skip_names)
const Set<std::string> &skip_names)
{
for (const CustomDataLayer &layer : Span(data.layers, data.totlayer)) {
if (layer.flag & CD_FLAG_NOCOPY) {

View File

@ -212,6 +212,7 @@ static void mesh_foreach_path(ID *id, BPathForeachPathData *bpath_data)
static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
using namespace blender;
Mesh *mesh = (Mesh *)id;
const bool is_undo = BLO_write_is_undo(writer);
@ -245,14 +246,17 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
memset(&mesh->pdata, 0, sizeof(mesh->pdata));
}
else {
Set<std::string> names_to_skip;
if (!BLO_write_is_undo(writer)) {
BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
/* When converting to the old mesh format, don't save redunant attributes. */
names_to_skip.add_multiple_new({".hide_vert", ".hide_edge", ".hide_poly"});
}
CustomData_blend_write_prepare(mesh->vdata, vert_layers, {".hide_vert"});
CustomData_blend_write_prepare(mesh->edata, edge_layers, {".hide_edge"});
CustomData_blend_write_prepare(mesh->ldata, loop_layers);
CustomData_blend_write_prepare(mesh->pdata, poly_layers, {".hide_poly"});
CustomData_blend_write_prepare(mesh->vdata, vert_layers, names_to_skip);
CustomData_blend_write_prepare(mesh->edata, edge_layers, names_to_skip);
CustomData_blend_write_prepare(mesh->ldata, loop_layers, names_to_skip);
CustomData_blend_write_prepare(mesh->pdata, poly_layers, names_to_skip);
}
BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);