[Bf-blender-cvs] [1a40e55] alembic_basic_io: De-duplicate point reading logic, add support to read custom data for points only meshes.
Kévin Dietrich
noreply at git.blender.org
Thu Jul 28 21:12:31 CEST 2016
Commit: 1a40e55f6aa46d2dbcfb903c4e554ba364961597
Author: Kévin Dietrich
Date: Thu Jul 28 21:00:30 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB1a40e55f6aa46d2dbcfb903c4e554ba364961597
De-duplicate point reading logic, add support to read custom data for
points only meshes.
===================================================================
M source/blender/alembic/intern/abc_mesh.cc
M source/blender/alembic/intern/abc_mesh.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
===================================================================
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 86fcc87..07bd12e 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -815,7 +815,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
return cd_ptr;
}
-ABC_INLINE CDStreamConfig create_config(Mesh *mesh)
+CDStreamConfig create_config(Mesh *mesh)
{
CDStreamConfig config;
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index fc629c2..9dc222e 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -147,4 +147,6 @@ void read_mverts(MVert *mverts,
const Alembic::AbcGeom::P3fArraySamplePtr &positions,
const Alembic::AbcGeom::N3fArraySamplePtr &normals);
-#endif /* __ABC_MESH_H__ */
\ No newline at end of file
+CDStreamConfig create_config(Mesh *mesh);
+
+#endif /* __ABC_MESH_H__ */
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index b0be0e9..9b2d02d 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -157,21 +157,10 @@ void AbcPointsReader::readObjectData(Main *bmain, float time)
m_sample = m_schema.getValue(sample_sel);
const P3fArraySamplePtr &positions = m_sample.getPositions();
-
utils::mesh_add_verts(mesh, positions->size());
- ICompoundProperty prop = m_schema.getArbGeomParams();
- N3fArraySamplePtr vnormals;
-
- if (has_property(prop, "N")) {
- const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, "N", time);
-
- if (normals_prop) {
- vnormals = normals_prop.getValue(sample_sel);
- }
- }
-
- read_mverts(mesh->mvert, positions, vnormals);
+ CDStreamConfig config = create_config(mesh);
+ read_points_sample(m_schema, sample_sel, config, time);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@@ -184,3 +173,27 @@ void AbcPointsReader::readObjectData(Main *bmain, float time)
addCacheModifier();
}
}
+
+void read_points_sample(const IPointsSchema &schema,
+ const ISampleSelector &selector,
+ CDStreamConfig &config,
+ float time)
+{
+ Alembic::AbcGeom::IPointsSchema::Sample m_sample = schema.getValue(selector);
+
+ const P3fArraySamplePtr &positions = m_sample.getPositions();
+
+ ICompoundProperty prop = schema.getArbGeomParams();
+ N3fArraySamplePtr vnormals;
+
+ if (has_property(prop, "N")) {
+ const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, "N", time);
+
+ if (normals_prop) {
+ vnormals = normals_prop.getValue(selector);
+ }
+ }
+
+ read_mverts(config.mvert, positions, vnormals);
+ read_custom_data(schema.getArbGeomParams(), config, selector);
+}
diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h
index f044956..51f3103 100644
--- a/source/blender/alembic/intern/abc_points.h
+++ b/source/blender/alembic/intern/abc_points.h
@@ -26,6 +26,7 @@
#define __ABC_POINTS_H__
#include "abc_object.h"
+#include "abc_customdata.h"
class ParticleSystem;
@@ -61,4 +62,9 @@ public:
void readObjectData(Main *bmain, float time);
};
+void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema,
+ const Alembic::AbcGeom::ISampleSelector &selector,
+ CDStreamConfig &config,
+ float time);
+
#endif /* __ABC_POINTS_H__ */
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index ac0f51c..6270dec 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -996,26 +996,16 @@ static DerivedMesh *read_points_sample(DerivedMesh *dm, const IObject &iobject,
const P3fArraySamplePtr &positions = sample.getPositions();
- if (dm->getNumVerts(dm) != positions->size()) {
- dm = CDDM_new(positions->size(), 0, 0, 0, 0);
- }
-
- ICompoundProperty prop = schema.getArbGeomParams();
- N3fArraySamplePtr vnormals;
-
- if (has_property(prop, "N")) {
- const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, "N", 0);
+ DerivedMesh *new_dm = NULL;
- if (normals_prop) {
- vnormals = normals_prop.getValue(sample_sel);
- }
+ if (dm->getNumVerts(dm) != positions->size()) {
+ new_dm = CDDM_new(positions->size(), 0, 0, 0, 0);
}
- MVert *mverts = dm->getVertArray(dm);
-
- read_mverts(mverts, positions, vnormals);
+ CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ read_points_sample(schema, sample_sel, config, time);
- return dm;
+ return new_dm ? new_dm : dm;
}
/* NOTE: Alembic only stores data about control points, but the DerivedMesh
More information about the Bf-blender-cvs
mailing list