[Bf-blender-cvs] [e74847e6bb5] master: Alembic: changed 'void *user_data' to 'Mesh *mesh'

Sybren A. Stüvel noreply at git.blender.org
Tue Jul 30 17:07:08 CEST 2019


Commit: e74847e6bb5cea24def9e544a3fb2bc90150aeaf
Author: Sybren A. Stüvel
Date:   Thu Jul 4 12:04:39 2019 +0200
Branches: master
https://developer.blender.org/rBe74847e6bb5cea24def9e544a3fb2bc90150aeaf

Alembic: changed 'void *user_data' to 'Mesh *mesh'

The only thing that is stored in this pointer is a `Mesh*`, and casting
it from/to `void*` is unnecessary and confusing. Maybe the entire
CDStreamConfig class could/should be removed at some point.

No functional changes.

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

M	source/blender/alembic/intern/abc_customdata.cc
M	source/blender/alembic/intern/abc_customdata.h
M	source/blender/alembic/intern/abc_mesh.cc

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

diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 20ca659d32f..63887d36381 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -353,7 +353,7 @@ static void read_custom_data_mcols(const std::string &iobject_full_name,
 
   /* Read the vertex colors */
   void *cd_data = config.add_customdata_cb(
-      config.user_data, prop_header.getName().c_str(), CD_MLOOPCOL);
+      config.mesh, prop_header.getName().c_str(), CD_MLOOPCOL);
   MCol *cfaces = static_cast<MCol *>(cd_data);
   MPoly *mpolys = config.mpoly;
   MLoop *mloops = config.mloop;
@@ -437,8 +437,7 @@ static void read_custom_data_uvs(const ICompoundProperty &prop,
     return;
   }
 
-  void *cd_data = config.add_customdata_cb(
-      config.user_data, prop_header.getName().c_str(), CD_MLOOPUV);
+  void *cd_data = config.add_customdata_cb(config.mesh, prop_header.getName().c_str(), CD_MLOOPUV);
 
   read_uvs(config, cd_data, sample.getVals(), sample.getIndices());
 }
diff --git a/source/blender/alembic/intern/abc_customdata.h b/source/blender/alembic/intern/abc_customdata.h
index c36029d5116..0ffafa8848e 100644
--- a/source/blender/alembic/intern/abc_customdata.h
+++ b/source/blender/alembic/intern/abc_customdata.h
@@ -28,6 +28,7 @@
 #include <Alembic/AbcGeom/All.h>
 
 struct CustomData;
+struct Mesh;
 struct MLoop;
 struct MLoopUV;
 struct MPoly;
@@ -60,8 +61,8 @@ struct CDStreamConfig {
   /* TODO(kevin): might need a better way to handle adding and/or updating
    * custom datas such that it updates the custom data holder and its pointers
    * properly. */
-  void *user_data;
-  void *(*add_customdata_cb)(void *user_data, const char *name, int data_type);
+  Mesh *mesh;
+  void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
 
   float weight;
   float time;
@@ -75,7 +76,7 @@ struct CDStreamConfig {
         totpoly(0),
         totvert(0),
         pack_uvs(false),
-        user_data(NULL),
+        mesh(NULL),
         add_customdata_cb(NULL),
         weight(0.0f),
         time(0.0f),
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 1903b5149c5..13cc670b7dc 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -900,7 +900,7 @@ ABC_INLINE void read_uvs_params(CDStreamConfig &config,
       name = uv.getName();
     }
 
-    void *cd_ptr = config.add_customdata_cb(config.user_data, name.c_str(), CD_MLOOPUV);
+    void *cd_ptr = config.add_customdata_cb(config.mesh, name.c_str(), CD_MLOOPUV);
     config.mloopuv = static_cast<MLoopUV *>(cd_ptr);
   }
 }
@@ -960,9 +960,8 @@ static void set_smooth_poly_flag(Mesh *mesh)
   }
 }
 
-static void *add_customdata_cb(void *user_data, const char *name, int data_type)
+static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
 {
-  Mesh *mesh = static_cast<Mesh *>(user_data);
   CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
   void *cd_ptr;
   CustomData *loopdata;
@@ -1047,7 +1046,7 @@ CDStreamConfig get_config(Mesh *mesh)
 
   BLI_assert(mesh->mvert || mesh->totvert == 0);
 
-  config.user_data = mesh;
+  config.mesh = mesh;
   config.mvert = mesh->mvert;
   config.mloop = mesh->mloop;
   config.mpoly = mesh->mpoly;



More information about the Bf-blender-cvs mailing list