Commit: 3f4f0a1b38201e14a38eaee0d66feb969da644e1 Author: Sybren A. Stüvel Date: Wed Feb 15 15:29:41 2017 +0100 Branches: temp-sybren-alembic https://developer.blender.org/rB3f4f0a1b38201e14a38eaee0d66feb969da644e1
Alembic: cleaned up hack in AbcObjectReader::read_matrix() =================================================================== M source/blender/alembic/intern/abc_object.cc =================================================================== diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index a5b8af542f..3a3b076dbf 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,20 @@ 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 { + /* Sybren: getInhertisXforms() should be a const function, see Alembic + * pull request at https://github.com/alembic/alembic/pull/111 and + * bug report at https://github.com/alembic/alembic/issues/110 */ + IXformSchema & schema_mutable = const_cast<IXformSchema &>(schema); + has_alembic_parent = ixform_parent && schema_mutable.getInheritsXforms(); + } + const Imath::M44d matrix = get_matrix(schema, time); convert_matrix(matrix, m_object, mat, scale, has_alembic_parent); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs