Commit: 5b0f96f97cd427daef7b00331b841580f6ffcdcf
Author: Sybren A. Stüvel
Date:   Wed Jun 6 11:06:11 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB5b0f96f97cd427daef7b00331b841580f6ffcdcf

Alembic import: port DerivedMesh → Mesh

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

M       source/blender/alembic/ABC_alembic.h
M       source/blender/alembic/intern/abc_curves.cc
M       source/blender/alembic/intern/abc_curves.h
M       source/blender/alembic/intern/abc_mesh.cc
M       source/blender/alembic/intern/abc_mesh.h
M       source/blender/alembic/intern/abc_object.cc
M       source/blender/alembic/intern/abc_object.h
M       source/blender/alembic/intern/abc_points.cc
M       source/blender/alembic/intern/abc_points.h
M       source/blender/alembic/intern/alembic_capi.cc
M       source/blender/modifiers/intern/MOD_meshsequencecache.c

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

diff --git a/source/blender/alembic/ABC_alembic.h 
b/source/blender/alembic/ABC_alembic.h
index 70250310213..08136fc2f49 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -29,8 +29,8 @@ extern "C" {
 
 struct bContext;
 struct CacheReader;
-struct DerivedMesh;
 struct ListBase;
+struct Mesh;
 struct Object;
 struct Scene;
 
@@ -114,12 +114,13 @@ void ABC_get_transform(struct CacheReader *reader,
                        float time,
                        float scale);
 
-struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader,
-                                  struct Object *ob,
-                                  struct DerivedMesh *dm,
-                                  const float time,
-                                  const char **err_str,
-                                  int flags);
+/* Either modifies current_mesh in-place or constructs a new mesh. */
+struct Mesh *ABC_read_mesh(struct CacheReader *reader,
+                           struct Object *ob,
+                           struct Mesh *current_mesh,
+                           const float time,
+                           const char **err_str,
+                           int flags);
 
 void CacheReader_incref(struct CacheReader *reader);
 void CacheReader_free(struct CacheReader *reader);
diff --git a/source/blender/alembic/intern/abc_curves.cc 
b/source/blender/alembic/intern/abc_curves.cc
index 41c1dacabc0..9c64fd0481e 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -37,8 +37,8 @@ extern "C" {
 
 #include "BLI_listbase.h"
 
-#include "BKE_cdderivedmesh.h"
 #include "BKE_curve.h"
+#include "BKE_mesh.h"
 #include "BKE_object.h"
 
 #include "ED_curve.h"
@@ -400,16 +400,16 @@ void read_curve_sample(Curve *cu, const ICurvesSchema 
&schema, const ISampleSele
        }
 }
 
-/* NOTE: Alembic only stores data about control points, but the DerivedMesh
+/* NOTE: Alembic only stores data about control points, but the Mesh
  * passed from the cache modifier contains the displist, which has more data
  * than the control points, so to avoid corrupting the displist we modify the
- * object directly and create a new DerivedMesh from that. Also we might need 
to
+ * object directly and create a new Mesh from that. Also we might need to
  * create new or delete existing NURBS in the curve.
  */
-DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
-                                              const ISampleSelector 
&sample_sel,
-                                              int /*read_flag*/,
-                                              const char ** /*err_str*/)
+Mesh *AbcCurveReader::read_mesh(Mesh * /*existing_mesh*/,
+                                const ISampleSelector &sample_sel,
+                                int /*read_flag*/,
+                                const char ** /*err_str*/)
 {
        const ICurvesSchema::Sample sample = 
m_curves_schema.getValue(sample_sel);
 
@@ -450,5 +450,5 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * 
/*dm*/,
                }
        }
 
-       return CDDM_from_curve(m_object);
+       return BKE_mesh_new_nomain_from_curve(m_object);
 }
diff --git a/source/blender/alembic/intern/abc_curves.h 
b/source/blender/alembic/intern/abc_curves.h
index 1e7180bbb1f..e2373381703 100644
--- a/source/blender/alembic/intern/abc_curves.h
+++ b/source/blender/alembic/intern/abc_curves.h
@@ -60,10 +60,10 @@ public:
                                 const char **err_str) const;
 
        void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector 
&sample_sel);
-       DerivedMesh *read_derivedmesh(DerivedMesh *dm,
-                                     const Alembic::Abc::ISampleSelector 
&sample_sel,
-                                     int read_flag,
-                                     const char **err_str);
+       struct Mesh *read_mesh(struct Mesh *existing_mesh,
+                              const Alembic::Abc::ISampleSelector &sample_sel,
+                              int read_flag,
+                              const char **err_str);
 };
 
 /* ************************************************************************** 
*/
diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index d52d7f06048..03d70b4f56b 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -873,11 +873,11 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
        }
 }
 
