[Bf-blender-cvs] [359693a] alembic_basic_io: Implement granular data reading.
Kévin Dietrich
noreply at git.blender.org
Wed Jul 20 20:02:30 CEST 2016
Commit: 359693a26c08124122eb2dc8af66293f1e50c3cb
Author: Kévin Dietrich
Date: Wed Jul 20 14:32:19 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB359693a26c08124122eb2dc8af66293f1e50c3cb
Implement granular data reading.
This adds a new flag to the ImportSettings to tell what data is to be
read (verts, faces, uvs and mcols currently) to be speed data reading up
a bit. Eventually this coul also be exposed in the modifier's UI.
===================================================================
M source/blender/alembic/intern/abc_mesh.cc
M source/blender/alembic/intern/abc_mesh.h
M source/blender/alembic/intern/abc_object.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 e4227e5..405fc33 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -969,6 +969,8 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings, bool is_subd)
: AbcObjectReader(object, settings)
{
+ m_settings->flag |= ABC_READ_ALL;
+
IPolyMesh ipoly_mesh(m_iobject, kWrapExisting);
m_schema = ipoly_mesh.getSchema();
get_min_max_time(m_schema, m_min_time, m_max_time);
@@ -1000,7 +1002,7 @@ void AbcMeshReader::readObjectData(Main *bmain, float time)
m_mesh_data = create_config(mesh);
bool has_smooth_normals = false;
- read_mesh_sample(m_schema, sample_sel, m_mesh_data, has_smooth_normals);
+ read_mesh_sample(m_settings, m_schema, sample_sel, m_mesh_data, has_smooth_normals);
BKE_mesh_calc_normals(mesh);
BKE_mesh_validate(mesh, false, false);
@@ -1061,7 +1063,8 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star
utils::assign_materials(bmain, m_object, mat_map);
}
-void read_mesh_sample(const IPolyMeshSchema &schema,
+void read_mesh_sample(ImportSettings *settings,
+ const IPolyMeshSchema &schema,
const ISampleSelector &selector,
CDStreamConfig &config,
bool &do_normals)
@@ -1077,12 +1080,23 @@ void read_mesh_sample(const IPolyMeshSchema &schema,
do_normals = (abc_mesh_data.face_normals != NULL);
- read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
+ if ((settings->flag & ABC_READ_UVS) != 0) {
+ read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
+ }
+
+ if ((settings->flag & ABC_READ_VERTS) != 0) {
+ read_mverts(config, abc_mesh_data);
+ }
- read_mverts(config, abc_mesh_data);
- read_mpolys(config, abc_mesh_data);
+ if ((settings->flag & ABC_READ_FACES) != 0) {
+ read_mpolys(config, abc_mesh_data);
+ }
+
+ if ((settings->flag & (ABC_READ_UVS | ABC_READ_MCOLS)) != 0) {
+ read_custom_data(schema.getArbGeomParams(), config, selector);
+ }
- read_custom_data(schema.getArbGeomParams(), config, selector);
+ /* TODO: face sets */
}
/* ************************************************************************** */
@@ -1103,6 +1117,8 @@ ABC_INLINE MEdge *find_edge(MEdge *edges, int totedge, int v1, int v2)
AbcSubDReader::AbcSubDReader(const IObject &object, ImportSettings &settings)
: AbcObjectReader(object, settings)
{
+ m_settings->flag |= ABC_READ_ALL;
+
ISubD isubd_mesh(m_iobject, kWrapExisting);
m_schema = isubd_mesh.getSchema();
get_min_max_time(m_schema, m_min_time, m_max_time);
@@ -1133,7 +1149,7 @@ void AbcSubDReader::readObjectData(Main *bmain, float time)
m_mesh_data = create_config(mesh);
- read_subd_sample(m_schema, sample_sel, m_mesh_data);
+ read_subd_sample(m_settings, m_schema, sample_sel, m_mesh_data);
Int32ArraySamplePtr indices = sample.getCreaseIndices();
Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
@@ -1160,7 +1176,8 @@ void AbcSubDReader::readObjectData(Main *bmain, float time)
}
}
-void read_subd_sample(const ISubDSchema &schema,
+void read_subd_sample(ImportSettings *settings,
+ const ISubDSchema &schema,
const ISampleSelector &selector,
CDStreamConfig &config)
{
@@ -1173,10 +1190,21 @@ void read_subd_sample(const ISubDSchema &schema,
abc_mesh_data.face_normals = N3fArraySamplePtr();
abc_mesh_data.positions = sample.getPositions();
- read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
+ if ((settings->flag & ABC_READ_UVS) != 0) {
+ read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector);
+ }
+
+ if ((settings->flag & ABC_READ_VERTS) != 0) {
+ read_mverts(config, abc_mesh_data);
+ }
- read_mverts(config, abc_mesh_data);
- read_mpolys(config, abc_mesh_data);
+ if ((settings->flag & ABC_READ_FACES) != 0) {
+ read_mpolys(config, abc_mesh_data);
+ }
+
+ if ((settings->flag & (ABC_READ_UVS | ABC_READ_MCOLS)) != 0) {
+ read_custom_data(schema.getArbGeomParams(), config, selector);
+ }
- read_custom_data(schema.getArbGeomParams(), config, selector);
+ /* TODO: face sets */
}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index f35c714..eb5e1f0 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -108,9 +108,11 @@ private:
const Alembic::AbcGeom::ISampleSelector &sample_sel);
};
-void read_mesh_sample(const Alembic::AbcGeom::IPolyMeshSchema &schema,
+void read_mesh_sample(ImportSettings *settings,
+ const Alembic::AbcGeom::IPolyMeshSchema &schema,
const Alembic::AbcGeom::ISampleSelector &selector,
- CDStreamConfig &config, bool &do_normals);
+ CDStreamConfig &config,
+ bool &do_normals);
/* ************************************************************************** */
@@ -127,7 +129,8 @@ public:
void readObjectData(Main *bmain, float time);
};
-void read_subd_sample(const Alembic::AbcGeom::ISubDSchema &schema,
+void read_subd_sample(ImportSettings *settings,
+ const Alembic::AbcGeom::ISubDSchema &schema,
const Alembic::AbcGeom::ISampleSelector &selector,
CDStreamConfig &config);
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 59e8d10..aa8e440 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -77,6 +77,15 @@ private:
class CacheFile;
+enum {
+ ABC_READ_VERTS = (1 << 0),
+ ABC_READ_FACES = (1 << 1),
+ ABC_READ_UVS = (1 << 2),
+ ABC_READ_MCOLS = (1 << 3),
+
+ ABC_READ_ALL = (ABC_READ_VERTS | ABC_READ_FACES | ABC_READ_UVS | ABC_READ_MCOLS),
+};
+
struct ImportSettings {
bool do_convert_mat;
float conversion_mat[4][4];
@@ -91,7 +100,22 @@ struct ImportSettings {
int sequence_len;
int offset;
+ int flag;
+
CacheFile *cache_file;
+
+ ImportSettings()
+ : do_convert_mat(false)
+ , from_up(0)
+ , from_forward(0)
+ , scale(1.0f)
+ , is_sequence(false)
+ , set_frame_range(false)
+ , sequence_len(1)
+ , offset(0)
+ , flag(0)
+ , cache_file(NULL)
+ {}
};
template <typename Schema>
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 4ca6d52..b8737ca 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -921,6 +921,10 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co
DerivedMesh *new_dm = NULL;
+ /* Only read point data when streaming meshes, unless we need to create new ones. */
+ ImportSettings settings;
+ settings.flag |= ABC_READ_VERTS;
+
if (dm->getNumVerts(dm) != positions->size()) {
new_dm = CDDM_from_template(dm,
positions->size(),
@@ -928,12 +932,14 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co
0,
face_indices->size(),
face_counts->size());
+
+ settings.flag |= ABC_READ_ALL;
}
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
bool has_loop_normals = false;
- read_mesh_sample(schema, sample_sel, config, has_loop_normals);
+ read_mesh_sample(&settings, schema, sample_sel, config, has_loop_normals);
if (new_dm) {
/* Check if we had ME_SMOOTH flag set to restore it. */
@@ -965,6 +971,9 @@ static DerivedMesh *read_subd_sample(DerivedMesh *dm, const IObject &iobject, co
DerivedMesh *new_dm = NULL;
+ ImportSettings settings;
+ settings.flag |= ABC_READ_VERTS;
+
if (dm->getNumVerts(dm) != positions->size()) {
new_dm = CDDM_from_template(dm,
positions->size(),
@@ -972,10 +981,13 @@ static DerivedMesh *read_subd_sample(DerivedMesh *dm, const IObject &iobject, co
0,
face_indices->size(),
face_counts->size());
+
+ settings.flag |= ABC_READ_ALL;
}
+ /* Only read point data when streaming meshes, unless we need to create new ones. */
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
- read_subd_sample(schema, sample_sel, config);
+ read_subd_sample(&settings, schema, sample_sel, config);
if (new_dm) {
/* Check if we had ME_SMOOTH flag set to restore it. */
More information about the Bf-blender-cvs
mailing list