diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-02-15 17:29:41 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-06 17:04:31 +0300 |
commit | 62a47f9660c18787de4def41dde149c67e416547 (patch) | |
tree | 2468e1a991097c1379f4e54e5f837e84e0aa3c9c | |
parent | 347a4956a0f4c12f8bcaa789f0574bada3e4db63 (diff) |
Alembic: cleaned up hack in AbcObjectReader::read_matrix()
-rw-r--r-- | source/blender/alembic/intern/abc_object.cc | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index a0cd378ff95..3765e13d585 100644 --- a/source/blender/alembic/intern/abc_object.cc +++ b/source/blender/alembic/intern/abc_object.cc @@ -239,35 +239,24 @@ void AbcObjectReader::readObjectMatrix(const float time) void AbcObjectReader::read_matrix(float mat[4][4], const float time, const float scale, bool &is_constant) { IXform ixform; - bool has_alembic_parent = false; + IObject ixform_parent; /* Check that we have an empty object (locator, bone head/tail...). */ if (IXform::matches(m_iobject.getMetaData())) { ixform = IXform(m_iobject, Alembic::AbcGeom::kWrapExisting); - - /* See comment below. */ - has_alembic_parent = m_iobject.getParent().getParent().valid(); + ixform_parent = m_iobject.getParent(); } /* Check that we have an object with actual data. */ else if (IXform::matches(m_iobject.getParent().getMetaData())) { ixform = IXform(m_iobject.getParent(), Alembic::AbcGeom::kWrapExisting); - - /* This is a bit hackish, but we need to make sure that extra - * transformations added to the matrix (rotation/scale) are only applied - * to root objects. The way objects and their hierarchy are created will - * need to be revisited at some point but for now this seems to do the - * trick. - * - * Explanation of the trick: - * The first getParent() will return this object's transformation matrix. - * The second getParent() will get the parent of the transform, but this - * might be the archive root ('/') which is valid, so we go passed it to - * make sure that there is no parent. - */ - has_alembic_parent = m_iobject.getParent().getParent().getParent().valid(); + ixform_parent = m_iobject.getParent().getParent(); } /* Should not happen. */ else { + std::cerr << "AbcObjectReader::read_matrix: " + << "unable to find IXform for Alembic object '" + << m_iobject.getFullName() << "'\n"; + BLI_assert(false); return; } @@ -277,6 +266,16 @@ void AbcObjectReader::read_matrix(float mat[4][4], const float time, const float return; } + bool has_alembic_parent; + if (!ixform_parent.getParent()) { + /* The archive top object certainly is not a transform itself, so handle + * it as "no parent". */ + has_alembic_parent = false; + } + else { + has_alembic_parent = ixform_parent && schema.getInheritsXforms(); + } + const Imath::M44d matrix = get_matrix(schema, time); convert_matrix(matrix, m_object, mat, scale, has_alembic_parent); |