[Bf-blender-cvs] [5482ccc] alembic_basic_io: Add an empty (Maya locator) object reader.

Kévin Dietrich noreply at git.blender.org
Mon May 23 12:52:41 CEST 2016


Commit: 5482ccc3a6feae87a22143cda10c22a5223fbcf1
Author: Kévin Dietrich
Date:   Mon May 23 12:25:16 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB5482ccc3a6feae87a22143cda10c22a5223fbcf1

Add an empty (Maya locator) object reader.

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

M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/abc_mesh.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 275d575..b61e141 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -33,6 +33,7 @@ extern "C" {
 #include "DNA_modifier_types.h"
 #include "DNA_object_fluidsim.h"
 #include "DNA_object_types.h"
+#include "DNA_object_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math_geom.h"
@@ -1273,3 +1274,17 @@ 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)
+{}
+
+bool AbcEmptyReader::valid() const
+{
+	return true; // TODO? m_schema.valid();
+}
+
+void AbcEmptyReader::readObjectData(Main *bmain, Scene *scene, float /*time*/)
+{
+	m_object = BKE_object_add(bmain, scene, OB_EMPTY, m_object_name.c_str());
+}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index dd8aeb2..8abdc86 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -114,4 +114,15 @@ public:
 	void readObjectData(Main *bmain, Scene *scene, float time);
 };
 
+class AbcEmptyReader : public AbcObjectReader {
+	Alembic::AbcGeom::IXformSchema m_schema;
+
+public:
+	AbcEmptyReader(const Alembic::Abc::IObject &object, int from_forward, int from_up);
+
+	bool valid() const;
+
+	void readObjectData(Main *bmain, Scene *scene, float time);
+};
+
 #endif  /* __ABC_MESH_WRITER_H__ */
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index e16a2bd..68a759e 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -58,6 +58,7 @@ using Alembic::AbcGeom::IObject;
 using Alembic::AbcGeom::IPolyMesh;
 using Alembic::AbcGeom::IPolyMeshSchema;
 using Alembic::AbcGeom::ISampleSelector;
+using Alembic::AbcGeom::IXform;
 
 static IArchive open_archive(const std::string &filename)
 {
@@ -282,6 +283,13 @@ int ABC_export(Scene *sce, const char *filename,
 	return BL_ABC_NO_ERR;
 }
 
+/* Return whether or not this object is a Maya locator, which is similar to
+ * empties used as parent object in Blender. */
+static bool is_locator(const IObject &object)
+{
+	return object.getProperties().getPropertyHeader("locator") != NULL;
+}
+
 static void visit_object(const IObject &object,
                          std::vector<AbcObjectReader *> &readers,
                          int from_forward, int from_up)
@@ -301,7 +309,10 @@ static void visit_object(const IObject &object,
 
 		const MetaData &md = child.getMetaData();
 
-		if (IPolyMesh::matches(md)) {
+		if (IXform::matches(md) && is_locator(child)) {
+			reader = new AbcEmptyReader(child, from_forward, from_up);
+		}
+		else if (IPolyMesh::matches(md)) {
 			reader = new AbcMeshReader(child, from_forward, from_up);
 		}
 		else if (INuPatch::matches(md)) {




More information about the Bf-blender-cvs mailing list