-static bool check_smooth_poly_flag(DerivedMesh *dm)
+static bool check_smooth_poly_flag(Mesh *mesh)
 {
-       MPoly *mpolys = dm->getPolyArray(dm);
+       MPoly *mpolys = mesh->mpoly;
 
-       for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
+       for (int i = 0, e = mesh->totpoly; i < e; ++i) {
                MPoly &poly = mpolys[i];
 
                if ((poly.flag & ME_SMOOTH) != 0) {
@@ -888,11 +888,11 @@ static bool check_smooth_poly_flag(DerivedMesh *dm)
        return false;
 }
 
-static void set_smooth_poly_flag(DerivedMesh *dm)
+static void set_smooth_poly_flag(Mesh *mesh)
 {
-       MPoly *mpolys = dm->getPolyArray(dm);
+       MPoly *mpolys = mesh->mpoly;
 
-       for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
+       for (int i = 0, e = mesh->totpoly; i < e; ++i) {
                MPoly &poly = mpolys[i];
                poly.flag |= ME_SMOOTH;
        }
@@ -900,7 +900,7 @@ static void set_smooth_poly_flag(DerivedMesh *dm)
 
 static void *add_customdata_cb(void *user_data, const char *name, int 
data_type)
 {
-       DerivedMesh *dm = static_cast<DerivedMesh *>(user_data);
+       Mesh *mesh = static_cast<Mesh *>(user_data);
        CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
        void *cd_ptr;
        CustomData *loopdata;
@@ -911,7 +911,7 @@ static void *add_customdata_cb(void *user_data, const char 
*name, int data_type)
                return NULL;
        }
 
-       loopdata = dm->getLoopDataLayout(dm);
+       loopdata = &mesh->ldata;
        cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
        if (cd_ptr != NULL) {
                /* layer already exists, so just return it. */
@@ -920,7 +920,7 @@ static void *add_customdata_cb(void *user_data, const char 
*name, int data_type)
 
        /* create a new layer, taking care to construct the 
hopefully-soon-to-be-removed
         * CD_MTEXPOLY layer too, with the same name. */
-       numloops = dm->getNumLoops(dm);
+       numloops = mesh->totloop;
        cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT,
                                            NULL, numloops, name);
        return cd_ptr;
@@ -986,17 +986,19 @@ static void read_mesh_sample(const std::string & 
iobject_full_name,
        }
 }
 
-CDStreamConfig get_config(DerivedMesh *dm)
+CDStreamConfig get_config(Mesh *mesh)
 {
        CDStreamConfig config;
 
-       config.user_data = dm;
-       config.mvert = dm->getVertArray(dm);
-       config.mloop = dm->getLoopArray(dm);
-       config.mpoly = dm->getPolyArray(dm);
-       config.totloop = dm->getNumLoops(dm);
-       config.totpoly = dm->getNumPolys(dm);
-       config.loopdata = dm->getLoopDataLayout(dm);
+       BLI_assert(mesh->mvert);
+
+       config.user_data = mesh;
+       config.mvert = mesh->mvert;
+       config.mloop = mesh->mloop;
+       config.mpoly = mesh->mpoly;
+       config.totloop = mesh->totloop;
+       config.totpoly = mesh->totpoly;
+       config.loopdata = &mesh->ldata;
        config.add_customdata_cb = add_customdata_cb;
 
        return config;
@@ -1027,14 +1029,8 @@ void AbcMeshReader::readObjectData(Main *bmain, const 
Alembic::Abc::ISampleSelec
        m_object = BKE_object_add_only_object(bmain, OB_MESH, 
m_object_name.c_str());
        m_object->data = mesh;
 
-       DerivedMesh *dm = CDDM_from_mesh(mesh);
-       DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, 
MOD_MESHSEQ_READ_ALL, NULL);
-
-       if (ndm != dm) {
-               dm->release(dm);
-       }
-
-       DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
+       Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 
MOD_MESHSEQ_READ_ALL, NULL);
+       BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
 
        if (m_settings->validate_meshes) {
                BKE_mesh_validate(mesh, false, false);
@@ -1064,10 +1060,10 @@ bool AbcMeshReader::accepts_object_type(const 
Alembic::AbcCoreAbstract::ObjectHe
        return true;
 }
 
-DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
-                                             const ISampleSelector &sample_sel,
-                                             int read_flag,
-                                             const char **err_str)
+Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
+                               const ISampleSelector &sample_sel,
+                               int read_flag,
+                               const char **err_str)
 {
        const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel);
 
@@ -1075,22 +1071,22 @@ DerivedMesh 
*AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
        const Alembic::Abc::Int32ArraySamplePtr &face_indices = 
sample.getFaceIndices();
        const Alembic::Abc::Int32ArraySamplePtr &face_counts = 
sample.getFaceCounts();
 
-       DerivedMesh *new_dm = NULL;
+       Mesh *new_mesh = NULL;
 
        /* Only read point data when streaming meshes, unless we need to create 
new ones. */
        ImportSettings settings;
        settings.read_flag |= read_flag;
 
-       bool topology_changed =  positions->size() != dm->getNumVerts(dm) ||
-                                face_counts->size() != dm->getNumPolys(dm) ||
-                                face_indices->size() != dm->getNumLoops(dm);
+       bool topology_changed =  positions->size() != existing_mesh->totvert ||
+                                face_counts->size() != existing_mesh->totpoly 
||
+                                face_indices->size() != existing_mesh->totloop;
        if (topology_changed) {
-               new_dm = CDDM_from_template(dm,
-                                           positions->size(),
-                                           0,
-                                           0,
-                                           face_indices->size(),
-                                           face_counts->size());
+               new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
+                                                            positions->size(),
+                                                            0,
+                                                            0,
+                                                            
face_indices->size(),
+                                                            
face_counts->size());
 
                settings.read_flag |= MOD_MESHSEQ_READ_ALL;
        }
@@ -1098,8 +1094,8 @@ DerivedMesh *AbcMeshReader::

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to