[Bf-blender-cvs] [e72a6971c18] temp-sybren-alembic-customprops-read: Alembic: support for custom props on meshes.

Sybren A. Stüvel noreply at git.blender.org
Thu Dec 7 10:36:29 CET 2017


Commit: e72a6971c18ea4ec6c41b7bfac760d3c02748c9c
Author: Sybren A. Stüvel
Date:   Mon Nov 13 12:35:08 2017 +0100
Branches: temp-sybren-alembic-customprops-read
https://developer.blender.org/rBe72a6971c18ea4ec6c41b7bfac760d3c02748c9c

Alembic: support for custom props on meshes.

Also introduces a different approach for subclasses of AbcObjectReader.
Subclasses can now just override read_custom_properties(…) and call
read_custom_properties_into(…) however they like. This is more flexible
as well as easier to read than what we had before.

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

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

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

diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 40859ace390..85f247aeecb 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1368,3 +1368,24 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
 
 	return dm;
 }
+
+
+/* ******* Custom properties support **************************************** */
+
+void AbcMeshReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel)
+{
+	AbcObjectReader::read_custom_properties(sample_sel);
+
+	read_custom_properties_into(static_cast<ID *>(m_object->data),
+	                            m_schema.getArbGeomParams(),
+	                            sample_sel);
+}
+
+void AbcSubDReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel)
+{
+	AbcObjectReader::read_custom_properties(sample_sel);
+
+	read_custom_properties_into(static_cast<ID *>(m_object->data),
+	                            m_schema.getArbGeomParams(),
+	                            sample_sel);
+}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 77c352d7cd3..57d116b5eb6 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -109,7 +109,7 @@ public:
 	                              const Alembic::Abc::ISampleSelector &sample_sel,
 	                              int read_flag,
 	                              const char **err_str);
-
+	virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel) override;
 private:
 	void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
 	                        const Alembic::AbcGeom::ISampleSelector &sample_sel);
@@ -139,6 +139,7 @@ public:
 	                              const Alembic::Abc::ISampleSelector &sample_sel,
 	                              int read_flag,
 	                              const char **err_str);
+	virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel) override;
 };
 
 /* ************************************************************************** */
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index a74850cfdec..88f5f24cd1a 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -375,18 +375,18 @@ void AbcObjectReader::decref()
 	BLI_assert(m_refcount >= 0);
 }
 
-void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel)
+void AbcObjectReader::read_custom_properties_into(ID *id,
+                                                  ICompoundProperty params,
+                                                  const Alembic::Abc::ISampleSelector &sample_sel)
 {
-	using Alembic::AbcCoreAbstract::ArraySamplePtr;
+	/* This makes it easier for our callers to just pass ob->data without checking. */
+	if (id == NULL) return;
 
-	/* Maya seems to write custom properties to the .abcGeomParams Alembic property. */
-	ICompoundProperty params = getArbGeomParams();
 	if (!params.valid()) {
-		std::cerr << "Params for " << m_object_name << " invalid, skipping\n";
+		std::cerr << "Params for " << id->name << " invalid, skipping\n";
 		return;
 	}
 
-	ID *id = getID();
 	IDPropertyTemplate idval = { 0 };
 	char idproptype;
 
@@ -586,18 +586,11 @@ void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector
 	}
 }
 
-ICompoundProperty AbcObjectReader::getArbGeomParams()
+void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel)
 {
 	IXform my_xform = xform();
-	if (!my_xform.valid()) {
-		std::cerr << "XForm for " << m_object_name << " invalid, skipping\n";
-		return ICompoundProperty();
-	}
+	if (!my_xform.valid()) return;
 
-	return my_xform.getSchema().getArbGeomParams();
-}
-
-ID *AbcObjectReader::getID()
-{
-	return &m_object->id;
+	IXformSchema schema = my_xform.getSchema();
+	read_custom_properties_into(&m_object->id, schema.getArbGeomParams(), sample_sel);
 }
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 28a274a8bf9..8b8f6540703 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -198,12 +198,13 @@ public:
 	void read_matrix(float r_mat[4][4], const float time,
 	                 const float scale, bool &is_constant);
 
-	void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel);
+	virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel);
 protected:
 	void determine_inherits_xform();
 
-	virtual Alembic::AbcGeom::ICompoundProperty getArbGeomParams();
-	virtual ID *getID();
+	static void read_custom_properties_into(ID *id,
+	                                        Alembic::Abc::ICompoundProperty params,
+	                                        const Alembic::Abc::ISampleSelector &sample_sel);
 };
 
 Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);



More information about the Bf-blender-cvs mailing list