[Bf-blender-cvs] [e36ced1dce9] master: Fix: Write hide status attributes for undo steps

Hans Goudey noreply at git.blender.org
Tue Aug 23 19:51:00 CEST 2022


Commit: e36ced1dce96f980fd844181946b3318fcc6233c
Author: Hans Goudey
Date:   Tue Aug 23 13:50:47 2022 -0400
Branches: master
https://developer.blender.org/rBe36ced1dce96f980fd844181946b3318fcc6233c

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.

===================================================================

M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/intern/customdata.cc
M	source/blender/blenkernel/intern/mesh.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 2ced685884b..6461ff30cd6 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -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.
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 69825031795..90bc79f6907 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -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) {
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 1b8d094e9d3..7f2c09f049b 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -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);



More information about the Bf-blender-cvs mailing list