diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-02-23 17:58:36 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-06 17:04:31 +0300 |
commit | 818ee188e704b61ce745d3394483183a86994608 (patch) | |
tree | f357afdda2b36e143531cf357e31df9d6a55189d /source/blender/alembic | |
parent | e4367ccb786c246c388b043e1cd154efc518fe3f (diff) |
Alembic import: separated reading matrix and getting the appropriate Xform object
Also added a bit better error reporting, instead of silently ignoring
invalid Alembic data.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r-- | source/blender/alembic/intern/abc_object.cc | 47 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_object.h | 6 |
2 files changed, 36 insertions, 17 deletions
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index 3765e13d585..0b2c8cb6b8a 100644 --- a/source/blender/alembic/intern/abc_object.cc +++ b/source/blender/alembic/intern/abc_object.cc @@ -236,37 +236,50 @@ 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; - IObject ixform_parent; +Alembic::AbcGeom::IXform AbcObjectReader::xform() +{ /* Check that we have an empty object (locator, bone head/tail...). */ if (IXform::matches(m_iobject.getMetaData())) { - ixform = IXform(m_iobject, Alembic::AbcGeom::kWrapExisting); - ixform_parent = m_iobject.getParent(); + return IXform(m_iobject, Alembic::AbcGeom::kWrapExisting); } - /* 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); - ixform_parent = m_iobject.getParent().getParent(); + + /* Check that we have an object with actual data, in which case the + * parent Alembic object should contain the transform. */ + IObject abc_parent = m_iobject.getParent(); + + /* The archive's top object can be recognised by not having a parent. */ + if (abc_parent.getParent() + && IXform::matches(abc_parent.getMetaData())) { + return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting); } + /* Should not happen. */ - else { - std::cerr << "AbcObjectReader::read_matrix: " - << "unable to find IXform for Alembic object '" - << m_iobject.getFullName() << "'\n"; - BLI_assert(false); + std::cerr << "AbcObjectReader::xform(): " + << "unable to find IXform for Alembic object '" + << m_iobject.getFullName() << "'\n"; + BLI_assert(false); + + return IXform(); +} + + +void AbcObjectReader::read_matrix(float mat[4][4], const float time, const float scale, bool &is_constant) +{ + IXform ixform = xform(); + if (!ixform) { return; } - const IXformSchema &schema(ixform.getSchema()); - + const IXformSchema & schema(ixform.getSchema()); if (!schema.valid()) { + std::cerr << "Alembic object " << ixform.getFullName() + << " has an invalid schema." << std::endl; return; } bool has_alembic_parent; + IObject ixform_parent = ixform.getParent(); if (!ixform_parent.getParent()) { /* The archive top object certainly is not a transform itself, so handle * it as "no parent". */ diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h index 7d400f17a2a..6d97c0359b7 100644 --- a/source/blender/alembic/intern/abc_object.h +++ b/source/blender/alembic/intern/abc_object.h @@ -158,6 +158,12 @@ public: const Alembic::Abc::IObject &iobject() const; + /** + * Returns the transform of this object. This can be the Alembic object + * itself (in case of an Empty) or it can be the parent Alembic object. + */ + virtual Alembic::AbcGeom::IXform xform(); + Object *object() const; void object(Object *ob); |