[Bf-blender-cvs] [c4abed0] alembic_basic_io: Move import settings to a separate struct.

Kévin Dietrich noreply at git.blender.org
Tue May 24 11:23:42 CEST 2016


Commit: c4abed0623e5da7dfbf1b628ef32904fcc6cbdac
Author: Kévin Dietrich
Date:   Tue May 24 10:42:33 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBc4abed0623e5da7dfbf1b628ef32904fcc6cbdac

Move import settings to a separate struct.

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

M	source/blender/alembic/intern/abc_camera.cc
M	source/blender/alembic/intern/abc_camera.h
M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/abc_mesh.h
M	source/blender/alembic/intern/abc_nurbs.cc
M	source/blender/alembic/intern/abc_nurbs.h
M	source/blender/alembic/intern/abc_object.cc
M	source/blender/alembic/intern/abc_object.h
M	source/blender/alembic/intern/alembic_capi.cc

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

diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc
index 858644c..0e08100 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -112,8 +112,8 @@ void AbcCameraWriter::do_write()
 
 /* ****************************** camera reader ***************************** */
 
-AbcCameraReader::AbcCameraReader(const Alembic::Abc::IObject &object, int from_forward, int from_up)
-    : AbcObjectReader(object, from_forward, from_up)
+AbcCameraReader::AbcCameraReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
+    : AbcObjectReader(object, settings)
 {
 	ICamera abc_cam(m_iobject, kWrapExisting);
 	m_schema = abc_cam.getSchema();
diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h
index eb2c8ff..d7c9989 100644
--- a/source/blender/alembic/intern/abc_camera.h
+++ b/source/blender/alembic/intern/abc_camera.h
@@ -47,7 +47,7 @@ class AbcCameraReader : public AbcObjectReader {
 	Alembic::AbcGeom::ICameraSchema m_schema;
 
 public:
-	AbcCameraReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+	AbcCameraReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
 
 	bool valid() const;
 
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index b61e141..d43093e 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1120,8 +1120,8 @@ static void ABC_apply_materials(Object *ob, void *key)
 }
 #endif
 
-AbcMeshReader::AbcMeshReader(const IObject &object, int from_forward, int from_up)
-    : AbcObjectReader(object, from_forward, from_up)
+AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings)
+    : AbcObjectReader(object, settings)
 {
 	IPolyMesh abc_mesh(m_iobject, kWrapExisting);
 	m_schema = abc_mesh.getSchema();
@@ -1178,11 +1178,11 @@ void AbcMeshReader::readObjectData(Main *bmain, Scene *scene, float time)
 		mvert.bweight = 0;
 	}
 
-	if (m_do_convert_mat) {
+	if (m_settings->do_convert_mat) {
 		j = vtx_pos;
 		for (int i = 0; i < vertex_count; ++i, ++j) {
 			MVert &mvert = blender_mesh->mvert[j];
-			mul_m3_v3(m_conversion_mat, mvert.co);
+			mul_m4_v3(m_settings->conversion_mat, mvert.co);
 		}
 	}
 
@@ -1261,8 +1261,8 @@ void AbcMeshReader::readObjectData(Main *bmain, Scene *scene, float time)
 	MeshCacheModifierData *mcmd = reinterpret_cast<MeshCacheModifierData *>(md);
 	mcmd->type = MOD_MESHCACHE_TYPE_ABC;
 	mcmd->time_mode = MOD_MESHCACHE_TIME_SECONDS;
-	mcmd->forward_axis = m_from_forward;
-	mcmd->up_axis = m_from_up;
+	mcmd->forward_axis = m_settings->from_forward;
+	mcmd->up_axis = m_settings->from_up;
 
 	BLI_strncpy(mcmd->filepath, m_iobject.getArchive().getName().c_str(), 1024);
 	BLI_strncpy(mcmd->sub_object, m_iobject.getFullName().c_str(), 1024);
@@ -1275,8 +1275,8 @@ void AbcMeshReader::readObjectData(Main *bmain, Scene *scene, float time)
 #endif
 }
 
-AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, int from_forward, int from_up)
-    : AbcObjectReader(object, from_forward, from_up)
+AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
+    : AbcObjectReader(object, settings)
 {}
 
 bool AbcEmptyReader::valid() const
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 8abdc86..b03b80d 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -107,7 +107,7 @@ class AbcMeshReader : public AbcObjectReader {
 	Alembic::AbcGeom::IPolyMeshSchema m_schema;
 
 public:
-	AbcMeshReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+	AbcMeshReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
 
 	bool valid() const;
 
@@ -118,7 +118,7 @@ class AbcEmptyReader : public AbcObjectReader {
 	Alembic::AbcGeom::IXformSchema m_schema;
 
 public:
-	AbcEmptyReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+	AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
 
 	bool valid() const;
 
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index 82d5ea4..c5d7dce 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -218,8 +218,8 @@ void AbcNurbsWriter::do_write()
 
 /* ****************************** nurbs reader ****************************** */
 
-AbcNurbsReader::AbcNurbsReader(const IObject &object, int from_forward, int from_up)
-    : AbcObjectReader(object, from_forward, from_up)
+AbcNurbsReader::AbcNurbsReader(const IObject &object, ImportSettings &settings)
+    : AbcObjectReader(object, settings)
 {
 	getNurbsPatches(m_iobject);
 }
diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h
index cbb0a69..7621fe7 100644
--- a/source/blender/alembic/intern/abc_nurbs.h
+++ b/source/blender/alembic/intern/abc_nurbs.h
@@ -46,7 +46,7 @@ class AbcNurbsReader : public AbcObjectReader {
 	std::vector< std::pair<Alembic::AbcGeom::INuPatchSchema, Alembic::Abc::IObject> > m_schemas;
 
 public:
-	AbcNurbsReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+	AbcNurbsReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
 
 	bool valid() const;
 
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index e14b395..ae99961 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -303,15 +303,13 @@ bool AbcObjectWriter::getPropertyValue(ID *id, const std::string &name, double &
 
 /* ****************************** object reader ***************************** */
 
-AbcObjectReader::AbcObjectReader(const IObject &object, int from_forward, int from_up)
+AbcObjectReader::AbcObjectReader(const IObject &object, ImportSettings &settings)
     : m_name("")
     , m_object_name("")
     , m_data_name("")
     , m_object(NULL)
     , m_iobject(object)
-    , m_do_convert_mat(false)
-    , m_from_up(from_up)
-    , m_from_forward(from_forward)
+    , m_settings(&settings)
 {
 	m_name = object.getFullName();
 	std::vector<std::string> parts;
@@ -321,10 +319,6 @@ AbcObjectReader::AbcObjectReader(const IObject &object, int from_forward, int fr
 
 	m_object_name = parts[parts.size() - 2];
 	m_data_name = parts[parts.size() - 1];
-
-	if (mat3_from_axis_conversion(from_forward, from_up, 1, 2, m_conversion_mat)) {
-		m_do_convert_mat = true;
-	}
 }
 
 AbcObjectReader::~AbcObjectReader()
@@ -340,7 +334,7 @@ Object *AbcObjectReader::object() const
 	return m_object;
 }
 
-void AbcObjectReader::readObjectMatrix(const float time, const float scale)
+void AbcObjectReader::readObjectMatrix(const float time)
 {
 	const Alembic::AbcGeom::MetaData &md = m_iobject.getParent().getMetaData();
 
@@ -366,8 +360,8 @@ void AbcObjectReader::readObjectMatrix(const float time, const float scale)
 		m_object->rot[1] = xs.getYRotation() * M_PI / 180;
 		m_object->rot[2] = xs.getZRotation() * M_PI / 180;
 
-		if (m_do_convert_mat) {
-			mul_v3_m3v3(m_object->loc, m_conversion_mat, loc);
+		if (m_settings->do_convert_mat) {
+			mul_v3_m4v3(m_object->loc, m_settings->conversion_mat, loc);
 		}
 		else {
 			copy_v3_v3(m_object->loc, loc);
@@ -375,16 +369,7 @@ void AbcObjectReader::readObjectMatrix(const float time, const float scale)
 
 		DAG_id_tag_update(&(m_object->id), OB_RECALC_OB);
 
-//		float global_mat[4][4];
-//		scale_m4_fl(global_mat, scale);
-
-//		if (m_do_convert_mat) {
-//			mul_m4_m4m3(global_mat, global_mat, m_conversion_mat);
-//		}
-
-//		translate_m4(global_mat, 1.0f, 1.0f, 1.0f);
-//		mul_m4_m4m4(m_object->obmat, m_object->obmat, global_mat);
-
+//		mul_m4_m4m4(m_object->obmat, m_settings->conversion_mat, m_object->obmat);
 //		BKE_object_apply_mat4(m_object, m_object->obmat, false,  false);
 	}
 }
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 8b6747e..0bd133b 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -72,6 +72,15 @@ protected:
 	bool getPropertyValue(ID *id, const std::string &name, double &val);
 };
 
+struct ImportSettings {
+	bool do_convert_mat;
+	float conversion_mat[4][4];
+
+	int from_up;
+	int from_forward;
+	float scale;
+};
+
 class AbcObjectReader {
 protected:
 	std::string m_name;
@@ -80,16 +89,10 @@ protected:
 	Object *m_object;
 	Alembic::Abc::IObject m_iobject;
 
-	/* TODO(kevin): move this out of here, becomes redundant when importing
-	 * multiple object */
-	bool m_do_convert_mat;
-	float m_conversion_mat[3][3];
-
-	int m_from_up;
-	int m_from_forward;
+	ImportSettings *m_settings;
 
 public:
-	explicit AbcObjectReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+	explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
 
 	virtual ~AbcObjectReader();
 
@@ -101,7 +104,7 @@ public:
 
 	virtual void readObjectData(Main *bmain, Scene *scene, float time) = 0;
 
-	void readObjectMatrix(const float time, const float scale);
+	void readObjectMatrix(const float time);
 };
 
 #endif
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 657d72b..cbbe24b 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -292,7 +292,7 @@ static bool is_locator(const IObject &object)
 
 static void visit_object(const IObject &object,
                          std::vector<AbcObjectReader *> &readers,
-                         int from_forward, int from_up)
+                         ImportSettings &settings)
 {
 	if (!object.valid()) {
 		return;
@@ -310,31 +310,31 @@ static void visit_object(const IObject &object,
 		const MetaData &md = child.getMetaData();
 
 		if (IXform::matches(md) && is_locator(child)) {
-			reader = new AbcEmptyReader(child, from_forward, from_up);
+			reader = new AbcEmptyReader(child, settings);
 		}
 		else if (IPolyMesh::ma

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list