[Bf-blender-cvs] [301f648f3a9] temp-io-alembic-changes-up-to-D7672: Alembic: export object data with object data name

Sybren A. Stüvel noreply at git.blender.org
Fri May 8 17:57:50 CEST 2020


Commit: 301f648f3a92da450d086608d4672cea229f99ca
Author: Sybren A. Stüvel
Date:   Fri May 8 13:23:47 2020 +0200
Branches: temp-io-alembic-changes-up-to-D7672
https://developer.blender.org/rB301f648f3a92da450d086608d4672cea229f99ca

Alembic: export object data with object data name

The old exporter always exported a mesh object to `{object.name}/{object.name}Shape`. Now it exports to `{object.name}/{mesh.name}` instead. The same change also applies to other object data types.

Note that the code now is a bit hackish, as `m_name` is set even in cases where it isn't used. This hackishness was already there, though, but it's now just more visible. This will all be cleaned up when the Alembic exporter is ported to use the `AbstractHierarchyImporter` structure of USD.

Differential Revision: https://developer.blender.org/D7672

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

M	source/blender/io/alembic/intern/abc_writer_object.cc
M	tests/python/alembic_tests.py

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

diff --git a/source/blender/io/alembic/intern/abc_writer_object.cc b/source/blender/io/alembic/intern/abc_writer_object.cc
index 75dc93bd08e..5f1af45ae9a 100644
--- a/source/blender/io/alembic/intern/abc_writer_object.cc
+++ b/source/blender/io/alembic/intern/abc_writer_object.cc
@@ -32,7 +32,17 @@ AbcObjectWriter::AbcObjectWriter(Object *ob,
                                  AbcObjectWriter *parent)
     : m_object(ob), m_settings(settings), m_time_sampling(time_sampling), m_first_frame(true)
 {
-  m_name = get_id_name(m_object) + "Shape";
+  /* This class is used as superclass for objects themselves (i.e. transforms) and for object
+   * data (meshes, curves, cameras, etc.). However, when writing transforms, the m_name field is
+   * ignored. This is a temporary tweak to get the exporter to write object data with the data
+   * name instead of the object name in a safe way. */
+  if (m_object->data == nullptr) {
+    m_name = get_id_name(m_object);
+  }
+  else {
+    ID *ob_data = static_cast<ID *>(m_object->data);
+    m_name = get_id_name(ob_data);
+  }
 
   if (parent) {
     parent->addChild(this);
diff --git a/tests/python/alembic_tests.py b/tests/python/alembic_tests.py
index 8c0315f1b68..0b5126bc3bc 100644
--- a/tests/python/alembic_tests.py
+++ b/tests/python/alembic_tests.py
@@ -252,10 +252,10 @@ class CurveExportTest(AbstractAlembicTest):
         self.run_blender('single-curve.blend', script)
 
         # Now check the resulting Alembic file.
-        abcprop = self.abcprop(abc, '/NurbsCurve/NurbsCurveShape/.geom')
+        abcprop = self.abcprop(abc, '/NurbsCurve/CurveData/.geom')
         self.assertEqual(abcprop['.orders'], [4])
 
-        abcprop = self.abcprop(abc, '/NurbsCurve/NurbsCurveShape/.geom/.userProperties')
+        abcprop = self.abcprop(abc, '/NurbsCurve/CurveData/.geom/.userProperties')
         self.assertEqual(abcprop['blender:resolution'], 10)
 
 
@@ -285,7 +285,7 @@ class HairParticlesExportTest(AbstractAlembicTest):
         abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom')
         self.assertIn('.velocities', abcprop)
 
-        abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom')
+        abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom')
         self.assertIn('.faceIndices', abcprop)
 
     @with_tempdir
@@ -298,7 +298,7 @@ class HairParticlesExportTest(AbstractAlembicTest):
         self.assertRaises(AbcPropError, self.abcprop, abc,
                           '/Suzanne/Non-hair particle system/.geom')
 
-        abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom')
+        abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom')
         self.assertIn('.faceIndices', abcprop)
 
     @with_tempdir
@@ -310,7 +310,7 @@ class HairParticlesExportTest(AbstractAlembicTest):
         abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom')
         self.assertIn('.velocities', abcprop)
 
-        abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom')
+        abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom')
         self.assertIn('.faceIndices', abcprop)
 
     @with_tempdir
@@ -321,7 +321,7 @@ class HairParticlesExportTest(AbstractAlembicTest):
         self.assertRaises(AbcPropError, self.abcprop, abc,
                           '/Suzanne/Non-hair particle system/.geom')
 
-        abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom')
+        abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom')
         self.assertIn('.faceIndices', abcprop)
 
 
@@ -410,7 +410,7 @@ class LongNamesExportTest(AbstractAlembicTest):
             0.0, 3.0, 0.0, 1.0,
         ])
 
-        abcprop = self.abcprop(abc, '%s/CubeShape/.geom' % name)
+        abcprop = self.abcprop(abc, '%s/Cube/.geom' % name)
         self.assertIn('.faceCounts', abcprop)



More information about the Bf-blender-cvs mailing list