[Bf-blender-cvs] [86e2584d2a1] refactor-mesh-remove-pointers: Fix forward compatibility by writing pointers to custom data arrays

Hans Goudey noreply at git.blender.org
Fri Sep 2 01:12:17 CEST 2022


Commit: 86e2584d2a1bad7d2a04b50a4533a19755ccf7f2
Author: Hans Goudey
Date:   Thu Sep 1 18:00:44 2022 -0500
Branches: refactor-mesh-remove-pointers
https://developer.blender.org/rB86e2584d2a1bad7d2a04b50a4533a19755ccf7f2

Fix forward compatibility by writing pointers to custom data arrays

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

M	source/blender/blenkernel/intern/mesh.cc
M	source/blender/makesdna/DNA_mesh_types.h

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

diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index d9fa6c6d4e9..c0379c50de4 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -248,10 +248,17 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
   else {
     Set<std::string> names_to_skip;
     if (!BLO_write_is_undo(writer)) {
+
       BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
       BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh);
       /* When converting to the old mesh format, don't save redundant attributes. */
       names_to_skip.add_multiple_new({".hide_vert", ".hide_edge", ".hide_poly"});
+
+      /* Set deprecated mesh data pointers for forward compatibility. */
+      mesh->mvert = const_cast<MVert *>(mesh->vertices().data());
+      mesh->medge = const_cast<MEdge *>(mesh->edges().data());
+      mesh->mpoly = const_cast<MPoly *>(mesh->polygons().data());
+      mesh->mloop = const_cast<MLoop *>(mesh->loops().data());
     }
 
     CustomData_blend_write_prepare(mesh->vdata, vert_layers, names_to_skip);
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index cfa9425bc3d..c41d028c01b 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -272,6 +272,11 @@ typedef struct Mesh {
   char subdivr DNA_DEPRECATED;
   char subsurftype DNA_DEPRECATED;
 
+  /** Deprecated pointer to mesh polygons, kept for forward compatibility. */
+  struct MPoly *mpoly DNA_DEPRECATED;
+  /** Deprecated pointer to face corners, kept for forward compatibility. */
+  struct MLoop *mloop DNA_DEPRECATED;
+
   /** Deprecated array of mesh vertices, kept for reading old files, now stored in #CustomData. */
   struct MVert *mvert DNA_DEPRECATED;
   /** Deprecated array of mesh edges, kept for reading old files, now stored in #CustomData. */
@@ -286,6 +291,7 @@ typedef struct Mesh {
   struct MCol *mcol DNA_DEPRECATED;
   /** Deprecated face storage (quads & triangles only). Kept for reading old files. */
   struct MFace *mface DNA_DEPRECATED;
+
   /**
    * Deprecated storage of old faces (only triangles or quads).
    *



More information about the Bf-blender-cvs mailing list